[NI] Prioritize variables with trivial constraints over complex ones
Consider the following constraint system (from the test example): Nothing? <: V1 F!! <: V2 Inv<V1> <: S Inv<V2> <: S Where V1, V2, S are type variables, and F has nullable upper bound. Type variable fixation order should be: V2 -> V1 -> S, and the problem was that previously after fixation of type variable V2 we were trying to fix S (before V1), so we had the following constraints on S: Inv<F!!> <: S Inv<V1> <: S => S were fixed to Inv<F!!> And after this V1 was fixed to F!! which is contradictory as Nothing? is not a subtype of F!!. #KT-33033 Fixed
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun <K> foo(t: K?) = Inv<K>()
|
||||
|
||||
fun <T> bar(t: T) = foo(t)
|
||||
fun <V1> bar1(t: V1): Inv<V1> = foo(t)
|
||||
fun <V2> bar2(t: V2): Inv<V2> = foo(t)
|
||||
|
||||
fun <S> select(x: S, y: S): S = x
|
||||
|
||||
fun <T> fail(t: T?) = if (t == null) bar(<!DEBUG_INFO_CONSTANT!>t<!>) else bar(<!DEBUG_INFO_SMARTCAST!>t<!>)
|
||||
fun <F> fail1(t: F?, n: Nothing?) = select(bar1(<!DEBUG_INFO_CONSTANT!>n<!>), bar2(t!!))
|
||||
fun <F> fail2(t: F?, n: Nothing?) = if (t == null) bar1(<!DEBUG_INFO_CONSTANT!>t<!>) else bar2(<!DEBUG_INFO_SMARTCAST!>t<!>)
|
||||
fun <F> fail3(t: F?) = select(bar1(null), bar2(t?.let { it }))
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar(/*0*/ t: T): Inv<T>
|
||||
public fun </*0*/ V1> bar1(/*0*/ t: V1): Inv<V1>
|
||||
public fun </*0*/ V2> bar2(/*0*/ t: V2): Inv<V2>
|
||||
public fun </*0*/ T> fail(/*0*/ t: T?): Inv<out T?>
|
||||
public fun </*0*/ F> fail1(/*0*/ t: F?, /*1*/ n: kotlin.Nothing?): Inv<out F?>
|
||||
public fun </*0*/ F> fail2(/*0*/ t: F?, /*1*/ n: kotlin.Nothing?): Inv<out F?>
|
||||
public fun </*0*/ F> fail3(/*0*/ t: F?): Inv<out F?>
|
||||
public fun </*0*/ K> foo(/*0*/ t: K?): Inv<K>
|
||||
public fun </*0*/ S> select(/*0*/ x: S, /*1*/ y: S): S
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
Reference in New Issue
Block a user