Make 'self' a standard parameter (ParamVariable)
[nit.git] / tests / base_isa_cast_self.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2009 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 import kernel
18
19 class A
20 init do end
21
22 meth work
23 do
24 if self isa B then
25 foo
26 if self isa C then
27 bar
28 end
29 #alt1# bar
30 foo
31 else
32 #alt2# foo
33 end
34 #alt3# foo
35
36 if self isa B and self == self then
37 foo
38 end
39
40 if self isa B or self == self then
41 #alt4# foo
42 end
43
44 assert self isa B
45 foo
46 end
47 end
48
49 class B
50 special A
51 meth foo do 0.output
52 init do end
53 end
54
55 class C
56 special B
57 meth bar do 1.output
58 init do end
59 end
60
61 var a: A
62 a = new C
63 #alt5#a = new B
64 #alt6#a = new A
65 a.work