Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_gen_variance_int.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: Discrete]
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[Int]
27 redef fun foo(e)
28 do
29 e.bar
30 end
31 end
32
33 redef class Int
34 fun bar
35 do
36 2.output
37 end
38 end
39 redef class Char
40 fun not_bar
41 do
42 100.output
43 end
44 end
45
46 var h: G[Discrete] = new H
47 var b = 10
48 var d = 'A'
49 h.foo(b)
50 #alt1#h.foo(d)
51 '!'.output
52 b.bar
53 '!'.output
54 d.not_bar