Debian Codegraph @

src/test/01-Basic/245-depend-class-extend.ck

raw
1 // test declaring/instantation classes with inheritance, involving
2 // a member variable, declared in the file below its access
3 //
4 // related:
5 // https://github.com/ccrma/chuck/issues/349
6 // https://github.com/ccrma/chuck/issues/376
7
8 public class Foo
9 {
10 // this implicitly uses Bar.name, but okay since .name gets
11 // initialized in pre-ctor before all this runs
12 BarFactory.make() @=> Bar bar;
13 // test new
14 new BarChild @=> BarChild @ bc;
15 // test decl
16 BarChild bc2;
17 }
18
19 class Bar
20 {
21 "i am bar" => string name;
22 }
23
24 class BarChild extends Bar
25 {
26 "success" => name;
27 }
28
29 class BarFactory
30 {
31 fun static BarChild make()
32 {
33 return new BarChild;
34 }
35 }
36
37 // make a Foo
38 Foo foo;
39 // print
40 <<< foo.bar.name >>>;