scope: refuse `&x` where x is a local variable
[nit.git] / tests / base_init_super_call2.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import kernel
16
17 class A
18 var i: Int
19 end
20
21 class B1
22 super A
23 #alt1#init is old_style_init do super
24 end
25
26 class B2
27 super A
28 init is old_style_init do super(3)
29 end
30
31 class B3
32 super A
33 #alt2#init is old_style_init do super(true)
34 end
35
36 class B4
37 super A
38 #alt3#init is old_style_init do end
39 end
40
41 class C1
42 super A
43 init(j: Int) do
44 super
45 j.output
46 end
47 end
48
49 class D1
50 super A
51 init(j: Int) do
52 super
53 j.output
54 end
55 end
56
57 class E1
58 super A
59 init(j: Bool) do
60 super(8)#alt4#super
61 j.output
62 end
63 end
64
65 class C2
66 super A
67 init(j: Int) do
68 super(j)
69 j.output
70 end
71 end
72
73 class D2
74 super A
75 init(j: Int) do
76 super(j)
77 j.output
78 end
79 end
80
81 class E2
82 super A
83 init(j: Bool) do
84 super(11)#alt5#super(j)
85 j.output
86 end
87 end
88
89 class C3
90 super A
91 init(j: Int) do
92 super(j)#alt6#
93 j.output
94 end
95 end
96
97 class D3
98 super A
99 init(j: Int) do
100 super(j)#alt6#
101 j.output
102 end
103 end
104
105 class E3
106 super A
107 init(j: Bool) do
108 super(14)#alt6#
109 j.output
110 end
111 end
112
113 class F1
114 super A
115 init(j: Int, k: Bool) do
116 super
117 j.output
118 end
119 end
120
121 class F2
122 super A
123 init(j: Int, k: Bool) do
124 super(j)#alt6#
125 j.output
126 end
127 end
128
129 var x
130 x = new A(1)
131 x.i.output
132 x = new B1(2) #alt1# x = new B1
133 x.i.output
134 x = new B2
135 x.i.output
136 x = new B3(4) #alt2# x = new B3
137 x.i.output
138 x = new B4(5) #alt3# x = new B4
139 x.i.output
140 x = new C1(6)
141 x.i.output
142 x = new D1(7)
143 x.i.output
144 x = new E1(true)
145 x.i.output
146 x = new C2(9)
147 x.i.output
148 x = new D2(10)
149 x.i.output
150 x = new E2(true)
151 x.i.output
152 x = new C3(12)
153 x.i.output
154 x = new D3(13)
155 x.i.output
156 x = new E3(true)
157 x.i.output
158 x = new F1(15,true)
159 x.i.output
160 x = new F2(16,true)
161 x.i.output