[Raw FIR] Keep the name of an anonymous object of enum entry in classId of its nested classes
It is needed to have an ability to distinguish those two cases in FIR2IR: Without this change the following tests fail: - org.jetbrains.kotlin.test.runners.codegen.FirPsiBlackBoxCodegenTestGenerated.Enum - testEnumEntryReferenceFromInnerClassConstructor1() - testEnumEntryReferenceFromInnerClassConstructor2() - testEnumEntryReferenceFromInnerClassConstructor3() - testInnerClassMethodInEnumEntryClass() - testInnerClassMethodInEnumEntryClass2() - testKt9711_2() - testDeepInnerClassInEnumEntryClass() - testKt7257_boundReference1() - testInnerClassInEnumEntryClass() - testKt44744_innerClass()
This commit is contained in:
committed by
Space Team
parent
000c24fc69
commit
22f55b3dc4
+1
-4
@@ -419,8 +419,6 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
private val LighterASTNode.isDirectlyInsideEnumEntry get() = getParent()?.getParent()?.elementType == ENUM_ENTRY
|
||||
|
||||
/***** DECLARATIONS *****/
|
||||
/**
|
||||
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseClassOrObject
|
||||
@@ -460,8 +458,7 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
}
|
||||
|
||||
val className = identifier.nameAsSafeName(if (modifiers.isCompanion()) "Companion" else "")
|
||||
val isLocalWithinParent = classNode.isDirectlyInsideEnumEntry
|
||||
|| classNode.getParent()?.elementType != CLASS_BODY && isClassLocal(classNode) { getParent() }
|
||||
val isLocalWithinParent = classNode.getParent()?.elementType != CLASS_BODY && isClassLocal(classNode) { getParent() }
|
||||
val classIsExpect = modifiers.hasExpect() || context.containerIsExpect
|
||||
|
||||
return withChildClassName(className, isExpect = classIsExpect, isLocalWithinParent) {
|
||||
|
||||
+1
-5
@@ -1376,12 +1376,8 @@ open class PsiRawFirBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
private val KtElement.isDirectlyInsideEnumEntry get() = parent?.parent is KtEnumEntry
|
||||
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject, data: FirElement?): FirElement {
|
||||
// NB: enum entry nested classes are considered local by FIR design (see discussion in KT-45115)
|
||||
val isLocalWithinParent = classOrObject.isDirectlyInsideEnumEntry
|
||||
|| classOrObject.parent !is KtClassBody && classOrObject.isLocal
|
||||
val isLocalWithinParent = classOrObject.parent !is KtClassBody && classOrObject.isLocal
|
||||
val classIsExpect = classOrObject.hasExpectModifier() || context.containerIsExpect
|
||||
val sourceElement = classOrObject.toFirSourceElement()
|
||||
return withChildClassName(
|
||||
|
||||
Vendored
+1
-1
@@ -23,7 +23,7 @@ FILE: localDeclarationsInEnumEntry.kt
|
||||
}
|
||||
|
||||
local final? [ContainingClassKey=<anonymous>] class Nested : R|kotlin/Any| {
|
||||
public? [ContainingClassKey=Nested] constructor(): R|<local>/Nested| {
|
||||
public? [ContainingClassKey=Nested] constructor(): R|<local>/<anonymous>.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user