mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Struct and typedef subtypes inherit dynamic functions.
This commit is contained in:
33
test/unit/regression/interface_inheritance.c3
Normal file
33
test/unit/regression/interface_inheritance.c3
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user