Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / base_types_formal_and_virtual2.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 end
16
17 interface Object
18 end
19
20 class Int
21 end
22
23 class Bool
24 end
25
26 class Char
27 end
28
29 class A[E, F]
30 type U: F
31
32 fun e: E is abstract
33 fun f: F is abstract
34 fun u: U is abstract
35
36 fun test1(a: A[E, F], ax: A[E, A[U, Int]])
37 do
38 __debug__ type E: self.e # E -> Object
39 __debug__ type F: self.f # F -> Object
40 __debug__ type U: self.u # U -> Object
41
42 __debug__ type E: a.e # E -> Object
43 __debug__ type F: a.f # F -> Object
44 __debug__ type F: a.u # F -> Object
45
46 __debug__ type A[U, Int]: ax.u # A[U, Int] -> A[Object, Int]
47 end
48 end
49
50 class B[G]
51 super A[Int, G]
52 fun g: G is abstract
53 end
54
55 class C[H: Char]
56 super B[Bool]
57
58 type W: B[H]
59
60 fun test3(b1: B[H], b2: B[W], w: W)
61 do
62 __debug__ type Int: self.e
63 __debug__ type U: self.u
64
65 __debug__ type H: b1.u
66
67 __debug__ type W: b2.u
68
69 __debug__ type H: w.u
70 end
71 end