[FIR] Implement REIFIED_TYPE_FORBIDDEN_SUBSTITUTION

This commit is contained in:
Ivan Kochurkin
2021-07-15 15:29:41 +03:00
committed by teamcityserver
parent bade6cb611
commit 173813f7cf
14 changed files with 59 additions and 23 deletions
@@ -24,9 +24,9 @@ fun <T> test(x: T) {
baz<Int, String?>(<!NULL_FOR_NONNULL_TYPE!>null<!>, null, ::foo)
baz<Int?, String>(null, <!NULL_FOR_NONNULL_TYPE!>null<!>, ::foo)
baz(null, "", ::foo)
baz(1, null, ::foo)
baz(null, null, ::foo)
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>baz<!>(null, "", ::foo)
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>baz<!>(1, null, ::foo)
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION, REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>baz<!>(null, null, ::foo)
val s3: Pair<Int, String?> = <!TYPE_MISMATCH, TYPE_MISMATCH!>bar(null, null, ::foo)<!>
val s4: Pair<Int?, String> = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>bar(null, null, ::foo)<!>
@@ -11,5 +11,5 @@ fun test1() {
val f2: Foo<in Nothing> = foo1 { it checkType { _<Nothing>() } }
val f3: Foo<out Int> = foo2 { it checkType { _<Int>() } }
val f4: Foo<in Nothing> = foo2 { it checkType { _<Nothing>() } }
}
val f4: Foo<in Nothing> = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo2<!> { it checkType { _<Nothing>() } }
}
@@ -22,7 +22,7 @@ fun test2() {
}
fun test3() {
takeReifiedUnbound(null)
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>takeReifiedUnbound<!>(null)
}
fun test4(): Bound = takeReifiedUnbound(null)
@@ -35,7 +35,7 @@ fun test5(): Bound? = select(
fun test6() {
select(
null,
materializeReified()
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>materializeReified<!>()
)
}
@@ -48,6 +48,6 @@ fun test7(): Bound? =
fun test8() {
select(
null,
materializeReifiedUnbound()
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>materializeReifiedUnbound<!>()
)
}
@@ -28,7 +28,7 @@ inline fun <reified T : In<T>> testIn(): T {
// Unexpected behaviour
inline fun <reified T : Out<T>> testOut(): T {
return try {
outBound()
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>outBound<!>()
} catch (ex: Exception) {
throw Exception()
}
@@ -39,8 +39,8 @@ fun test4(
) {}
fun test5() {
arrayOf<Nothing>()
Array<Nothing>(10) { throw Exception() }
arrayOf<<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Nothing<!>>()
Array<<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Nothing<!>>(10) { throw Exception() }
}
fun <T> foo(): Array<T> = (object {} as Any) as Array<T>
@@ -5,12 +5,12 @@ inline fun<reified T> foo(block: () -> T): String = block().toString()
inline fun <reified T: Any> javaClass(): Class<T> = T::class.java
fun box() {
val a = arrayOf(null!!)
val b = Array<Nothing?>(5) { null!! }
val c = foo() { null!! }
val a = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>arrayOf<!>(null!!)
val b = Array<<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Nothing?<!>>(5) { null!! }
val c = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!>() { null!! }
val d = foo<Any> { null!! }
val e = foo { "1" as Nothing }
val e1 = foo { "1" as Nothing? }
val e = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!> { "1" as Nothing }
val e1 = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!> { "1" as Nothing? }
val f = javaClass<Nothing>()
val f = javaClass<<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Nothing<!>>()
}