FIR: use correct context for enum entry resolve
Now the same resolve context is used for enum entries and for constructors.
This commit is contained in:
+49
@@ -30,6 +30,55 @@ FILE: selfReferenceToCompanionObject.kt
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final enum class Test : R|kotlin/Enum<Test>| {
|
||||
private constructor(x: R|kotlin/String|, closure1: R|() -> kotlin/String|): R|Test| {
|
||||
super<R|kotlin/Enum<Test>|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/String| = R|<local>/x|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final val closure1: R|() -> kotlin/String| = R|<local>/closure1|
|
||||
public get(): R|() -> kotlin/String|
|
||||
|
||||
public final static enum entry FOO: R|Test| = object : R|Test| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|Test|>(String(O), this@R|kotlin/Enum.Companion|.R|kotlin/run|<R|kotlin/Enum.Companion|, R|() -> kotlin/String|>(<L> = run@fun R|kotlin/Enum.Companion|.<anonymous>(): R|() -> kotlin/String| <kind=EXACTLY_ONCE> {
|
||||
^ run@fun <anonymous>(): R|kotlin/String| {
|
||||
^ R|/Test.FOO|.R|/Test.x|
|
||||
}
|
||||
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
public final override val y: R|kotlin/String| = String(K)
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final val closure2: R|() -> kotlin/String| = fun <anonymous>(): R|kotlin/String| {
|
||||
^ this@R|/<anonymous>|.R|/<anonymous>.y|
|
||||
}
|
||||
|
||||
public get(): R|() -> kotlin/String|
|
||||
|
||||
public final override val z: R|kotlin/String| = this@R|/<anonymous>|.R|/<anonymous>.closure2|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
|
||||
public abstract val y: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public abstract val z: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final static fun values(): R|kotlin/Array<Test>| {
|
||||
}
|
||||
|
||||
public final static fun valueOf(value: R|kotlin/String|): R|Test| {
|
||||
}
|
||||
|
||||
}
|
||||
public final fun box(): R|kotlin/String| {
|
||||
^box Q|Host.Companion|.R|/Base.fn|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
|
||||
Vendored
+11
@@ -6,4 +6,15 @@ class Host {
|
||||
}
|
||||
}
|
||||
|
||||
enum class Test(val x: String, val closure1: () -> String) {
|
||||
FOO("O", run { { FOO.x } }) {
|
||||
override val y: String = "K"
|
||||
val closure2 = { y } // Implicit 'FOO'
|
||||
override val z: String = closure2()
|
||||
};
|
||||
|
||||
abstract val y: String
|
||||
abstract val z: String
|
||||
}
|
||||
|
||||
fun box() = Host.Companion.fn()
|
||||
|
||||
+4
@@ -250,6 +250,10 @@ open class FirBodyResolveTransformer(
|
||||
return declarationsTransformer.transformDeclarationStatus(declarationStatus, data)
|
||||
}
|
||||
|
||||
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
||||
return declarationsTransformer.transformEnumEntry(enumEntry, data)
|
||||
}
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: ResolutionMode): CompositeTransformResult<FirProperty> {
|
||||
return declarationsTransformer.transformProperty(property, data)
|
||||
}
|
||||
|
||||
+6
@@ -99,6 +99,12 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
||||
context.withTowerDataContext(context.getTowerDataContextForConstructorResolution()) {
|
||||
return (enumEntry.transformChildren(this, data) as FirEnumEntry).compose()
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: ResolutionMode): CompositeTransformResult<FirProperty> {
|
||||
require(property !is FirSyntheticProperty) { "Synthetic properties should not be processed by body transfromers" }
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
enum class Test(val x: String, val closure1: () -> String) {
|
||||
FOO("O", run { { FOO.x } }) {
|
||||
override val y: String = "K"
|
||||
|
||||
Reference in New Issue
Block a user