From 469252f6b40d86b29822d37fd27f023f197242de Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 19 Feb 2021 17:47:44 +0300 Subject: [PATCH] [FIR] Don't create smartcast node if smartcasted type is equal to original type --- .../kotlin/fir/resolve/ResolveUtils.kt | 5 +- .../castsInsideCoroutineInference.fir.kt.txt | 3 +- .../castsInsideCoroutineInference.fir.txt | 3 +- .../diagnostics/notLinked/dfa/neg/11.fir.kt | 16 ++-- .../diagnostics/notLinked/dfa/neg/12.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/13.fir.kt | 12 +-- .../diagnostics/notLinked/dfa/neg/15.fir.kt | 16 ++-- .../diagnostics/notLinked/dfa/neg/18.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/21.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/23.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/24.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/26.fir.kt | 44 +++++------ .../diagnostics/notLinked/dfa/neg/3.fir.kt | 30 ++++---- .../diagnostics/notLinked/dfa/neg/33.fir.kt | 2 +- .../diagnostics/notLinked/dfa/neg/34.fir.kt | 40 +++++----- .../diagnostics/notLinked/dfa/neg/35.fir.kt | 36 ++++----- .../diagnostics/notLinked/dfa/neg/37.fir.kt | 32 ++++---- .../diagnostics/notLinked/dfa/neg/38.fir.kt | 12 +-- .../diagnostics/notLinked/dfa/pos/1.fir.kt | 36 ++++----- .../diagnostics/notLinked/dfa/pos/12.fir.kt | 74 +++++++++---------- .../diagnostics/notLinked/dfa/pos/13.fir.kt | 70 +++++++++--------- .../diagnostics/notLinked/dfa/pos/14.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/30.fir.kt | 20 ++--- .../diagnostics/notLinked/dfa/pos/4.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/52.fir.kt | 22 +++--- .../diagnostics/notLinked/dfa/pos/64.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/66.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/69.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/7.fir.kt | 22 +++--- .../diagnostics/notLinked/dfa/pos/71.fir.kt | 2 +- 30 files changed, 272 insertions(+), 271 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 9aeaaf3d4db..74d519269e0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -243,11 +243,12 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol< fun BodyResolveComponents.transformQualifiedAccessUsingSmartcastInfo(qualifiedAccessExpression: FirQualifiedAccessExpression): FirQualifiedAccessExpression { val typesFromSmartCast = dataFlowAnalyzer.getTypeUsingSmartcastInfo(qualifiedAccessExpression) ?: return qualifiedAccessExpression + val originalType = qualifiedAccessExpression.resultType.coneType val allTypes = typesFromSmartCast.also { - it += qualifiedAccessExpression.resultType.coneType + it += originalType } val intersectedType = ConeTypeIntersector.intersectTypes(session.inferenceComponents.ctx, allTypes) - // TODO: add check that intersectedType is not equal to original type + if (intersectedType == originalType) return qualifiedAccessExpression val intersectedTypeRef = buildResolvedTypeRef { source = qualifiedAccessExpression.resultType.source?.fakeElement(FirFakeSourceElementKind.SmartCastedTypeRef) type = intersectedType diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt index 20df7d23208..7d69636b8db 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt @@ -3,7 +3,7 @@ fun scopedFlow(@BuilderInference block: @ExtensionFunctionType Suspen return flow(block = local suspend fun FlowCollector.() { val collector: FlowCollector = flowScope(block = local suspend fun CoroutineScope.() { - block.invoke(p1 = , p2 = collector /*as FlowCollector */) + block.invoke(p1 = , p2 = collector) } ) } @@ -141,3 +141,4 @@ interface SendChannel { abstract suspend fun send(e: E) } + diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index 3000008ef91..51368d44897 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -25,8 +25,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=null $this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION p1: GET_VAR ': .CoroutineScope declared in .scopedFlow..' type=.CoroutineScope origin=null - p2: TYPE_OP type=.FlowCollector origin=IMPLICIT_CAST typeOperand=.FlowCollector - GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + p2: GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt index 7a9e67c7ab5..835c827a936 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt @@ -25,8 +25,8 @@ fun case_3() { var x: Boolean? = true if (x is Boolean) { funWithAnyArg(try { x = null; true } catch (e: Exception) { false }) - x - x.not() + x + x.not() } } @@ -35,8 +35,8 @@ fun case_4() { var x: Boolean? = true if (x != null) { false || when { else -> {x = null; true} } - x - x.not() + x + x.not() } } @@ -57,8 +57,8 @@ fun case_6() { var x: Boolean? = true x as Boolean if (if (true) { x = null; true } else { false }) { - x - x.not() + x + x.not() } } @@ -68,6 +68,6 @@ fun case_7() { x!! if (if (true) { x = null; true } else { false }) {} - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt index ac6cd9a935d..6855de1205a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt @@ -6,7 +6,7 @@ fun case_1() { var x: Int? = 11 x!! - try {x = null;} finally { x += 10; } + try {x = null;} finally { x += 10; } } // TESTCASE NUMBER: 2 @@ -18,7 +18,7 @@ fun case_2() { } catch (e: Exception) { x = null } - x.not() + x.not() } } @@ -31,7 +31,7 @@ fun case_3() { } catch (e: Exception) { x = null } - x.not() + x.not() } } @@ -42,5 +42,5 @@ fun case_4() { try { x = null } finally { } - x.not() + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt index 16525fa04cf..7e2d5a9980f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt @@ -14,16 +14,16 @@ fun case_1(x: Class?) { fun case_2() { var x: Class? = 10 x!! - x(if (true) {x=null;0} else 0, x) - x - x.fun_1() + x(if (true) {x=null;0} else 0, x) + x + x.fun_1() } // TESTCASE NUMBER: 3 fun case_3() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] - x - x.fun_1() + val y = x[if (true) {x=null;0} else 0, x[0]] + x + x.fun_1() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt index c64857f04cc..6e15f53f9f1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt @@ -37,8 +37,8 @@ fun case_3() { var x: Boolean? = true if (x != null) { false || when { else -> { x = null; true} } - x - x.not() + x + x.not() } } @@ -64,7 +64,7 @@ fun case_4() { fun case_5() { var x: Boolean? = true if (x != null) { - when { else -> { x = null; false} } || x.not() + when { else -> { x = null; false} } || x.not() } } @@ -88,7 +88,7 @@ fun case_6() { fun case_7() { var x: Boolean? = true if (x != null) { - (if (true) {x = null; null} else true) ?: x.not() + (if (true) {x = null; null} else true) ?: x.not() } } @@ -96,7 +96,7 @@ fun case_7() { fun case_8(y: MutableList) { var x: Boolean? = true if (x != null) { - y[if (true) {x = null;0} else 0] = x + y[if (true) {x = null;0} else 0] = x } } @@ -109,8 +109,8 @@ fun case_9() { var x: Boolean? = true if (x is Boolean) { funWithAnyArg(try { x = null; true } catch (e: Exception) { false }) - x - x.not() + x + x.not() } } @@ -122,7 +122,7 @@ fun case_9() { fun case_10() { var x: Boolean? = true if (x is Boolean) { - select(if (true) {x = null;Class()} else Class()).prop_9 = x.not() + select(if (true) {x = null;Class()} else Class()).prop_9 = x.not() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt index 3131236c2e5..c3de82369bd 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt @@ -50,7 +50,7 @@ fun case_4(x: Interface1?) { y as Interface2 y = null fun foo() { - y.itest2() + y.itest2() } y = x foo() @@ -62,7 +62,7 @@ fun case_5(x: Interface1?) { y as Interface2 y = null fun foo() { - y.itest2() + y.itest2() } y = x foo() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt index 05f3312dcc5..ffd0875039f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt @@ -13,7 +13,7 @@ class Case1 { val y = this if (y.x != null) { x = null - x + x this.x y.x y.x.inv() @@ -34,7 +34,7 @@ class Case2 { val y = this if (y.x == null) { x = 11 - x + x this.x y.x y.x.inv() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt index 824509b6e92..2f8844df640 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt @@ -61,8 +61,8 @@ inline fun case_6() { var x: T? = 10 as T if (x is K) { x = null - x.equals(10) - x + x.equals(10) + x println(1) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt index 9a5d4c663f4..8c8cb291b57 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt @@ -15,8 +15,8 @@ fun case_1() { } catch (e: Exception) { x = null } - x - x.not() + x + x.not() } } @@ -31,8 +31,8 @@ fun case_2() { try { x = null } finally { } - x - x.not() + x + x.not() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt index 54118ea35c6..fbc59bb9911 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt @@ -10,18 +10,18 @@ fun case_1() { var x: MutableList? = mutableListOf(1) x!! - ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] += ? & kotlin.collections.MutableList?")!>x[0] - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] += ?")!>x[0] + ?")!>x + ?")!>x[0].inv() } // TESTCASE NUMBER: 2 fun case_2() { var x: MutableList? = mutableListOf(1) x!! - ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] = ? & kotlin.collections.MutableList?")!>x[0] - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] = ?")!>x[0] + ?")!>x + ?")!>x[0].inv() } // TESTCASE NUMBER: 3 @@ -29,8 +29,8 @@ fun case_3() { var x: MutableList? = mutableListOf(1) x!! ? & kotlin.collections.MutableList")!>x[0] = if (true) {x=null;0} else 0 - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ?")!>x + ?")!>x[0].inv() } /* @@ -41,9 +41,9 @@ fun case_3() { fun case_4() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] - x - x[0].inv() + val y = x[if (true) {x=null;0} else 0, x[0]] + x + x[0].inv() } /* @@ -54,17 +54,17 @@ fun case_4() { fun case_5() { var x: Class? = Class() x!! - x(if (true) {x=null;0} else 0, x) - x.fun_1() + x(if (true) {x=null;0} else 0, x) + x.fun_1() } // TESTCASE NUMBER: 6 fun case_6() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0][>? & kotlin.collections.MutableList>?")!>x[0][0]] += 10 - >? & kotlin.collections.MutableList>?")!>x - >? & kotlin.collections.MutableList>?")!>x[0][0].inv() + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0][>?")!>x[0][0]] += 10 + >?")!>x + >?")!>x[0][0].inv() } /* @@ -75,22 +75,22 @@ fun case_6() { fun case_7() { var x: Class? = Class() x!! - x(if (true) {x=null;0} else 0)(x) - x.fun_1() + x(if (true) {x=null;0} else 0)(x) + x.fun_1() } // TESTCASE NUMBER: 8 fun case_8() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].addAll(1, >? & kotlin.collections.MutableList>?")!>x[0]) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].addAll(1, >?")!>x[0]) } // TESTCASE NUMBER: 9 fun case_9() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>?")!>x[0][0]] } /* @@ -101,7 +101,7 @@ fun case_9() { fun case_10() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x.subList(if (true) {x=null;0} else 0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x.subList(if (true) {x=null;0} else 0, 2)[>?")!>x[0][0]] } /* @@ -112,5 +112,5 @@ fun case_10() { fun case_11() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(>? & kotlin.collections.MutableList>?")!>x[0][0], 2) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(>?")!>x[0][0], 2) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt index 3a0a0ca8a49..ea8cef6a0d9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt @@ -13,8 +13,8 @@ fun case_1(x: Nothing?) { // TESTCASE NUMBER: 2 fun case_2(x: Nothing) { if (x is Unit) { - x - x.inv() + x + x.inv() } } @@ -29,16 +29,16 @@ fun case_3(x: Nothing?) { // TESTCASE NUMBER: 4 fun case_4(x: Nothing) { if (x !is EnumClass) else { - x - x.fun_1() + x + x.fun_1() } } // TESTCASE NUMBER: 5 fun case_5(x: Nothing?) { if (!(x !is Class.NestedClass?)) { - x - x?.prop_4 + x + x?.prop_4 } } @@ -53,24 +53,24 @@ fun case_6(x: Nothing?) { // TESTCASE NUMBER: 7 fun case_7(x: Nothing) { if (!(x is DeepObject.A.B.C.D.E.F.G.J)) else { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 8 fun case_8(x: Nothing?) { if (!(x is Int?)) else { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 9 fun case_9(x: Nothing?) { if (!!(x !is TypealiasNullableStringIndirect?)) else { - x - x?.length + x + x?.length } } @@ -86,8 +86,8 @@ fun case_10(x: Nothing?) { // TESTCASE NUMBER: 11 fun case_11(x: Nothing?) { if (x is SealedMixedChildObject1?) { - x - x?.prop_1 - x?.prop_2 + x + x?.prop_1 + x?.prop_2 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt index 714f64ad3c0..09f7ad29aa3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt @@ -57,6 +57,6 @@ fun case_4(x: Int?) { fun case_5(x: Int?) { if (x == null) { var y = x - nullableStringArg(y) + nullableStringArg(y) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt index 82010624f7a..92bca11edee 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt @@ -13,8 +13,8 @@ fun case_1() { x = null break } - x - x.length + x + x.length } /* @@ -28,8 +28,8 @@ fun case_3() { x = null break } - x - x.length + x + x.length } /* @@ -43,8 +43,8 @@ fun case_4() { x = null break } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 5 @@ -56,8 +56,8 @@ fun case_5() { x = null break } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 6 @@ -141,8 +141,8 @@ fun case_12() { x = null break } while (true && x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 13 @@ -154,8 +154,8 @@ fun case_13() { x = null break } while (false && x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 14 @@ -167,8 +167,8 @@ fun case_14() { x = null break } while (true || x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 15 @@ -180,8 +180,8 @@ fun case_15() { x = null break } while (!(false && x!!)) - x - x.not() + x + x.not() } /* @@ -194,8 +194,8 @@ fun case_16() { while (x!! && if (true) {x = null; true} else true) { break } - x - x.not() + x + x.not() } /* @@ -208,6 +208,6 @@ fun case_17() { while (x!! && if (true) {x = null; true} else true) { break } - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt index 74c65c8446c..4edde03cecb 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt @@ -11,8 +11,8 @@ fun case_1() { var x: String? x = "Test" println("${if (true) x = null else 1}") - x - x.length + x + x.length } /* @@ -24,8 +24,8 @@ fun case_2() { var x: String? x = "Test" println("${try { x = null } finally { }}") - x - x.length + x + x.length } /* @@ -37,8 +37,8 @@ fun case_3() { var x: String? x = "Test" println("${try { } finally { x = null }}") - x - x.length + x + x.length } /* @@ -50,8 +50,8 @@ fun case_4() { var x: String? x = "Test" println("${try { x = null } catch (e: Exception) { } finally { }}") - x - x.length + x + x.length } /* @@ -63,8 +63,8 @@ fun case_5() { var x: String? x = "Test" println("${try { } catch (e: Exception) { x = null } finally { }}") - x - x.length + x + x.length } /* @@ -76,8 +76,8 @@ fun case_6() { var x: String? x = "Test" println("${try { } catch (e: Exception) { } finally { x = null }}") - x - x.length + x + x.length } /* @@ -89,8 +89,8 @@ fun case_7() { var x: String? x = "Test" println("${try { x = null } catch (e: Exception) { }}") - x - x.length + x + x.length } /* @@ -102,8 +102,8 @@ fun case_8() { var x: String? x = "Test" println("${try { } catch (e: Exception) { x = null }}") - x - x.length + x + x.length } /* @@ -115,6 +115,6 @@ fun case_9() { var x: String? x = "Test" println("${when (null) { else -> x = null } }") - x - x.length + x + x.length } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt index c8976901980..5f1948ef40d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt @@ -12,8 +12,8 @@ fun case_1() { if (x != null) { x x++ - x - x.equals(10) + x + x.equals(10) } } @@ -27,8 +27,8 @@ fun case_2() { x = Class() x x-- - x - x.equals(10) + x + x.equals(10) } /* @@ -41,8 +41,8 @@ fun case_3() { x!! x --x - x - x.equals(10) + x + x.equals(10) } /* @@ -55,8 +55,8 @@ fun case_4() { x as Class x ++x - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 5 @@ -65,8 +65,8 @@ fun case_5() { x as Class x x = x + x - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 6 @@ -75,8 +75,8 @@ fun case_6() { if (x is Class) { x x = x - x - x - x.equals(10) + x + x.equals(10) } } @@ -90,8 +90,8 @@ fun case_7() { x = Class() x x += x - x - x.equals(10) + x + x.equals(10) } /* @@ -104,6 +104,6 @@ fun case_8() { x!! x x -= x - x - x.equals(10) + x + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt index c427c09fcf6..310fcb05941 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt @@ -145,8 +145,8 @@ fun case_9() { inner@ do { x = null } while (x != null) - x - x.length + x + x.length } } @@ -158,8 +158,8 @@ fun case_10() { inner@ do { x = null } while (true) - x - x.length + x + x.length } } @@ -172,7 +172,7 @@ fun case_11() { x = null break } while (x == null) - x - x.length + x + x.length } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt index 7acc5f215f0..31b1bb2a01f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt @@ -304,16 +304,16 @@ fun case_14() { // TESTCASE NUMBER: 15 fun case_15(x: EmptyObject) { val t = if (x === null) "" else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -1302,8 +1302,8 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -2346,8 +2346,8 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -3391,8 +3391,8 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -4039,8 +4039,8 @@ object Case32 { if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt index 5f1af413a73..cb71cdfb613 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt @@ -320,17 +320,17 @@ fun T.case_8() { // TESTCASE NUMBER: 9 fun T.case_9() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() equals(null) @@ -567,18 +567,18 @@ fun T.case_12() where T : Number?, T: Interface1? { */ fun T.case_13() where T : Out<*>?, T: Comparable { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.compareTo(null) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.compareTo(null) equals(null) @@ -3494,18 +3494,18 @@ fun T.case_56() where T : Number?, T: Interface1? { */ fun T.case_57() where T : Out<*>?, T: Comparable { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.compareTo(null) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.compareTo(null) equals(null) @@ -3818,8 +3818,8 @@ fun Nothing?.case_62() { // TESTCASE NUMBER: 63 fun Nothing.case_63() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt index 23c7c7c13e9..a9b32599c67 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt @@ -388,17 +388,17 @@ fun case_8(x: T) { // TESTCASE NUMBER: 9 fun case_9(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.toByte() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.toByte() x.equals(null) @@ -683,18 +683,18 @@ fun case_12(x: T) where T : Number?, T: Interface1? { */ fun case_13(x: T) where T : Out<*>?, T: Comparable { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.get() - x.compareTo(null) + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.get() + x.compareTo(null) x.equals(null) @@ -3987,18 +3987,18 @@ fun case_56(x: T) where T : Number?, T: Interface1? { */ fun case_57(x: T) where T : Out<*>?, T: Comparable { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.get() - x.compareTo(null) + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.get() + x.compareTo(null) x.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt index 30b8dec3d50..dfaf1aefbae 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt @@ -5,7 +5,7 @@ // TESTCASE NUMBER: 1 fun case_1(vararg x: Int?) { if (x != null) { - & kotlin.Array")!>x + ")!>x x[0] } } @@ -30,7 +30,7 @@ fun case_2(vararg x: Int?) { // TESTCASE NUMBER: 3 fun case_3(vararg x: T?) { if (x != null) { - & kotlin.Array")!>x + ")!>x x[0] } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt index fab49cb5607..c909df2713c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt @@ -99,11 +99,11 @@ fun case_6(x: Class?) { */ fun case_7(x: Class) { if (x!!.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -114,11 +114,11 @@ fun case_7(x: Class) { */ fun case_8(x: Class) { if (x!!.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 9 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt index 4465240a87b..9d02e24f57a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt @@ -63,7 +63,7 @@ fun case_6(x: EmptyClass) { // TESTCASE NUMBER: 7 fun case_7() { - if (anonymousTypeProperty == null || anonymousTypeProperty == null) { + if (anonymousTypeProperty == null || anonymousTypeProperty == null) { anonymousTypeProperty } } @@ -258,7 +258,7 @@ fun case_23(a: ((Float) -> Int), b: Float) { if (a == null && b == null) { val x = a(b) if (x !== null) { - x + x } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt index 9415700500e..08af6541739 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt @@ -12,7 +12,7 @@ fun case_1(x: Int?) = x fun case_1() { var x: Int? = 10 x = null - case_1(x) + case_1(x) } // TESTCASE NUMBER: 2 @@ -21,7 +21,7 @@ fun case_2(x: Nothing?) = x fun case_2() { var x: Int? = 10 x = null - case_2(x) + case_2(x) } // TESTCASE NUMBER: 3 @@ -29,7 +29,7 @@ fun case_3(x: String?) = x fun case_3() { var x: Int? = 10 x = null - case_3(x) + case_3(x) } /* @@ -42,7 +42,7 @@ fun Int?.case_4() = this fun case_4() { var x: Int? = 10 x = null - x.case_4() + x.case_4() } // TESTCASE NUMBER: 5 @@ -51,7 +51,7 @@ fun Nothing?.case_5() = this fun case_5() { var x: Int? = 10 x = null - x.case_5() + x.case_5() } // TESTCASE NUMBER: 6 @@ -59,7 +59,7 @@ fun String?.case_6() = this fun case_6() { var x: Int? = 10 x = null - x.case_6() + x.case_6() } /* @@ -72,7 +72,7 @@ fun T.case_7() = this fun case_7() { var x: Int? = 10 x = null - x.case_7() + x.case_7() } // TESTCASE NUMBER: 8 @@ -81,7 +81,7 @@ fun T.case_8() = this fun case_8() { var x: Int? = 10 x = null - x.case_8() + x.case_8() } // TESTCASE NUMBER: 9 @@ -89,7 +89,7 @@ fun T.case_9() = this fun case_9() { var x: Int? = 10 x = null - x.case_9() + x.case_9() } /* @@ -102,7 +102,7 @@ fun T?.case_10() = this fun case_10() { var x: Int? = 10 x = null - x.case_10() + x.case_10() } // TESTCASE NUMBER: 11 @@ -110,5 +110,5 @@ fun T?.case_11() = this fun case_11() { var x: Int? = 10 x = null - x.case_11() + x.case_11() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt index d2e5de161c9..f24a90f7e97 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt @@ -16,7 +16,7 @@ class Case1 { if (x == null) { x = getT() } - x + x return x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt index 09ba8fc695b..2fcf9954b1a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt @@ -79,8 +79,8 @@ fun case_6(x: Any?) { when (x) { is Nothing? -> return is Any? -> { - x - x.equals(10) + x + x.equals(10) } } x diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt index 24ad68a1d8d..f0885dadbdd 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt @@ -36,7 +36,7 @@ fun case_4(x: Any?) { // TESTCASE NUMBER: 5 fun case_5(x: Class) { if (x!!.prop_8 != null) { - x - x.prop_8.prop_8 + x + x.prop_8.prop_8 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt index 76b0c3c5964..63fe7a9a7b9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt @@ -131,17 +131,17 @@ fun case_7() { // TESTCASE NUMBER: 8 fun case_8(x: TypealiasString) { - if (x !== null && x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + if (x !== null && x != null) { + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt index f10b4dc77aa..158f8704143 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt @@ -42,6 +42,6 @@ fun case_2(): Int { var c: Int = 0 c = 0 - c + c return c }