update NOTICE and LICENSE
[nit.git] / tests / base_var_type_evolution_null3.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2010 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 G[A: nullable Object]
20 var _a: A
21 init (a: A) do _a = a
22
23 fun run
24 do
25 var a = _a
26
27 if a != null then
28 a.output
29 end
30
31 _a = a
32 end
33
34 fun na: nullable A = _a
35
36 fun run2
37 do
38 var na = na
39 if na != null then
40 na.output
41 _a = na
42 end
43
44 #alt1# _a = na
45 end
46 end
47
48 fun foo
49 do
50 var a: Object = 5
51 var o = a
52 if a != null then
53 a.output
54 end
55 o = a
56 end
57
58 fun rand: Bool do return true
59
60 var g = new G[Object](1)
61 g.run
62 g.run2
63 foo