1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
class StaticTest {
Int x;
init(Int x) {
init() { x = x; }
}
StaticTest create() : static, pure {
StaticTest(52);
}
Int fn(StaticTest z) : static {
z.x;
}
}
class StaticDerived extends StaticTest {
init(Int x) {
init(x) {}
}
Int fn(StaticDerived z) : static {
z.x + 5;
}
}
// Check decorators for free functions as well.
Int unity(Int v) : pure {
v;
}
Int testStatic() {
StaticTest v = StaticTest:create();
unity(v.x);
}
Int testStaticInheritance(Int x) {
StaticTest s = if (x == 0) { StaticTest(10); } else { StaticDerived(10); };
s.fn();
}
|