[NI] Make constraint check for type variables with complex dependency

Additional check for trivial constraints is needed to make lambda
analysis before outer variable fixation to Nothing(?)

^KT-37627 Fixed
This commit is contained in:
Pavel Kirpichenkov
2020-03-24 17:55:53 +03:00
parent 568b21e31c
commit e39b69839b
13 changed files with 208 additions and 3 deletions
@@ -0,0 +1,69 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// Isuue: KT-37627
class Inv<T>(arg: T)
class Pair<A, B>
infix fun <M, N> M.to(other: N): Pair<M, N> = TODO()
fun <I> id(arg: I): I = arg
fun <S> select(vararg args: S): S = TODO()
fun test(bool: Boolean) {
val test1 = if (bool) {
{ "1" }
} else null
test1
val test2 = if (bool) {
id { "2" }
} else null
test2
val test3 = if (bool) {
Inv { "3" }
} else null
test3
val test4 = if (bool) {
4 to { "4" }
} else null
test4
val test5 = if (bool) {
{{ "5" }}
} else null
test5
val test6 = if (bool) {
id { { "6" } }
} else null
test6
val test7 = if (bool) {
Inv { { "7" } }
} else null
test7
val test8 = if (bool) {
8 to { { "8" } }
} else null
test8
val test9 = select({ "9" }, null)
test9
val test10 = select(id { "10" }, null)
test10
val test11 = select(null, Inv { "11" })
test11
val test12 = select({ 12 to "" }, null)
test12
val test13: Pair<Int, () -> () -> String>? = if(bool) {
13 to { { "13" } }
} else null
test13
}
@@ -0,0 +1,69 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// Isuue: KT-37627
class Inv<T>(arg: T)
class Pair<A, B>
infix fun <M, N> M.to(other: N): Pair<M, N> = TODO()
fun <I> id(arg: I): I = arg
fun <S> select(vararg args: S): S = TODO()
fun test(bool: Boolean) {
val test1 = if (bool) {
{ "1" }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> kotlin.String)?")!>test1<!>
val test2 = if (bool) {
id { "2" }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> kotlin.String)?")!>test2<!>
val test3 = if (bool) {
Inv { "3" }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<() -> kotlin.String>?")!>test3<!>
val test4 = if (bool) {
4 to { "4" }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("Pair<kotlin.Int, () -> kotlin.String>?")!>test4<!>
val test5 = if (bool) {
{{ "5" }}
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> () -> kotlin.String)?")!>test5<!>
val test6 = if (bool) {
id { { "6" } }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> () -> kotlin.String)?")!>test6<!>
val test7 = if (bool) {
Inv { { "7" } }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<() -> () -> kotlin.String>?")!>test7<!>
val test8 = if (bool) {
8 to { { "8" } }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("Pair<kotlin.Int, () -> () -> kotlin.String>?")!>test8<!>
val test9 = select({ "9" }, null)
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> kotlin.String)?")!>test9<!>
val test10 = select(id { "10" }, null)
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> kotlin.String)?")!>test10<!>
val test11 = select(null, Inv { "11" })
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<() -> kotlin.String>?")!>test11<!>
val test12 = select({ 12 to "" }, null)
<!DEBUG_INFO_EXPRESSION_TYPE("(() -> Pair<kotlin.Int, kotlin.String>)?")!>test12<!>
val test13: Pair<Int, () -> () -> String>? = if(bool) {
13 to { { "13" } }
} else null
<!DEBUG_INFO_EXPRESSION_TYPE("Pair<kotlin.Int, () -> () -> kotlin.String>?")!>test13<!>
}
@@ -0,0 +1,20 @@
package
public fun </*0*/ I> id(/*0*/ arg: I): I
public fun </*0*/ S> select(/*0*/ vararg args: S /*kotlin.Array<out S>*/): S
public fun test(/*0*/ bool: kotlin.Boolean): kotlin.Unit
public infix fun </*0*/ M, /*1*/ N> M.to(/*0*/ other: N): Pair<M, N>
public final class Inv</*0*/ T> {
public constructor Inv</*0*/ T>(/*0*/ arg: T)
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 final class Pair</*0*/ A, /*1*/ B> {
public constructor Pair</*0*/ A, /*1*/ B>()
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
}