Add test for KT-54742

This commit is contained in:
pyos
2022-12-08 11:59:32 +01:00
committed by Dmitriy Novozhilov
parent 0bce15b862
commit 544cf386af
7 changed files with 132 additions and 0 deletions
@@ -0,0 +1,41 @@
interface I
open class C
fun completed(): String = "..."
fun <T> incomplete(): T = null!!
fun <T : I> incompatibleI(): T = null!!
fun <T : C> incompatibleC(): T = null!!
val p = false
fun expectUnit(x: Unit) = x
fun test1() = run {
if (p) return@run
completed() // ok, not returned
}
fun test2() = run {
if (p) return@run
incomplete() // ? either uninferred T or Unit
}
fun test3() = run {
if (p) return@run
incompatibleI() // ? either uninferred T or error (Unit </: I)
}
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>run<!> {
if (p) return@run
incompatibleC() // ? either uninferred T or error (Unit </: C)
}
fun main() {
// all ok
expectUnit(<!ARGUMENT_TYPE_MISMATCH!>test1()<!>)
expectUnit(test2())
expectUnit(test3())
expectUnit(test4())
}
@@ -0,0 +1,41 @@
interface I
open class C
fun completed(): String = "..."
fun <T> incomplete(): T = null!!
fun <T : I> incompatibleI(): T = null!!
fun <T : C> incompatibleC(): T = null!!
val p = false
fun expectUnit(x: Unit) = x
fun test1() = run {
if (p) return@run
completed() // ok, not returned
}
fun test2() = run {
if (p) return@run
incomplete() // ? either uninferred T or Unit
}
fun test3() = <!INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION!>run<!> {
if (p) return@run
incompatibleI() // ? either uninferred T or error (Unit </: I)
}
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>run<!> {
if (p) return@run
incompatibleC() // ? either uninferred T or error (Unit </: C)
}
fun main() {
// all ok
expectUnit(test1())
expectUnit(test2())
expectUnit(test3())
expectUnit(test4())
}
@@ -0,0 +1,26 @@
package
public val p: kotlin.Boolean = false
public fun completed(): kotlin.String
public fun expectUnit(/*0*/ x: kotlin.Unit): kotlin.Unit
public fun </*0*/ T : C> incompatibleC(): T
public fun </*0*/ T : I> incompatibleI(): T
public fun </*0*/ T> incomplete(): T
public fun main(): kotlin.Unit
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public open class C {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface I {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}