mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
33 lines
435 B
D
33 lines
435 B
D
|
|
// RUN: %ldc -enable-dynamic-compile -run %s
|
|
|
|
import ldc.attributes;
|
|
import ldc.dynamic_compile;
|
|
|
|
interface IFoo
|
|
{
|
|
int foo();
|
|
}
|
|
|
|
class Foo : IFoo
|
|
{
|
|
int val = 0;
|
|
|
|
@dynamicCompile int foo()
|
|
{
|
|
return val;
|
|
}
|
|
}
|
|
|
|
void main(string[] args)
|
|
{
|
|
auto f1 = new Foo;
|
|
auto f2 = cast(IFoo)f1;
|
|
auto fun = &f1.foo;
|
|
f1.val = 42;
|
|
|
|
compileDynamicCode();
|
|
assert(42 == f1.foo());
|
|
assert(42 == f2.foo());
|
|
assert(42 == fun());
|
|
}
|