FIR body resolve context: fix accessor scope handling

This commit is contained in:
Mikhail Glukhikh
2021-03-17 08:39:21 +03:00
parent ca15df7815
commit ebfc431733
9 changed files with 2520 additions and 2 deletions
@@ -1226,7 +1226,9 @@ class Fir2IrDeclarationStorage(
private fun getIrVariableSymbol(firVariable: FirVariable<*>): IrVariableSymbol {
return localStorage.getVariable(firVariable)?.symbol
?: throw IllegalArgumentException("Cannot find variable ${firVariable.render()} in local storage")
?: run {
throw IllegalArgumentException("Cannot find variable ${firVariable.render()} in local storage")
}
}
fun getIrValueSymbol(firVariableSymbol: FirVariableSymbol<*>): IrSymbol {
@@ -2110,6 +2110,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/firProblems/AnnotationLoader.kt");
}
@Test
@TestMetadata("ArrayMap.kt")
public void testArrayMap() throws Exception {
runTest("compiler/testData/ir/irText/firProblems/ArrayMap.kt");
}
@Test
@TestMetadata("candidateSymbol.kt")
public void testCandidateSymbol() throws Exception {
@@ -606,7 +606,11 @@ class BodyResolveContext(
f: () -> T
): T {
if (accessor is FirDefaultPropertyAccessor || accessor.body == null) {
return withContainer(accessor, f)
return if (accessor.isGetter) withContainer(accessor, f)
else withTowerDataCleanup {
addLocalScope(FirLocalScope())
withContainer(accessor, f)
}
}
return withTowerDataCleanup {
val receiverTypeRef = property.receiverTypeRef