FIR DFA: fix logic clear aliasing
The logic should clear back aliases as well. To ensure all back aliases don't lose any information, statements on the original variable are copied over to its aliases.
This commit is contained in:
committed by
teamcityserver
parent
e495c722c7
commit
7e2f15f532
+6
@@ -28217,6 +28217,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/accessorAndFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("aliasing.kt")
|
||||
public void testAliasing() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/aliasing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInVariables() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/variables"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcast
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
import org.jetbrains.kotlin.fir.types.isStableSmartcast
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirSafe
|
||||
import org.jetbrains.kotlin.idea.frontend.api.ImplicitReceiverSmartCast
|
||||
import org.jetbrains.kotlin.idea.frontend.api.ImplicitReceiverSmartcastKind
|
||||
@@ -41,13 +42,13 @@ internal class KtFirSmartcastProvider(
|
||||
(extensionReceiver !is FirExpressionWithSmartcast || !extensionReceiver.isStable)
|
||||
) return emptyList()
|
||||
buildList {
|
||||
(dispatchReceiver as? FirExpressionWithSmartcast)?.takeIf { it.isStable }?.let { smartCasted ->
|
||||
dispatchReceiver.takeIf { it.isStableSmartcast() }?.let { smartCasted ->
|
||||
ImplicitReceiverSmartCast(
|
||||
smartCasted.typeRef.coneTypeSafe<ConeKotlinType>()?.asKtType() ?: return@let null,
|
||||
ImplicitReceiverSmartcastKind.DISPATCH
|
||||
)
|
||||
}?.let(::add)
|
||||
(extensionReceiver as? FirExpressionWithSmartcast)?.takeIf { it.isStable }?.let { smartCasted ->
|
||||
extensionReceiver.takeIf { it.isStableSmartcast() }?.let { smartCasted ->
|
||||
ImplicitReceiverSmartCast(
|
||||
smartCasted.typeRef.coneTypeSafe<ConeKotlinType>()?.asKtType() ?: return@let null,
|
||||
ImplicitReceiverSmartcastKind.EXTENSION
|
||||
|
||||
Reference in New Issue
Block a user