diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java index fb3683a4811..a2b3058ba83 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java @@ -22,6 +22,7 @@ import kotlin.CollectionsKt; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.BindingContext; @@ -153,6 +154,7 @@ public class SmartCastManager { @NotNull DataFlowValue dataFlowValue, boolean recordExpressionType ) { + if (KotlinBuiltIns.isNullableNothing(type)) return; if (dataFlowValue.isPredictable()) { trace.record(SMARTCAST, expression, type); if (recordExpressionType) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt index b3a7f0c26c7..7a28dad77a9 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt @@ -3,19 +3,19 @@ fun bar(x: Int) = x + 1 fun f1(x: Int?) { bar(x) if (x != null) bar(x!!) - if (x == null) bar(x!!) + if (x == null) bar(x!!) } fun f2(x: Int?) { - if (x != null) else x!! + if (x != null) else x!! } fun f3(x: Int?) { - if (x != null) bar(x!!) else x!! + if (x != null) bar(x!!) else x!! } fun f4(x: Int?) { - if (x == null) x!! else bar(x!!) + if (x == null) x!! else bar(x!!) } fun f5(x: Int?) { diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt index 2517fbddc36..7c22d72818c 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt @@ -22,7 +22,7 @@ fun main(args : Array) { foo(x) } else { foo(x) - foo(x!!) + foo(x!!) foo(x) } diff --git a/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt b/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt index 205d234acca..4c5a76add3e 100644 --- a/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt +++ b/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt @@ -2,13 +2,13 @@ fun test(t: T): T { if (t != null) { return t!! } - return t!! + return t!! } fun T.testThis(): String { if (this != null) { return this!!.toString() } - return this!!.toString() + return this!!.toString() } diff --git a/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.kt b/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.kt index d3c642bcf90..da6d4ac28eb 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.kt @@ -6,6 +6,6 @@ fun foo(): String { var t: String? = "y" if (t == null) t = "x" var x: Int? = null - if (x == null) x += null + if (x == null) x += null return t + s } \ No newline at end of file