Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_gen_variance3.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 G[E: A]
18 var e: nullable E = null
19 fun foo(e: E)
20 do
21 0.output
22 end
23 end
24
25 class H
26 super G[B]
27 redef fun foo(e)
28 do
29 e.bar
30 end
31 end
32
33 class A
34 end
35 class B
36 super A
37 fun bar
38 do
39 2.output
40 end
41 end
42 class D
43 super A
44 fun not_bar
45 do
46 100.output
47 end
48 end
49
50 var h: G[A] = new H
51 var b = new B
52 var d = new D
53 h.foo(b)
54 #alt1#h.foo(d)
55 '!'.output
56 b.bar
57 '!'.output
58 d.not_bar