FIR: distinguish anonymous object as enum entry when scoping

so that `this` reference with the enum entry name as label can be
resolved
This commit is contained in:
Jinseong Jeon
2020-07-29 22:34:15 -07:00
committed by Mikhail Glukhikh
parent 52631b7abd
commit c744dfba9c
2 changed files with 5 additions and 2 deletions
@@ -400,7 +400,11 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
this.type = type
}
}
var result = withScopesForClass(null, anonymousObject, type) {
val labelName =
if (anonymousObject.classKind == ClassKind.ENUM_ENTRY) {
anonymousObject.getPrimaryConstructorIfAny()?.symbol?.callableId?.className?.shortName()
} else null
var result = withScopesForClass(labelName, anonymousObject, type) {
transformDeclarationContent(anonymousObject, data).single as FirAnonymousObject
}
if (!implicitTypeOnly && result.controlFlowGraphReference == FirEmptyControlFlowGraphReference) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
enum class A {
X {
val x = "OK"