FIR: Fix safe call receiver nullability after null check
This commit is contained in:
+6
@@ -17269,6 +17269,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallDefinitelyNotNull.kt")
|
||||
public void testSafeCallDefinitelyNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/safeCallDefinitelyNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samInConstructorWithGenerics.kt")
|
||||
public void testSamInConstructorWithGenerics() throws Exception {
|
||||
|
||||
+6
@@ -17269,6 +17269,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallDefinitelyNotNull.kt")
|
||||
public void testSafeCallDefinitelyNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/safeCallDefinitelyNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samInConstructorWithGenerics.kt")
|
||||
public void testSamInConstructorWithGenerics() throws Exception {
|
||||
|
||||
+6
@@ -17269,6 +17269,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallDefinitelyNotNull.kt")
|
||||
public void testSafeCallDefinitelyNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/safeCallDefinitelyNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samInConstructorWithGenerics.kt")
|
||||
public void testSamInConstructorWithGenerics() throws Exception {
|
||||
|
||||
+1
-1
@@ -890,7 +890,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
|
||||
safeCall.receiver.let { receiver ->
|
||||
val type = receiver.coneType.takeIf { it.isMarkedNullable }
|
||||
?.withNullability(ConeNullability.NOT_NULL, components.session.typeContext)
|
||||
?.makeConeTypeDefinitelyNotNullOrNotNull(components.session.typeContext)
|
||||
?: return@let
|
||||
|
||||
val variable = variableStorage.getOrCreateVariable(flow, receiver)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// SKIP_TXT
|
||||
// FILE: Api.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
public abstract class Api<T> {
|
||||
public abstract void typeOf(@NotNull T node);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <E> foo(a: Api<E>, e: E?) {
|
||||
e?.let { a.typeOf(e) }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// SKIP_TXT
|
||||
// FILE: Api.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
public abstract class Api<T> {
|
||||
public abstract void typeOf(@NotNull T node);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <E> foo(a: Api<E>, e: E?) {
|
||||
e?.let { a.typeOf(<!DEBUG_INFO_SMARTCAST!>e<!>) }
|
||||
}
|
||||
Generated
+6
@@ -17275,6 +17275,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallDefinitelyNotNull.kt")
|
||||
public void testSafeCallDefinitelyNotNull() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/j+k/safeCallDefinitelyNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samInConstructorWithGenerics.kt")
|
||||
public void testSamInConstructorWithGenerics() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user