From 5445f4043a1a6cf053dbd596942419751707036e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 18 Jul 2022 15:17:37 +0200 Subject: [PATCH] K2: expand types during smartcasting to prevent redundant intersections #KT-53184 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../runners/ir/Fir2IrTextTestGenerated.java | 6 ++ .../ir/LightTreeFir2IrTextTestGenerated.java | 6 ++ .../kotlin/fir/resolve/ResolveUtils.kt | 4 +- .../codegen/box/fir/getOnNullableTypeAlias.kt | 18 ++++ .../reflectGetOnNullableTypeAlias.fir.ir.txt | 50 +++++++++++ .../reflectGetOnNullableTypeAlias.fir.kt.txt | 21 +++++ .../reflectGetOnNullableTypeAlias.ir.txt | 51 +++++++++++ .../reflectGetOnNullableTypeAlias.kt | 18 ++++ .../reflectGetOnNullableTypeAlias.kt.txt | 23 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../test/runners/ir/IrTextTestGenerated.java | 6 ++ .../klib/KlibTextTestCaseGenerated.java | 5 ++ .../diagnostics/notLinked/dfa/pos/1.fir.kt | 82 +++++++++--------- .../diagnostics/notLinked/dfa/pos/6.fir.kt | 86 +++++++++---------- .../diagnostics/notLinked/dfa/pos/7.fir.kt | 84 +++++++++--------- 16 files changed, 344 insertions(+), 128 deletions(-) create mode 100644 compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt create mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt create mode 100644 compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index ba666e257cb..f7bcbb89ab9 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -17829,6 +17829,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt"); } + @Test + @TestMetadata("getOnNullableTypeAlias.kt") + public void testGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt"); + } + @Test @TestMetadata("implicitNothingInDelegate.kt") public void testImplicitNothingInDelegate() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 4cbf72f3e0b..60de8481032 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2632,6 +2632,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @Test + @TestMetadata("reflectGetOnNullableTypeAlias.kt") + public void testReflectGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt"); + } + @Test @TestMetadata("SafeLetWithReturn.kt") public void testSafeLetWithReturn() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java index 24c4810ae97..41bcf2f0490 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java @@ -2632,6 +2632,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @Test + @TestMetadata("reflectGetOnNullableTypeAlias.kt") + public void testReflectGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt"); + } + @Test @TestMetadata("SafeLetWithReturn.kt") public void testSafeLetWithReturn() throws Exception { 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 b7614d9468e..916795e6542 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 @@ -361,10 +361,10 @@ private inline fun BodyResolveComponents.transformExpression SmartcastStability.STABLE_VALUE } - val originalType = expression.resultType.coneType + val originalType = expression.resultType.coneType.fullyExpandedType(session) val allTypes = typesFromSmartCast.also { if (originalType !is ConeStubType) { - it += originalType + it += originalType.fullyExpandedType(session) } } if (allTypes.all { it is ConeDynamicType }) return null diff --git a/compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt b/compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt new file mode 100644 index 00000000000..996bd05695f --- /dev/null +++ b/compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM_IR +// WITH_REFLECT + +import kotlin.reflect.KProperty1 + +private typealias PropAlias = KProperty1? + +fun box(): String { + val backRefProp: PropAlias = Foo::bar + if (backRefProp != null) { + return backRefProp.get(Foo()) as String + } + return "FAIL" +} + +class Foo { + val bar: String = "OK" +} diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt new file mode 100644 index 00000000000..3a206fc2a83 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.ir.txt @@ -0,0 +1,50 @@ +FILE fqName: fileName:/reflectGetOnNullableTypeAlias.kt + TYPEALIAS name:PropAlias visibility:private expandedType:kotlin.reflect.KProperty1.PropAlias, kotlin.Any?>? + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:backRefProp type:kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? [val] + PROPERTY_REFERENCE 'public final bar: kotlin.String [val]' field=null getter='public final fun (): kotlin.String declared in .Foo' setter=null type=kotlin.reflect.KProperty1<.Foo, kotlin.String> origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? [val] declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String + CALL 'public abstract fun get (receiver: T of kotlin.reflect.KProperty1): V of kotlin.reflect.KProperty1 declared in kotlin.reflect.KProperty1' type=kotlin.Any? origin=null + $this: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? [val] declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>? origin=null + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Foo' type=.Foo origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo + CONSTRUCTOR visibility:public <> () returnType:.Foo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:bar visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="OK" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Foo) returnType:kotlin.String + correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Foo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .Foo declared in .Foo.' type=.Foo origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt new file mode 100644 index 00000000000..43fead4121b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.fir.kt.txt @@ -0,0 +1,21 @@ +private typealias PropAlias = KProperty1? +fun box(): String { + val backRefProp: KProperty1? = Foo::bar + when { + EQEQ(arg0 = backRefProp, arg1 = null).not() -> return backRefProp.get(receiver = Foo()) as String + } + return "FAIL" +} + +class Foo { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val bar: String + field = "OK" + get + +} diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.ir.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.ir.txt new file mode 100644 index 00000000000..e2c67e310e4 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.ir.txt @@ -0,0 +1,51 @@ +FILE fqName: fileName:/reflectGetOnNullableTypeAlias.kt + TYPEALIAS name:PropAlias visibility:private expandedType:kotlin.reflect.KProperty1.PropAlias, kotlin.Any?>? + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:backRefProp type:kotlin.reflect.KProperty1<.Foo, kotlin.Any?>?{ .PropAlias<.Foo> } [val] + PROPERTY_REFERENCE 'public final bar: kotlin.String [val]' field=null getter='public final fun (): kotlin.String declared in .Foo' setter=null type=kotlin.reflect.KProperty1<.Foo, kotlin.String> origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>?{ .PropAlias<.Foo> } [val] declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>?{ .PropAlias<.Foo> } origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String + CALL 'public abstract fun get (receiver: T of kotlin.reflect.KProperty1): V of kotlin.reflect.KProperty1 declared in kotlin.reflect.KProperty1' type=kotlin.Any? origin=null + $this: GET_VAR 'val backRefProp: kotlin.reflect.KProperty1<.Foo, kotlin.Any?>?{ .PropAlias<.Foo> } [val] declared in .box' type=kotlin.reflect.KProperty1<.Foo, kotlin.Any?>?{ .PropAlias<.Foo> } origin=null + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Foo' type=.Foo origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="FAIL" + CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo + CONSTRUCTOR visibility:public <> () returnType:.Foo [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:bar visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="OK" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Foo) returnType:kotlin.String + correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Foo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .Foo declared in .Foo.' type=.Foo origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt new file mode 100644 index 00000000000..99492b7cc2f --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt @@ -0,0 +1,18 @@ +// SKIP_KLIB_TEST +// WITH_REFLECT + +import kotlin.reflect.KProperty1 + +private typealias PropAlias = KProperty1? + +fun box(): String { + val backRefProp: PropAlias = Foo::bar + if (backRefProp != null) { + return backRefProp.get(Foo()) as String + } + return "FAIL" +} + +class Foo { + val bar: String = "OK" +} diff --git a/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt.txt b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt.txt new file mode 100644 index 00000000000..46c4468832b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt.txt @@ -0,0 +1,23 @@ +private typealias PropAlias = KProperty1? +fun box(): String { + val backRefProp: KProperty1? = Foo::bar + when { + EQEQ(arg0 = backRefProp, arg1 = null).not() -> { // BLOCK + return backRefProp.get(receiver = Foo()) as String + } + } + return "FAIL" +} + +class Foo { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val bar: String + field = "OK" + get + +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 873a03552da..110a19d6e74 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -17829,6 +17829,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/fir/flexibleIntegerLiterals.kt"); } + @Test + @TestMetadata("getOnNullableTypeAlias.kt") + public void testGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/getOnNullableTypeAlias.kt"); + } + @Test @TestMetadata("implicitNothingInDelegate.kt") public void testImplicitNothingInDelegate() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index 045500b87eb..31f0e16b79b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2632,6 +2632,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @Test + @TestMetadata("reflectGetOnNullableTypeAlias.kt") + public void testReflectGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt"); + } + @Test @TestMetadata("SafeLetWithReturn.kt") public void testSafeLetWithReturn() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java index bd0635f5c82..872ea9b6f4e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibTextTestCaseGenerated.java @@ -1932,6 +1932,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase { runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @TestMetadata("reflectGetOnNullableTypeAlias.kt") + public void testReflectGetOnNullableTypeAlias() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/reflectGetOnNullableTypeAlias.kt"); + } + @TestMetadata("SafeLetWithReturn.kt") public void testSafeLetWithReturn() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SafeLetWithReturn.kt"); 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 b8194f58efd..f16f3f08f44 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 @@ -138,16 +138,16 @@ fun case_7() { // TESTCASE NUMBER: 8 fun case_8(x: TypealiasNullableString) { - if (x !== null && x != null) x - if (x !== null && x != null) x.equals(null) - if (x !== null && x != null) x.propT - if (x !== null && x != null) x.propAny - if (x !== null && x != null) x.propNullableT - if (x !== null && x != null) x.propNullableAny - if (x !== null && x != null) x.funT() - if (x !== null && x != null) x.funAny() - if (x !== null && x != null) x.funNullableT() - if (x !== null && x != null) x.funNullableAny() + if (x !== null && x != null) x + if (x !== null && x != null) x.equals(null) + if (x !== null && x != null) x.propT + if (x !== null && x != null) x.propAny + if (x !== null && x != null) x.propNullableT + if (x !== null && x != null) x.propNullableAny + if (x !== null && x != null) x.funT() + if (x !== null && x != null) x.funAny() + if (x !== null && x != null) x.funNullableT() + if (x !== null && x != null) x.funNullableAny() } // TESTCASE NUMBER: 9 @@ -155,16 +155,16 @@ fun case_9(x: TypealiasNullableString?) { if (x === null) { } else if (false) { - 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() } } @@ -198,16 +198,16 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir if (y != null) { if (nullableStringProperty == null) { if (t != null) { - 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() } } } @@ -217,16 +217,16 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndirect) = if (x == null) "1" -else if (y === null) x -else if (y === null) x.equals(null) -else if (y === null) x.propT -else if (y === null) x.propAny -else if (y === null) x.propNullableT -else if (y === null) x.propNullableAny -else if (y === null) x.funT() -else if (y === null) x.funAny() -else if (y === null) x.funNullableT() -else if (y === null) x.funNullableAny() +else if (y === null) x +else if (y === null) x.equals(null) +else if (y === null) x.propT +else if (y === null) x.propAny +else if (y === null) x.propNullableT +else if (y === null) x.propNullableAny +else if (y === null) x.funT() +else if (y === null) x.funAny() +else if (y === null) x.funNullableT() +else if (y === null) x.funNullableAny() else "-1" // TESTCASE NUMBER: 13 @@ -322,7 +322,7 @@ fun case_16() { val x: TypealiasNullableNothing = null if (x != null) { - x + x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt index a5cb28bc8c2..f37dde6069f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt @@ -137,17 +137,17 @@ fun case_7(x: EmptyObject?) { fun case_8(x: TypealiasNullableString) { val y = null - if (x !== y && x != y) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + if (x !== y && x != y) { + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -156,16 +156,16 @@ fun case_9(x: TypealiasNullableString?, y: Nothing?) { if (x === y) { } else if (false) { - 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() } } @@ -221,16 +221,16 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNu // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableString, y: TypealiasNullableString, z1: Nothing?, z2: Nothing?) = if (x == z1 || x == z2) "1" else if (y === z1 && y == z2) { - 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() } else "-1" // TESTCASE NUMBER: 13 @@ -281,16 +281,16 @@ fun case_14() { fun case_15(x: TypealiasNullableString) { val y = null val z = if (x === null || y == x && x === y || null === x) "" 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() } } @@ -300,8 +300,8 @@ fun case_16() { val y: Nothing? = null if (x !== y) { - x - x.hashCode() + x + x.hashCode() } } 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 dc0535860f3..1c46970b55b 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 @@ -151,16 +151,16 @@ fun case_9(x: TypealiasNullableString?) { } else if (x === null || x === null) { } else if (false) { - 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() } } @@ -195,16 +195,16 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNu if (y != null || y != null) { if (stringProperty == null && nullableNothingProperty == null) { if (t != null || t != null) { - 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() } } } @@ -215,16 +215,16 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNu // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = if (x == null) "1" else if (y === null || y === null) { - 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() + x } else "-1" // TESTCASE NUMBER: 13 @@ -265,16 +265,16 @@ fun case_14() { fun case_15(x: TypealiasString?) { var y = null val t = if (x === null || x == y && x === y) "" else { - 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() + x } } @@ -284,8 +284,8 @@ fun case_16() { val y: Nothing? = null if (x != null || x !== null || x != y) { - x - x.hashCode() + x + x.hashCode() } }