Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / rterror_attr_def.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 I
18 var v: Int
19 redef fun output do v.output
20 end
21
22 class A
23 var o: Object = 'c'
24 var a: I is noinit
25 var b: nullable I = null
26 #alt2#var c: I = self.a
27 #alt3#var d: I = self.b.as(not null)
28 #alt4#var e: I = self.o.as(I)
29 #alt5#var f: I = self.initattr
30 #alt6#var g: I = self.getnull.a
31
32 fun initattr: I do abort
33 fun getnull: nullable A do return null
34
35 init
36 do
37 self.a = new I(1) #alt7#
38 self.b = new I(2) #alt8#
39 end
40 end
41
42 class B
43 super A
44
45 fun foo
46 do
47 self.o.output
48 '\n'.output
49 self.a.output
50 self.b.output
51 #alt2#self.c.output
52 #alt3#self.d.output
53 #alt4#self.e.output
54 #alt5#self.f.output
55 #alt6#self.g.output
56 end
57 end
58
59 var b = new B
60 b.foo
61 '\n'.output