[FIR] Resolve value class constructor to TYPES before using its params
Right now it is the easiest way to ensure that all the parameters are resolved. After KT-53573 is fixed, we might use `resolvedReturnTypeRef` on each parameter individually instead Also, add `toString` implementation to `ValueClassRepresentation` classes, so they are properly rendered in testdata ^KTIJ-22630 Fixed
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
|||||||
|
@JvmInline
|
||||||
|
value class Value(val value: Int) {
|
||||||
|
fun resolveMe() {}
|
||||||
|
}
|
||||||
+187
@@ -0,0 +1,187 @@
|
|||||||
|
|
||||||
|
RAW_FIR:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@JvmInline() public? final? inline [RAW_FIR] class Value : R|kotlin/Any| {
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] constructor([RAW_FIR] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPORTS:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@JvmInline() public? final? inline [RAW_FIR] class Value : R|kotlin/Any| {
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] constructor([RAW_FIR] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPILER_REQUIRED_ANNOTATIONS:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@JvmInline() public? final? inline [RAW_FIR] class Value : R|kotlin/Any| {
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] constructor([RAW_FIR] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [COMPILER_REQUIRED_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPANION_GENERATION:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@JvmInline() public? final? inline [RAW_FIR] class Value : R|kotlin/Any| {
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] constructor([RAW_FIR] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [COMPANION_GENERATION] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SUPER_TYPES:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@JvmInline() public? final? inline [RAW_FIR] class Value : R|kotlin/Any| {
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] constructor([RAW_FIR] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [RAW_FIR] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [RAW_FIR] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [SUPER_TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPES:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public? final? inline [SUPER_TYPES] class Value : R|kotlin/Any| {
|
||||||
|
public? [SUPER_TYPES] [ContainingClassKey=Value] constructor([SUPER_TYPES] [CorrespondingProperty=/Value.value] value: Int): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [SUPER_TYPES] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [SUPER_TYPES] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public? final? [TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
STATUS:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [SUPER_TYPES] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public? [TYPES] [ContainingClassKey=Value] constructor([TYPES] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [SUPER_TYPES] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [SUPER_TYPES] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public final [STATUS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGUMENTS_OF_ANNOTATIONS:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [SUPER_TYPES] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public? [TYPES] [ContainingClassKey=Value] constructor([TYPES] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [SUPER_TYPES] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [SUPER_TYPES] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public final [ARGUMENTS_OF_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CONTRACTS:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [SUPER_TYPES] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public? [TYPES] [ContainingClassKey=Value] constructor([TYPES] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public? final? [SUPER_TYPES] [IsFromPrimaryConstructor=true] val value: Int = R|<local>/value|
|
||||||
|
public? [SUPER_TYPES] [ContainingClassKey=Value] get(): Int
|
||||||
|
|
||||||
|
public final [CONTRACTS] fun resolveMe(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [STATUS] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public [STATUS] [ContainingClassKey=Value] constructor([STATUS] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [STATUS] [IsFromPrimaryConstructor=true] val value: R|kotlin/Int| = R|<local>/value|
|
||||||
|
public [STATUS] [ContainingClassKey=Value] get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_ACTUAL_MATCHING:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [STATUS] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public [STATUS] [ContainingClassKey=Value] constructor([STATUS] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [STATUS] [IsFromPrimaryConstructor=true] val value: R|kotlin/Int| = R|<local>/value|
|
||||||
|
public [STATUS] [ContainingClassKey=Value] get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BODY_RESOLVE:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [STATUS] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public [STATUS] [ContainingClassKey=Value] constructor([STATUS] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [STATUS] [IsFromPrimaryConstructor=true] val value: R|kotlin/Int| = R|<local>/value|
|
||||||
|
public [STATUS] [ContainingClassKey=Value] get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE RAW TO BODY:
|
||||||
|
FILE: functionInValueClass.kt
|
||||||
|
@R|kotlin/jvm/JvmInline|() public final inline [BODY_RESOLVE] [FirValueClassRepresentationKey=InlineClassRepresentation(underlyingPropertyName=value, underlyingType=kotlin/Int)] class Value : R|kotlin/Any| {
|
||||||
|
public [BODY_RESOLVE] [ContainingClassKey=Value] constructor([BODY_RESOLVE] [CorrespondingProperty=/Value.value] value: R|kotlin/Int|): R|Value| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final [BODY_RESOLVE] [IsFromPrimaryConstructor=true] val value: R|kotlin/Int| = R|<local>/value|
|
||||||
|
public [BODY_RESOLVE] [ContainingClassKey=Value] get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+6
@@ -152,6 +152,12 @@ public class FirLazyDeclarationResolveTestGenerated extends AbstractFirLazyDecla
|
|||||||
public void testClassWithTypeParameters() throws Exception {
|
public void testClassWithTypeParameters() throws Exception {
|
||||||
runTest("analysis/low-level-api-fir/testdata/lazyResolve/classes/classWithTypeParameters.kt");
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/classes/classWithTypeParameters.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("functionInValueClass.kt")
|
||||||
|
public void testFunctionInValueClass() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/classes/functionInValueClass.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+10
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.isInline
|
|||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.createTypeSubstitutorByTypeConstructor
|
import org.jetbrains.kotlin.fir.resolve.substitution.createTypeSubstitutorByTypeConstructor
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
@@ -47,8 +48,15 @@ fun computeValueClassRepresentation(klass: FirRegularClass, session: FirSession)
|
|||||||
return createValueClassRepresentation(session.typeContext, fields)
|
return createValueClassRepresentation(session.typeContext, fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirRegularClass.getValueClassUnderlyingParameters(session: FirSession): List<FirValueParameter>? =
|
private fun FirRegularClass.getValueClassUnderlyingParameters(session: FirSession): List<FirValueParameter>? {
|
||||||
if (isInline) primaryConstructorIfAny(session)?.fir?.valueParameters else null
|
if (!isInline) return null
|
||||||
|
|
||||||
|
val primaryConstructorIfAny = primaryConstructorIfAny(session) ?: return null
|
||||||
|
// FIXME: ATM we cannot lazy-resolve value parameters individually because of KT-53573
|
||||||
|
primaryConstructorIfAny.lazyResolveToPhase(FirResolvePhase.TYPES)
|
||||||
|
|
||||||
|
return primaryConstructorIfAny.fir.valueParameters
|
||||||
|
}
|
||||||
|
|
||||||
private fun isRecursiveSingleFieldValueClass(
|
private fun isRecursiveSingleFieldValueClass(
|
||||||
type: ConeSimpleKotlinType,
|
type: ConeSimpleKotlinType,
|
||||||
|
|||||||
@@ -19,4 +19,7 @@ class InlineClassRepresentation<Type : SimpleTypeMarker> constructor(
|
|||||||
override fun containsPropertyWithName(name: Name): Boolean = underlyingPropertyName == name
|
override fun containsPropertyWithName(name: Name): Boolean = underlyingPropertyName == name
|
||||||
|
|
||||||
override fun getPropertyTypeByName(name: Name): Type? = underlyingType.takeIf { containsPropertyWithName(name) }
|
override fun getPropertyTypeByName(name: Name): Type? = underlyingType.takeIf { containsPropertyWithName(name) }
|
||||||
|
|
||||||
|
override fun toString(): String =
|
||||||
|
"InlineClassRepresentation(underlyingPropertyName=$underlyingPropertyName, underlyingType=$underlyingType)"
|
||||||
}
|
}
|
||||||
+3
@@ -18,4 +18,7 @@ class MultiFieldValueClassRepresentation<Type : SimpleTypeMarker>(
|
|||||||
|
|
||||||
override fun containsPropertyWithName(name: Name): Boolean = name in map
|
override fun containsPropertyWithName(name: Name): Boolean = name in map
|
||||||
override fun getPropertyTypeByName(name: Name): Type? = map[name]
|
override fun getPropertyTypeByName(name: Name): Type? = map[name]
|
||||||
|
|
||||||
|
override fun toString(): String =
|
||||||
|
"MultiFieldValueClassRepresentation(underlyingPropertyNamesToTypes=$underlyingPropertyNamesToTypes)"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user