[FIR] Allow, but also warn, KMutableProperty with captured types
^KT-63589 Fixed
This commit is contained in:
committed by
Space Team
parent
80d9933543
commit
b077293396
+34
@@ -0,0 +1,34 @@
|
||||
FILE: mutablePropertyGenericButNotCapturedType.kt
|
||||
public final class Generic<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|Generic<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Klass<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|Klass<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final var mutableProperty: R|Generic<T>| = R|/Generic.Generic|<R|T|>()
|
||||
public get(): R|Generic<T>|
|
||||
public set(value: R|Generic<T>|): R|kotlin/Unit|
|
||||
|
||||
public final fun testWithinClass(): R|kotlin/Unit| {
|
||||
lval mutableProperty: R|kotlin/reflect/KMutableProperty1<Klass<T>, Generic<T>>| = Q|Klass|::R|/Klass.mutableProperty|
|
||||
R|<local>/mutableProperty|.R|SubstitutionOverride<kotlin/reflect/KMutableProperty1.set: R|kotlin/Unit|>|(this@R|/Klass|, R|/Generic.Generic|<R|T|>())
|
||||
}
|
||||
|
||||
}
|
||||
public final fun testConcreteType(): R|kotlin/Unit| {
|
||||
lval mutableProperty: R|kotlin/reflect/KMutableProperty1<Klass<kotlin/Int>, Generic<kotlin/Int>>| = Q|Klass|::R|SubstitutionOverride</Klass.mutableProperty: R|Generic<kotlin/Int>|>|
|
||||
R|<local>/mutableProperty|.R|SubstitutionOverride<kotlin/reflect/KMutableProperty1.set: R|kotlin/Unit|>|(R|/Klass.Klass|<R|kotlin/Int|>(), R|/Generic.Generic|<R|kotlin/Int|>())
|
||||
}
|
||||
public final fun <A> testGenericType(): R|kotlin/Unit| {
|
||||
lval mutableProperty: R|kotlin/reflect/KMutableProperty1<Klass<A>, Generic<A>>| = Q|Klass|::R|SubstitutionOverride</Klass.mutableProperty: R|Generic<A>|>|
|
||||
R|<local>/mutableProperty|.R|SubstitutionOverride<kotlin/reflect/KMutableProperty1.set: R|kotlin/Unit|>|(R|/Klass.Klass|<R|A|>(), R|/Generic.Generic|<R|A|>())
|
||||
}
|
||||
public final fun <S : R|kotlin/CharSequence|> testGenericTypeWithBounds(): R|kotlin/Unit| {
|
||||
lval mutableProperty: R|kotlin/reflect/KMutableProperty1<Klass<S>, Generic<S>>| = Q|Klass|::R|SubstitutionOverride</Klass.mutableProperty: R|Generic<S>|>|
|
||||
R|<local>/mutableProperty|.R|SubstitutionOverride<kotlin/reflect/KMutableProperty1.set: R|kotlin/Unit|>|(R|/Klass.Klass|<R|S|>(), R|/Generic.Generic|<R|S|>())
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
class Generic<T>
|
||||
class Klass<T> {
|
||||
var mutableProperty: Generic<T> = Generic()
|
||||
|
||||
fun testWithinClass() {
|
||||
val mutableProperty = Klass<T>::mutableProperty
|
||||
mutableProperty.set(this, Generic<T>())
|
||||
}
|
||||
}
|
||||
|
||||
fun testConcreteType() {
|
||||
val mutableProperty = Klass<Int>::mutableProperty
|
||||
mutableProperty.set(Klass<Int>(), Generic<Int>())
|
||||
}
|
||||
|
||||
fun <A> testGenericType() {
|
||||
val mutableProperty = Klass<A>::mutableProperty
|
||||
mutableProperty.set(Klass<A>(), Generic<A>())
|
||||
}
|
||||
|
||||
fun <S: CharSequence> testGenericTypeWithBounds() {
|
||||
val mutableProperty = Klass<S>::mutableProperty
|
||||
mutableProperty.set(Klass<S>(), Generic<S>())
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
FILE: mutablePropertyWithCapturedType.kt
|
||||
public final class Generic<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|Generic<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Klass<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|Klass<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final var mutableProperty: R|Generic<T>| = R|/Generic.Generic|<R|T|>()
|
||||
public get(): R|Generic<T>|
|
||||
public set(value: R|Generic<T>|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
lval mutableProperty: R|kotlin/reflect/KMutableProperty1<Klass<*>, Generic<out kotlin/Any?>>| = Q|Klass|::R|SubstitutionOverride</Klass.mutableProperty: R|Generic<CapturedType(*)>|>|
|
||||
R|<local>/mutableProperty|.R|SubstitutionOverride<kotlin/reflect/KMutableProperty1.set: R|kotlin/Unit|>|(R|/Klass.Klass|<R|kotlin/Int|>(), R|/Generic.Generic|<R|kotlin/String|>())
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Generic<T>
|
||||
class Klass<T> {
|
||||
var mutableProperty: Generic<T> = Generic()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val mutableProperty = Klass<*>::<!MUTABLE_PROPERTY_WITH_CAPTURED_TYPE!>mutableProperty<!>
|
||||
mutableProperty.set(Klass<Int>(), Generic<String>())
|
||||
}
|
||||
Reference in New Issue
Block a user