[FIR] Fix resolving of refs with implicit this in lambdas in smartcasts
This commit is contained in:
+6
@@ -27932,6 +27932,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitThisOnRefInLambdaInSmartcast.kt")
|
||||
public void testImplicitThisOnRefInLambdaInSmartcast() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitToGrandSon.kt")
|
||||
public void testImplicitToGrandSon() throws Exception {
|
||||
|
||||
+6
@@ -27932,6 +27932,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitThisOnRefInLambdaInSmartcast.kt")
|
||||
public void testImplicitThisOnRefInLambdaInSmartcast() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitToGrandSon.kt")
|
||||
public void testImplicitToGrandSon() throws Exception {
|
||||
|
||||
+5
-3
@@ -105,14 +105,15 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
val index = receiverStack.getReceiverIndex(symbol) ?: return
|
||||
val info = flow.getTypeStatement(variable)
|
||||
|
||||
if (info == null) {
|
||||
receiverStack.replaceReceiverType(index, receiverStack.getOriginalType(index))
|
||||
val type = if (info == null) {
|
||||
receiverStack.getOriginalType(index)
|
||||
} else {
|
||||
val types = info.exactType.toMutableList().also {
|
||||
it += receiverStack.getOriginalType(index)
|
||||
}
|
||||
receiverStack.replaceReceiverType(index, context.intersectTypesOrNull(types)!!)
|
||||
context.intersectTypesOrNull(types)!!
|
||||
}
|
||||
receiverStack.replaceReceiverType(index, type)
|
||||
}
|
||||
|
||||
override fun updateAllReceivers(flow: PersistentFlow) {
|
||||
@@ -282,6 +283,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
// TODO: questionable
|
||||
postponedLambdaEnterNode?.mergeIncomingFlow()
|
||||
functionEnterNode.mergeIncomingFlow()
|
||||
logicSystem.updateAllReceivers(functionEnterNode.flow)
|
||||
}
|
||||
|
||||
private fun exitAnonymousFunction(anonymousFunction: FirAnonymousFunction): FirControlFlowGraphReference {
|
||||
|
||||
Reference in New Issue
Block a user