Struct and typedef subtypes inherit dynamic functions.

This commit is contained in:
Christoffer Lerno
2025-08-23 22:31:29 +02:00
parent 48318c3ad4
commit 961aa0ef61
15 changed files with 686 additions and 470 deletions

View File

@@ -0,0 +1,33 @@
module inherit_interface;
import std;
interface Test
{
fn int x();
}
struct Foo (Test)
{
int z;
}
fn int Foo.x(&self) @dynamic
{
return 42;
}
struct Baz
{
inline Bar b;
}
struct Bar
{
inline Foo f;
}
fn void test_inheritance() @test
{
Baz x;
Test t = &x;
test::eq(t.x(), 42);
}