1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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 # Test classes for variance analysis
23 fun foo
: T
is abstract
28 fun foo
(t
: T
) is abstract
33 fun foo
(t
: T
) is abstract
35 fun bar
: T
is abstract
40 fun foo
(x
: Object) is abstract
43 # bivariant, the contravariant position of this complex expression
44 # reverse the variance, but contra*bivar = bivar
48 fun bar
(x
: E
[D
[C
[T
]]]) is abstract
51 # Covariant, the contravariant position reverse the variance,
52 # and the variance of A[B[T]] is contravariance
56 fun bar
(x
: A
[B
[T
]]) is abstract
59 # Can be annotated bivariant
63 fun bar
: A
[D
[E
[T
]]] is abstract
68 fun bar
: A
[B
[C
[T
]]] is abstract
73 fun bar
(x
: Dest[T
]) is abstract
78 fun bar
(x
: Src[T
]) is abstract
85 fun bar
(x
: Src[B
[T
]]) is abstract
90 fun foo
(x
: Cycle2[T
]): Cycle2[T
] is abstract
95 fun foo
(x
: Cycle2[T
]): C
[D
[T
]] is abstract