diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 325b272b706..1f7f5701953 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -680,6 +680,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt"); } + @Test + @TestMetadata("SafeCallNonNullReceiver2.kt") + public void testSafeCallNonNullReceiver2() throws Exception { + runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt"); + } + @Test @TestMetadata("SafeCallNonNullReceiverReturnNull.kt") public void testSafeCallNonNullReceiverReturnNull() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 451b8021b9f..9d0b6bd42c2 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -680,6 +680,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt"); } + @Test + @TestMetadata("SafeCallNonNullReceiver2.kt") + public void testSafeCallNonNullReceiver2() throws Exception { + runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt"); + } + @Test @TestMetadata("SafeCallNonNullReceiverReturnNull.kt") public void testSafeCallNonNullReceiverReturnNull() throws Exception { diff --git a/compiler/testData/codegen/box/objects/safeAccess.kt b/compiler/testData/codegen/box/objects/safeAccess.kt index 26efd8a6dae..78255aeee9f 100644 --- a/compiler/testData/codegen/box/objects/safeAccess.kt +++ b/compiler/testData/codegen/box/objects/safeAccess.kt @@ -5,4 +5,4 @@ object Test { val a = "OK" } -fun box(): String = Test?.a +fun box(): String? = Test?.a diff --git a/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall.kt b/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall.kt index 5a1fe4989db..1d7c468771f 100644 --- a/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall.kt +++ b/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall.kt @@ -3,4 +3,4 @@ fun test(s: String) = s?.length // 0 IFNULL // 0 IFNONNULL // 0 intValue -// 0 valueOf +// 1 valueOf diff --git a/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall_1_4.kt b/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall_1_4.kt index 47b84ef593a..ff40c8cea9a 100644 --- a/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall_1_4.kt +++ b/compiler/testData/codegen/bytecodeText/nullCheckOptimization/redundantSafeCall_1_4.kt @@ -1,5 +1,4 @@ -// !API_VERSION: LATEST_STABLE - +// !LANGUAGE: -SafeCallsAreAlwaysNullable fun test(s: String) = s?.length // 0 IFNULL diff --git a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt index 90aa053604b..90846bf25e2 100644 --- a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt +++ b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt @@ -1,4 +1,5 @@ // FIR_IDENTICAL +// !LANGUAGE: -SafeCallsAreAlwaysNullable // http://youtrack.jetbrains.net/issue/KT-418 fun ff() { diff --git a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt new file mode 100644 index 00000000000..175c3f3fb71 --- /dev/null +++ b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt @@ -0,0 +1,7 @@ +// FIR_IDENTICAL +// http://youtrack.jetbrains.net/issue/KT-418 + +fun ff() { + val i: Int = 1 + val a: Int? = i?.plus(2) +} diff --git a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.txt b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.txt new file mode 100644 index 00000000000..99c7d67ddd4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.txt @@ -0,0 +1,3 @@ +package + +public fun ff(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.fir.kt index e1283f32acc..6586a5d0d3e 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.fir.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -SafeCallsAreAlwaysNullable // See KT-10913 Bogus unreachable code warning fun fn() : String? = null diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt index 3c937e6f72e..448f175f9b4 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -SafeCallsAreAlwaysNullable // See KT-10913 Bogus unreachable code warning fun fn() : String? = null diff --git a/compiler/testData/diagnostics/tests/inference/nestedCalls/makeNullableIfSafeCall.fir.kt b/compiler/testData/diagnostics/tests/inference/nestedCalls/makeNullableIfSafeCall.fir.kt index 1926dacd36d..b8ad510b483 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/makeNullableIfSafeCall.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/makeNullableIfSafeCall.fir.kt @@ -11,7 +11,7 @@ interface B { fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) { u?.b?.foo()!! // was UNNECESSARY_SAFE_CALL everywhere, because result type (of 'foo()') wasn't made nullable - u!!.b?.foo()!! + u!!.b?.foo()!! x?.b!!.foo()!! // x?.b is not null x!!.b!!.foo()!! @@ -22,7 +22,7 @@ fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) { // z?.nb is not null z!!.nb!!.foo()!! - w.b?.foo()!! + w.b?.foo()!! w.b!!.foo()!! w.nb?.foo()!! w.nb!!.foo()!! diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/javaStaticMembers.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/javaStaticMembers.kt index f1532277731..cd512b70b79 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/javaStaticMembers.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/javaStaticMembers.kt @@ -8,5 +8,5 @@ fun ff() { val a = Test.FOO val b = Test?.FOO System.out.println(a + b) - System?.out.println(a + b) + System?.out.println(a + b) } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index a962b3343ec..4f557af34d5 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -680,6 +680,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt"); } + @Test + @TestMetadata("SafeCallNonNullReceiver2.kt") + public void testSafeCallNonNullReceiver2() throws Exception { + runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt"); + } + @Test @TestMetadata("SafeCallNonNullReceiverReturnNull.kt") public void testSafeCallNonNullReceiverReturnNull() throws Exception { diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 800faf9a970..1079cd02f79 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -680,6 +680,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver.kt"); } + @Test + @TestMetadata("SafeCallNonNullReceiver2.kt") + public void testSafeCallNonNullReceiver2() throws Exception { + runTest("compiler/testData/diagnostics/tests/SafeCallNonNullReceiver2.kt"); + } + @Test @TestMetadata("SafeCallNonNullReceiverReturnNull.kt") public void testSafeCallNonNullReceiverReturnNull() throws Exception {