[Raw FIR] don't add an implicit Any super reference to kotlin/Any itself
KTIJ-27966
This commit is contained in:
committed by
Space Team
parent
d7190af72d
commit
c4fe7e4453
+8
-3
@@ -462,6 +462,9 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
val className = identifier.nameAsSafeName(if (modifiers.isCompanion()) "Companion" else "")
|
||||
val isLocalWithinParent = classNode.getParent()?.elementType != CLASS_BODY && isClassLocal(classNode) { getParent() }
|
||||
val classIsExpect = modifiers.hasExpect() || context.containerIsExpect
|
||||
val classIsKotlinAny = identifier.nameAsSafeName() == StandardNames.FqNames.any.shortName()
|
||||
&& classNode.getParent()?.getChildNodeByType(PACKAGE_DIRECTIVE)?.getChildNodeByType(REFERENCE_EXPRESSION)
|
||||
?.getReferencedNameAsName() == StandardNames.BUILT_INS_PACKAGE_NAME
|
||||
|
||||
return withChildClassName(className, isExpect = classIsExpect, isLocalWithinParent) {
|
||||
val isLocal = context.inLocalContext
|
||||
@@ -527,7 +530,7 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
superTypeRefs.ifEmpty {
|
||||
if (superTypeRefs.isEmpty() && !classIsKotlinAny) {
|
||||
superTypeRefs += implicitAnyType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
@@ -551,7 +554,8 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
classWrapper,
|
||||
delegatedConstructorSource,
|
||||
containingClassIsExpectClass = status.isExpect,
|
||||
isImplicitlyActual = status.isActual && (status.isInline || classKind == ClassKind.ANNOTATION_CLASS)
|
||||
isImplicitlyActual = status.isActual && (status.isInline || classKind == ClassKind.ANNOTATION_CLASS),
|
||||
isKotlinAny = classIsKotlinAny,
|
||||
)
|
||||
val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor
|
||||
firPrimaryConstructor?.let { declarations += it }
|
||||
@@ -887,6 +891,7 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
isEnumEntry: Boolean = false,
|
||||
containingClassIsExpectClass: Boolean,
|
||||
isImplicitlyActual: Boolean = false,
|
||||
isKotlinAny: Boolean = false,
|
||||
): PrimaryConstructor? {
|
||||
fun ClassKind.isEnumRelated(): Boolean = this == ClassKind.ENUM_CLASS || this == ClassKind.ENUM_ENTRY
|
||||
val shouldGenerateImplicitConstructor =
|
||||
@@ -912,7 +917,7 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
val modifiers = modifiersIfPresent ?: Modifier()
|
||||
|
||||
val defaultVisibility = classWrapper.defaultConstructorVisibility()
|
||||
val firDelegatedCall = runUnless(containingClassIsExpectClass) {
|
||||
val firDelegatedCall = runUnless(containingClassIsExpectClass || isKotlinAny) {
|
||||
fun createDelegatedConstructorCall(
|
||||
delegatedConstructorSource: KtLightSourceElement?,
|
||||
delegatedSuperTypeRef: FirTypeRef,
|
||||
|
||||
+15
@@ -196,6 +196,16 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinAny.kt")
|
||||
public void testKotlinAny() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/kotlinAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinAnyNonTopLevel.kt")
|
||||
public void testKotlinAnyNonTopLevel() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/kotlinAnyNonTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localDeclarationsInEnumEntry.kt")
|
||||
public void testLocalDeclarationsInEnumEntry() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/localDeclarationsInEnumEntry.kt");
|
||||
@@ -271,6 +281,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("userAny.kt")
|
||||
public void testUserAny() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/userAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("where.kt")
|
||||
public void testWhere() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
||||
|
||||
Reference in New Issue
Block a user