diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 3719cd80c34..d743d1a9b93 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -17663,6 +17663,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt"); } + @TestMetadata("kt32507.kt") + public void testKt32507() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32507.kt"); + } + @TestMetadata("kt328.kt") public void testKt328() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 549dce4fc2a..c16fa091a8d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -232,7 +232,7 @@ class DiagnosticReporterByTrackingStrategy( val call = if (call.callElement is KtBinaryExpression) null else call smartCastManager.checkAndRecordPossibleCast( dataFlowValue, smartCastDiagnostic.smartCastType, argumentExpression, context, call, - recordExpressionType = true + recordExpressionType = false ) } is ReceiverExpressionKotlinCallArgument -> { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.fir.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.fir.kt index a41b87bd9e3..2e9264619c7 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.fir.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.fir.kt @@ -1,5 +1,4 @@ // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST -// !WITH_NEW_INFERENCE fun bar(x: Int) = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt index 5192ef84474..a2a2b5f470d 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt @@ -1,5 +1,4 @@ // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST -// !WITH_NEW_INFERENCE fun bar(x: Int) = x + 1 fun foo() { @@ -13,17 +12,17 @@ fun foo() { if (1 > 2) bar(x) } if (x == null) { - bar(x) + bar(x) } - if (x == null) bar(x) else bar(x) + if (x == null) bar(x) else bar(x) bar(bar(x)) } else if (x == null) { bar(x) if (x != null) { - bar(x) - if (x == null) bar(x) - if (x == null) bar(x) else bar(x) - bar(bar(x) + bar(x)) + bar(x) + if (x == null) bar(x) + if (x == null) bar(x) else bar(x) + bar(bar(x) + bar(x)) } else if (x == null) { bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.fir.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.fir.kt index 3a0a0916cfd..28b3d130b89 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.fir.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.fir.kt @@ -1,4 +1,3 @@ -// !WITH_NEW_INFERENCE fun bar(x: Int): Int = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt index c90ae2af731..0589735a2ef 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt @@ -1,4 +1,3 @@ -// !WITH_NEW_INFERENCE fun bar(x: Int): Int = x + 1 fun foo() { @@ -11,7 +10,7 @@ fun foo() { bar(x) for (q in a) { bar(x) - if (x == null) bar(x) + if (x == null) bar(x) } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.fir.kt index f010cf53a13..c533df109b8 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.fir.kt @@ -1,5 +1,3 @@ -// !WITH_NEW_INFERENCE - fun foo(d: Any?) { if (d is String?) { d!! diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt index 2e8b39b2dd5..97d793a3369 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt @@ -1,9 +1,7 @@ -// !WITH_NEW_INFERENCE - fun foo(d: Any?) { if (d is String?) { d!! - doString(d) + doString(d) } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt32507.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt32507.fir.kt new file mode 100644 index 00000000000..d215d2b6135 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt32507.fir.kt @@ -0,0 +1,7 @@ +// !LANGUAGE: +NewInference + +fun foo(bar: Any?): Int { + bar as String? + bar ?: throw IllegalStateException() + return bar.length +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt32507.kt b/compiler/testData/diagnostics/tests/regressions/kt32507.kt new file mode 100644 index 00000000000..14e13ed6181 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt32507.kt @@ -0,0 +1,7 @@ +// !LANGUAGE: +NewInference + +fun foo(bar: Any?): Int { + bar as String? + bar ?: throw IllegalStateException() + return bar.length +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt32507.txt b/compiler/testData/diagnostics/tests/regressions/kt32507.txt new file mode 100644 index 00000000000..9233982b03a --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt32507.txt @@ -0,0 +1,3 @@ +package + +public fun foo(/*0*/ bar: kotlin.Any?): kotlin.Int diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index c34dcdf0e64..f8fc3639a16 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -17675,6 +17675,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt"); } + @TestMetadata("kt32507.kt") + public void testKt32507() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32507.kt"); + } + @TestMetadata("kt328.kt") public void testKt328() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index f4b571afb54..1393ac3e654 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -17665,6 +17665,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt"); } + @TestMetadata("kt32507.kt") + public void testKt32507() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32507.kt"); + } + @TestMetadata("kt328.kt") public void testKt328() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt");