[FIR] Fix resolving of refs with implicit this in lambdas in smartcasts
This commit is contained in:
+6
@@ -27932,6 +27932,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
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 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 {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun Any.test() {
|
||||
val x: () -> Int = when (this) {
|
||||
is String -> { { length } }
|
||||
else -> { { 1 } }
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun Any.test() {
|
||||
val x: () -> Int = when (this) {
|
||||
is String -> { { <!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!> } }
|
||||
else -> { { 1 } }
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun kotlin.Any.test(): kotlin.Unit
|
||||
Generated
+6
@@ -28022,6 +28022,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user