FIR: set constructor parameter scope correctly for designated transformer
This commit is contained in:
+6
-5
@@ -74,11 +74,6 @@ open class FirBodyResolveTransformer(
|
||||
private var primaryConstructorParametersScope: FirLocalScope? = null
|
||||
|
||||
override fun transformConstructor(constructor: FirConstructor, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
if (constructor.isPrimary) {
|
||||
primaryConstructorParametersScope = FirLocalScope().apply {
|
||||
constructor.valueParameters.forEach { this.storeDeclaration(it) }
|
||||
}
|
||||
}
|
||||
if (implicitTypeOnly) return constructor.compose()
|
||||
return super.transformConstructor(constructor, data)
|
||||
}
|
||||
@@ -131,6 +126,12 @@ open class FirBodyResolveTransformer(
|
||||
scopes.addIfNotNull(symbolProvider.getClassUseSiteMemberScope(companionObject.classId, session, scopeSession))
|
||||
}
|
||||
val result = withLabelAndReceiverType(regularClass.name, regularClass, type) {
|
||||
val constructor = regularClass.declarations.firstOrNull() as? FirConstructor
|
||||
if (constructor?.isPrimary == true) {
|
||||
primaryConstructorParametersScope = FirLocalScope().apply {
|
||||
constructor.valueParameters.forEach { this.storeDeclaration(it) }
|
||||
}
|
||||
}
|
||||
super.transformRegularClass(regularClass, data)
|
||||
}
|
||||
primaryConstructorParametersScope = oldConstructorScope
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Bar(name: () -> String) {
|
||||
val name = name()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FILE: propertyFromParameter.kt
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(name: R|kotlin/Function0<kotlin/String>|): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val name: <ERROR TYPE REF: cycle> = R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
public get(): <ERROR TYPE REF: cycle>
|
||||
|
||||
}
|
||||
+5
@@ -372,6 +372,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyFromParameter.kt")
|
||||
public void testPropertyFromParameter() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt");
|
||||
|
||||
Reference in New Issue
Block a user