FE: don't approximate type variable based types for public/local declarations

#KT-58618 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-05-23 14:43:41 +02:00
committed by Space Team
parent 2cfa3d7e0d
commit 6e58ba8f33
5 changed files with 41 additions and 34 deletions
@@ -1,13 +0,0 @@
// FIR_DUMP
// WITH_REFLECT
import kotlin.reflect.KProperty
// Definitions
class State<T>(var value: T)
<!NOTHING_TO_INLINE!>inline<!> operator fun <T> State<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
inline fun <T> remember(block: () -> T): T = block()
// list should have a type of List<Int>, not Any?
val list by remember { State(listOf(0)) }
val first = list.<!UNRESOLVED_REFERENCE!>first<!>()
@@ -1,26 +1,26 @@
FILE: noInferenceFromWrappedDelegate.fir.kt
public final class State<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|State<T>| {
FILE: noInferenceFromWrappedDelegate.kt
public final class State<S> : R|kotlin/Any| {
public constructor<S>(value: R|S|): R|State<S>| {
super<R|kotlin/Any|>()
}
public final var value: R|T| = R|<local>/value|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
public final var value: R|S| = R|<local>/value|
public get(): R|S|
public set(value: R|S|): R|kotlin/Unit|
}
public final inline operator fun <T> R|State<T>|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|T| {
^getValue this@R|/getValue|.R|SubstitutionOverride</State.value: R|T|>|
public final inline operator fun <V> R|State<V>|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V| {
^getValue this@R|/getValue|.R|SubstitutionOverride</State.value: R|V|>|
}
public final inline fun <T> remember(block: R|() -> T|): R|T| {
^remember R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|T|>|()
public final inline fun <M> remember(block: R|() -> M|): R|M| {
^remember R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|M|>|()
}
public final val list: R|kotlin/Any?|by R|/remember|<R|State<kotlin/collections/List<kotlin/Int>>|>(<L> = remember@fun <anonymous>(): R|State<kotlin/collections/List<kotlin/Int>>| <inline=Inline, kind=UNKNOWN> {
public final val list: R|kotlin/collections/List<kotlin/Int>|by R|/remember|<R|State<kotlin/collections/List<kotlin/Int>>|>(<L> = remember@fun <anonymous>(): R|State<kotlin/collections/List<kotlin/Int>>| <inline=Inline, kind=UNKNOWN> {
^ R|/State.State|<R|kotlin/collections/List<kotlin/Int>|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(0)))
}
)
public get(): R|kotlin/Any?| {
public get(): R|kotlin/collections/List<kotlin/Int>| {
^ D|/list|.R|/getValue|<R|kotlin/collections/List<kotlin/Int>|>(Null(null), ::R|/list|)
}
public final val first: <ERROR TYPE REF: Unresolved name: first> = R|/list|.<Unresolved name: first>#()
public get(): <ERROR TYPE REF: Unresolved name: first>
public final val first: R|kotlin/Int| = R|/list|.R|kotlin/collections/first|<R|kotlin/Int|>()
public get(): R|kotlin/Int|
@@ -1,12 +1,13 @@
// FIR_IDENTICAL
// FIR_DUMP
// WITH_REFLECT
import kotlin.reflect.KProperty
// Definitions
class State<T>(var value: T)
<!NOTHING_TO_INLINE!>inline<!> operator fun <T> State<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
inline fun <T> remember(block: () -> T): T = block()
class State<S>(var value: S)
<!NOTHING_TO_INLINE!>inline<!> operator fun <V> State<V>.getValue(thisRef: Any?, property: KProperty<*>): V = value
inline fun <M> remember(block: () -> M): M = block()
// list should have a type of List<Int>, not Any?
val list by remember { State(listOf(0)) }