First NIT release and new clean mercurial repository
[nit.git] / tests / test_inh.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 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 end
18
19 # Base Classes
20
21 class Object
22 end
23
24 class Hashable
25 special Object
26 end
27 # Ancestor: "Object" on "Hashable"
28
29 class Comparable
30 special Object
31 end
32
33 class Int
34 special Hashable
35 special Comparable
36 end
37
38 # Complex Classes
39
40 class Pair[E]
41 special Object
42 end
43 class Pair[F: Hashable]
44 special Hashable
45 end
46 # Ancestor: "ANY": "Object" on "Pair[E: Object]"
47 # "HASHABLE": "Hashable" on "Pair[F: Hashable]"
48
49 class PairCmp[G: Comparable]
50 special Pair[G]
51 special Comparable
52 end
53 # Ancestor: "PAIR": "Pair[G]" on "PairCmp[G: Comparable]"
54 # => "ANY": "Object" on "PairCmp[G: Comparable]"
55 # => "HASHABLE": "Hashable" on "PairCmp[G: Comparable+Hahsable]"
56 # Ancestor: "COMPARABLE": "Comparable" on "PairCmp[G: Comparable]"
57
58 class Complex
59 special PairCmp[Int]
60 end
61 # Ancestor: "PAIRCMP": "PairCmp[Int]" on "Complex"
62 # => "PAIR": "Pair[Int]" on "Complex"
63 # => "ANY": "Object" on "Complex"
64 # => "HASHABLE": "Hashable" on "Complex"
65
66 # Un ancètre d'une classe c est un couple de types (ancetre, héritier) où héritier est dérivé de c
67 # les ancètres indirects de c par la filiation (a, h) sont
68 # pour chaque ancètres (aa, ha) de la classe de a
69 #
70
71 # un type a un contexte.
72 # Les ancetres d'une classes c sont un tas de types dont le contexte est dérivé de la classe c
73
74
75 # application: type1 x type2 x type3 -> type4 (ex "A[U]" x "A[E: T]" x "B[E,C]" -> "B[U,C]")
76 # * map: type1 x type2 -> hash (ex "A[U] x A[E: T]" -> {E->U})
77 # * betared: hash x type3 -> type4 (ex {E->U} x "B[E,C]" -> "B[U,C]"
78 # * application(x,y,z) = betared(map(x,y), z)
79 # remarques :
80 # * type2 est la liste des parametres formels
81 # * type1 peut contenir des paramètres formels
82 # ... l'application est plus compliquée
83
84 # application("Pair[Comparable]", "Pair[E: Comparable]", )