[NI] Fix initial data flow info for analyzing lambdas
#KT-30734 Fixed
This commit is contained in:
+5
@@ -13944,6 +13944,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30734.kt")
|
||||
public void testKt30734() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt30734.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt362.kt")
|
||||
public void testKt362() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt");
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ class KotlinResolutionCallbacksImpl(
|
||||
.replaceBindingTrace(trace)
|
||||
.replaceContextDependency(lambdaInfo.contextDependency)
|
||||
.replaceExpectedType(approximatesExpectedType)
|
||||
.replaceDataFlowInfo(psiCallArgument.lambdaInitialDataFlowInfo).let {
|
||||
.replaceDataFlowInfo(psiCallArgument.dataFlowInfoBeforeThisArgument).let {
|
||||
if (coroutineSession != null) it.replaceInferenceSession(coroutineSession) else it
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> {
|
||||
}
|
||||
|
||||
fun returnFunctionLiteralExpressionBody(a: Any?): Function0<Int> =
|
||||
if (a is Int) { -> <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, OI;DEBUG_INFO_SMARTCAST!>a<!> }
|
||||
if (a is Int) { -> <!DEBUG_INFO_SMARTCAST!>a<!> }
|
||||
else { -> 1 }
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +NewInference
|
||||
// Issue: KT-30734
|
||||
|
||||
class Sample {
|
||||
fun foo(): Boolean = true
|
||||
}
|
||||
|
||||
fun test(ls: Sample?) {
|
||||
val filter: () -> Boolean = if (ls == null) {
|
||||
{ false }
|
||||
} else {
|
||||
{ <!DEBUG_INFO_SMARTCAST!>ls<!>.foo() } // OK in OI, error in NI
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ ls: Sample?): kotlin.Unit
|
||||
|
||||
public final class Sample {
|
||||
public constructor Sample()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -13951,6 +13951,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30734.kt")
|
||||
public void testKt30734() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt30734.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt362.kt")
|
||||
public void testKt362() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt");
|
||||
|
||||
Generated
+5
@@ -13946,6 +13946,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30734.kt")
|
||||
public void testKt30734() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt30734.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt362.kt")
|
||||
public void testKt362() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt362.kt");
|
||||
|
||||
Reference in New Issue
Block a user