added CHECK_TYPE directive to diagnostic tests

This commit is contained in:
Svetlana Isakova
2013-12-18 16:11:56 +04:00
parent c9a600a405
commit dd6940be41
14 changed files with 95 additions and 59 deletions
@@ -1,6 +1,5 @@
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
class TypeOf<T>(t: T)
// !CHECK_TYPE
trait A<T>
fun <T> foo(a: A<T>, aN: A<T?>): T = throw Exception("$a $aN")
@@ -9,13 +8,13 @@ fun <T> doA(a: A<T>): T = throw Exception("$a")
fun test(a: A<Int>, aN: A<Int?>) {
val aa = doA(aN)
TypeOf(aa): TypeOf<Int?>
aa checkType { it : _<Int?> }
val nullable = foo(aN, aN)
//T = Int?, T? = Int? => T = Int?
TypeOf(nullable): TypeOf<Int?>
nullable checkType { it : _<Int?> }
val notNullable = foo(a, aN)
//T = Int, T? = Int? => T = Int
TypeOf(notNullable): TypeOf<Int>
notNullable checkType { it : _<Int> }
}
@@ -1,5 +1,4 @@
class TypeOf<T>(t: T)
// !CHECK_TYPE
trait A<T>
trait In<in T>
@@ -15,7 +14,7 @@ fun test(out: Out<Int>, i: In<Int>, inv: A<Int>) {
// T? >: Int => T = Int
doT(1)
val r = doOut(out)
TypeOf(r): TypeOf<Int>
r checkType { it : _<Int> }
// T? <: Int => error
doIn(<!TYPE_MISMATCH!>i<!>)
@@ -1,6 +1,5 @@
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
class TypeOf<T>(t: T)
// !CHECK_TYPE
trait A<T>
trait Out<out T>
@@ -12,13 +11,13 @@ fun <T> doOut(o: Out<T?>): T = throw Exception("$o")
fun test(a: A<Int>, aN: A<Int?>, o: Out<Int?>) {
val out = doOut(o)
//T? >: Int? => T >: Int
TypeOf(out): TypeOf<Int>
out checkType { it : _<Int> }
val nullable = foo(aN, o)
//T = Int?, T? >: Int? => T = Int?
TypeOf(nullable): TypeOf<Int?>
nullable checkType { it : _<Int?> }
val notNullable = foo(a, o)
//T = Int, T? >: Int? => T = Int
TypeOf(notNullable): TypeOf<Int>
notNullable checkType { it : _<Int> }
}
@@ -1,6 +1,5 @@
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
class TypeOf<T>(t: T)
// !CHECK_TYPE
trait A<T>
trait In<in T>
@@ -12,13 +11,13 @@ fun <T> doIn(i: In<T?>): T = throw Exception("$i")
fun test(a: A<Int>, aN: A<Int?>, i: In<Int?>) {
val _in = doIn(i)
//T? <: Int? => T <: Int?
TypeOf(_in): TypeOf<Int?>
_in checkType { it : _<Int?> }
val notNullable = foo(a, i)
//T = Int, T? <: Int? => T = Int
TypeOf(notNullable): TypeOf<Int>
notNullable checkType { it : _<Int> }
val nullable = foo(aN, i)
//T = Int?, T? <: Int? => T = Int?
TypeOf(nullable): TypeOf<Int?>
nullable checkType { it : _<Int?> }
}