[NI] Preserve constraint position for OnlyInputType during incorporation
Variable with complex dependency on other variable loses its original constraint position when variable it depends on is fixed. To prevent that, original input position is saved in incorporation position.
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
import kotlin.internal.OnlyInputTypes
|
||||
|
||||
interface Bound
|
||||
class First : Bound
|
||||
class Second : Bound
|
||||
class Inv<I >(val v: I)
|
||||
class InvB<I : Bound>(val v: I)
|
||||
class In<in C>(v: C)
|
||||
class InB<in C : Bound>(v: C)
|
||||
class Out<out O>(val v: O)
|
||||
class OutB<out O : Bound>(val v: O)
|
||||
|
||||
fun <@OnlyInputTypes M> strictId(arg: M): M = arg
|
||||
fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1
|
||||
|
||||
fun testOK(first: First, bound: Bound, second: Second) {
|
||||
strictId(Inv(15))
|
||||
strictId(Inv("foo"))
|
||||
strictId(Inv(first))
|
||||
strictId(InvB(first))
|
||||
strictId(In(first))
|
||||
strictId(InB(first))
|
||||
strictId(Out(first))
|
||||
strictId(OutB(first))
|
||||
strictId(Inv(Inv(Inv(first))))
|
||||
|
||||
strictSelect(Inv(first), Inv(first))
|
||||
strictSelect(InvB(first), InvB(first))
|
||||
|
||||
strictSelect(Out(first), Out(bound))
|
||||
strictSelect(OutB(first), OutB(bound))
|
||||
strictSelect(In(first), In(bound))
|
||||
strictSelect(InB(first), InB(bound))
|
||||
<!OI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(InB(first), InB(second)) // different behaviour in contravariant position
|
||||
|
||||
val out: Out<Bound> = strictSelect(Out(first), Out(second))
|
||||
val outb: OutB<Bound> = strictSelect(OutB(first), OutB(second))
|
||||
strictSelect<Out<Bound>>(Out(first), Out(second))
|
||||
strictSelect<OutB<Bound>>(OutB(first), OutB(second))
|
||||
}
|
||||
|
||||
fun testFail(first: First, bound: Bound, second: Second) {
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(InvB(first), InvB(bound))
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(Inv(first), Inv(bound))
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(Out(first), Out(second))
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(In(first), In(second))
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(Out(Inv(first)), Out(Inv(second)))
|
||||
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>strictSelect<!>(In(Inv(first)), In(Inv(second)))
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ @kotlin.internal.OnlyInputTypes M> strictId(/*0*/ arg: M): M
|
||||
public fun </*0*/ @kotlin.internal.OnlyInputTypes S> strictSelect(/*0*/ arg1: S, /*1*/ arg2: S): S
|
||||
public fun testFail(/*0*/ first: First, /*1*/ bound: Bound, /*2*/ second: Second): kotlin.Unit
|
||||
public fun testOK(/*0*/ first: First, /*1*/ bound: Bound, /*2*/ second: Second): kotlin.Unit
|
||||
|
||||
public interface Bound {
|
||||
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 First : Bound {
|
||||
public constructor First()
|
||||
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 In</*0*/ in C> {
|
||||
public constructor In</*0*/ in C>(/*0*/ v: 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 final class InB</*0*/ in C : Bound> {
|
||||
public constructor InB</*0*/ in C : Bound>(/*0*/ v: 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 final class Inv</*0*/ I> {
|
||||
public constructor Inv</*0*/ I>(/*0*/ v: I)
|
||||
public final val v: 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
|
||||
}
|
||||
|
||||
public final class InvB</*0*/ I : Bound> {
|
||||
public constructor InvB</*0*/ I : Bound>(/*0*/ v: I)
|
||||
public final val v: 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
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>(/*0*/ v: O)
|
||||
public final val v: O
|
||||
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 OutB</*0*/ out O : Bound> {
|
||||
public constructor OutB</*0*/ out O : Bound>(/*0*/ v: O)
|
||||
public final val v: O
|
||||
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 Second : Bound {
|
||||
public constructor Second()
|
||||
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