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