Hack: do not add trivial constraints (t <: Any?) for constituent types,
otherwise nested calls handling logic in old inference wouldn't work for type alias constructors.
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
interface Ref<T> {
|
||||
var x: T
|
||||
}
|
||||
|
||||
class LateInitNumRef<NN: Number>() : Ref<NN> {
|
||||
constructor(x: NN) : this() { this.x = x }
|
||||
|
||||
private var xx: NN? = null
|
||||
|
||||
override var x: NN
|
||||
get() = xx!!
|
||||
set(value) {
|
||||
xx = value
|
||||
}
|
||||
}
|
||||
|
||||
typealias LateNR<Nt> = LateInitNumRef<Nt>
|
||||
|
||||
fun <V, R : Ref<in V>> update(r: R, v: V): R {
|
||||
r.x = v
|
||||
return r
|
||||
}
|
||||
|
||||
val r1 = update(LateInitNumRef(), 1)
|
||||
val r1a = update(LateNR(), 1)
|
||||
val r2 = update(LateInitNumRef(1), 1)
|
||||
val r2a = update(LateNR(1), 1)
|
||||
val r3 = LateInitNumRef(1)
|
||||
val r3a = LateNR(1)
|
||||
|
||||
fun test() {
|
||||
r1.x = <!TYPE_MISMATCH!>r1.x<!>
|
||||
r1a.x = <!TYPE_MISMATCH!>r1a.x<!>
|
||||
r2.x = r2.x
|
||||
r2a.x = r2a.x
|
||||
r3.x = r3.x
|
||||
r3a.x = r3a.x
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public val r1: Ref<in kotlin.Int>
|
||||
public val r1a: Ref<in kotlin.Int>
|
||||
public val r2: LateInitNumRef<kotlin.Int>
|
||||
public val r2a: LateInitNumRef<kotlin.Int>
|
||||
public val r3: LateInitNumRef<kotlin.Int>
|
||||
public val r3a: LateInitNumRef<kotlin.Int>
|
||||
public fun test(): kotlin.Unit
|
||||
public fun </*0*/ V, /*1*/ R : Ref<in V>> update(/*0*/ r: R, /*1*/ v: V): R
|
||||
|
||||
public final class LateInitNumRef</*0*/ NN : kotlin.Number> : Ref<NN> {
|
||||
public constructor LateInitNumRef</*0*/ NN : kotlin.Number>()
|
||||
public constructor LateInitNumRef</*0*/ NN : kotlin.Number>(/*0*/ x: NN)
|
||||
public open override /*1*/ var x: NN
|
||||
private final var xx: NN?
|
||||
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 Ref</*0*/ T> {
|
||||
public abstract var x: 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 typealias LateNR</*0*/ Nt> = LateInitNumRef<Nt>
|
||||
Reference in New Issue
Block a user