added CHECK_TYPE directive to diagnostic tests
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
trait A
|
||||
trait B : A
|
||||
trait C : B
|
||||
|
||||
fun test(b: B) {
|
||||
b checkType { it : _<B> }
|
||||
b checkType { <!TYPE_MISMATCH!>it<!> : _<A> }
|
||||
b checkType { <!TYPE_MISMATCH!>it<!> : _<C> }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// !CHECK_TYPE
|
||||
fun test() {
|
||||
val a = if (true) {
|
||||
val x = 1
|
||||
@@ -5,7 +6,5 @@ fun test() {
|
||||
} else {
|
||||
{ 2 }
|
||||
}
|
||||
TypeOf(a): TypeOf<Function0<Int>>
|
||||
}
|
||||
|
||||
class TypeOf<T>(t: T)
|
||||
a checkType { it : _<() -> Int> }
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
class TypeOf<T>(t: T)
|
||||
|
||||
// !CHECK_TYPE
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
fun foo() {
|
||||
val i = id { 22 } //type inference error: no information for parameter
|
||||
TypeOf(i): TypeOf<()->Int>
|
||||
i checkType { it : _<()->Int> }
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,11 +1,9 @@
|
||||
// !CHECK_TYPE
|
||||
trait Tr<T> {
|
||||
var v: Tr<T>
|
||||
}
|
||||
|
||||
fun test(t: Tr<*>) {
|
||||
t.v = t
|
||||
val v = TypeOf(t.v)
|
||||
v: TypeOf<Tr<*>>
|
||||
}
|
||||
|
||||
class TypeOf<T>(t: T)
|
||||
t.v checkType { it : _<Tr<*>> }
|
||||
}
|
||||
+3
-5
@@ -1,4 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNREACHABLE_CODE -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// t is unused due to KT-4233
|
||||
trait Tr<T> {
|
||||
var v: T
|
||||
@@ -6,8 +7,5 @@ trait Tr<T> {
|
||||
|
||||
fun test(t: Tr<*>) {
|
||||
<!SETTER_PROJECTED_OUT!>t.v<!> = null!!
|
||||
val v = TypeOf(t.v)
|
||||
v: TypeOf<Any?>
|
||||
}
|
||||
|
||||
class TypeOf<T>(t: T)
|
||||
t.v checkType { it : _<Any?> }
|
||||
}
|
||||
+4
-5
@@ -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> }
|
||||
}
|
||||
|
||||
+2
-3
@@ -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<!>)
|
||||
|
||||
+4
-5
@@ -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> }
|
||||
}
|
||||
|
||||
+4
-5
@@ -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?> }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
package a
|
||||
|
||||
class TypeOf<T>(t: T)
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1
|
||||
@@ -21,7 +20,7 @@ fun test() {
|
||||
d: Int
|
||||
|
||||
val e = id(9223372036854775807)
|
||||
TypeOf(e): TypeOf<Long>
|
||||
e checkType { it : _<Long> }
|
||||
|
||||
val f: Byte = either(1, 2)
|
||||
|
||||
@@ -32,7 +31,7 @@ fun test() {
|
||||
<!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>otherGeneric<!>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
|
||||
|
||||
val r = either(1, "")
|
||||
TypeOf(r): TypeOf<Any>
|
||||
r checkType { it : _<Comparable<*>> }
|
||||
|
||||
use(a, b, c, d, e, f, g, r)
|
||||
}
|
||||
@@ -48,7 +47,7 @@ fun testExactBound(invS: Inv<String>, invI: Inv<Int>, invB: Inv<Byte>) {
|
||||
exactBound(1, invI)
|
||||
|
||||
val b = exactBound(1, invB)
|
||||
TypeOf(b): TypeOf<Byte>
|
||||
b checkType { it : _<Byte> }
|
||||
}
|
||||
|
||||
trait Cov<out T>
|
||||
@@ -57,10 +56,10 @@ fun <T> lowerBound(t: T, l : Cov<T>): T = throw Exception("$t $l")
|
||||
|
||||
fun testLowerBound(cov: Cov<String>, covN: Cov<Number>) {
|
||||
val r = lowerBound(1, cov)
|
||||
TypeOf(r): TypeOf<Any>
|
||||
r checkType { it : _<Comparable<*>> }
|
||||
|
||||
val n = lowerBound(1, covN)
|
||||
TypeOf(n): TypeOf<Number>
|
||||
n checkType { it : _<Number> }
|
||||
}
|
||||
|
||||
trait Contr<in T>
|
||||
@@ -71,8 +70,8 @@ fun testUpperBound(contrS: Contr<String>, contrB: Contr<Byte>, contrN: Contr<Num
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>upperBound<!>(1, contrS)
|
||||
|
||||
val n = upperBound(1, contrN)
|
||||
TypeOf(n): TypeOf<Int>
|
||||
n checkType { it : _<Int> }
|
||||
|
||||
val b = upperBound(1, contrB)
|
||||
TypeOf(b): TypeOf<Byte>
|
||||
b checkType { it : _<Byte> }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user