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 5c14b8ef5c8..60503ce7e00 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 @@ -37446,6 +37446,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index cd46b7f931a..68734347c7d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -989,7 +989,8 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor if (variable.returnTypeRef is FirImplicitTypeRef) { when { initializer != null -> { - val expectedType = when (val resultType = initializer.resultType) { + val unwrappedInitializer = (initializer as? FirExpressionWithSmartcast)?.originalExpression ?: initializer + val expectedType = when (val resultType = unwrappedInitializer.resultType) { is FirImplicitTypeRef -> buildErrorTypeRef { diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) } diff --git a/compiler/testData/codegen/box/smartCasts/kt44932.kt b/compiler/testData/codegen/box/smartCasts/kt44932.kt new file mode 100644 index 00000000000..dad06a82a77 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44932.kt @@ -0,0 +1,40 @@ +// ISSUE: KT-44932 +// WITH_STDLIB + +abstract class PsiElement { + abstract val parent: PsiElement +} + +class KtNameReferenceExpression(override val parent: PsiElement) : PsiElement() + +class OtherElement(override val parent: PsiElement) : PsiElement() + +class KtDotQualifiedExpression : PsiElement() { + override val parent: PsiElement + get() = this + + val psi: PsiElement = EndElement() +} + +class EndElement : PsiElement() { + override val parent: PsiElement + get() = this +} + +fun mark(element: PsiElement): String { + when (element) { + is KtNameReferenceExpression -> { + var parent = element + repeat(2) { + parent = parent.parent + (parent as? KtDotQualifiedExpression)?.psi?.let { return mark(it) } + } + } + } + return if (element is EndElement) "OK" else "Fail" +} + +fun box(): String { + val element = KtNameReferenceExpression(OtherElement(KtDotQualifiedExpression())) + return mark(element) +} diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt index cda338ab4fd..34f2a1b0736 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt @@ -22,7 +22,7 @@ fun test2() { } ( = 0) - val : Int = () + val : Int? = () ( = .inc()) /*~> Unit */ ( = ().plus(other = 1)) diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt index 4bead69ab4c..7a1a2afb8d1 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt @@ -47,13 +47,13 @@ FILE fqName: fileName:/localDelegatedProperties.kt value: GET_VAR ': kotlin.Int? declared in .test2.' type=kotlin.Int? origin=null CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CONST Int type=kotlin.Int value=0 - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] CALL 'local final fun (): kotlin.Int? declared in .test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in .test2' type=kotlin.Int? origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + GET_VAR 'val tmp_0: kotlin.Int? [val] declared in .test2' type=kotlin.Int? origin=null CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'local final fun (): kotlin.Int? declared in .test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index 16b3427c296..c5798a0e780 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -63,8 +63,8 @@ fun test4(fn: Function1) { when { fn is IFoo -> { // BLOCK val <>: A = A - val <>: IFoo = fn /*as IFoo */ - <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + val <>: Function1 = fn /*as IFoo */ + <>.set(i = <> /*as IFoo */, newValue = <>.get(i = <> /*as IFoo */).plus(other = 1)) } } } @@ -73,8 +73,8 @@ fun test5(a: Any) { a as Function1 /*~> Unit */ { // BLOCK val <>: A = A - val <>: Function1 = a /*as Function1 */ - <>.set(i = <> /*-> IFoo */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + val <>: Any = a /*as Function1 */ + <>.set(i = <> /*as Function1 */ /*-> IFoo */, newValue = <>.get(i = <> /*as Function1 */ /*-> IFoo */).plus(other = 1)) } } @@ -83,8 +83,8 @@ fun test6(a: Any) { a /*as Function1 */ as IFoo /*~> Unit */ { // BLOCK val <>: A = A - val <>: Function1 = a /*as Function1 */ - <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + val <>: Any = a /*as Function1 */ + <>.set(i = <> /*as Function1 */, newValue = <>.get(i = <> /*as Function1 */).plus(other = 1)) } } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt index d1943517037..bb7afd74455 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt @@ -136,16 +136,18 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt then: BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.IFoo [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Function1 [val] TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + i: TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test4' type=kotlin.Function1 origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + i: TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test4' type=kotlin.Function1 origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any @@ -156,18 +158,20 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Function1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Any [val] TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_5: kotlin.Any [val] declared in .test5' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_5: kotlin.Any [val] declared in .test5' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any @@ -182,14 +186,16 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Function1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Any [val] TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_7: kotlin.Any [val] declared in .test6' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_7: kotlin.Any [val] declared in .test6' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt index 1cdd20ca6d0..b583cac2401 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt @@ -14,9 +14,9 @@ fun test(x: Any) { x is IC1 -> x /*as IC1 */ is IC2 else -> false } -> { // BLOCK - val : IC1 = x /*as IC1 */ - val x1: Int = .component1() - val x2: String = /*as IC2 */.component2() + val : Any = x /*as IC1 */ + val x1: Int = /*as IC1 */.component1() + val x2: String = /*as IC1 */ /*as IC2 */.component2() } } } diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt index 3f44bf5ad7f..1d8244a2161 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt @@ -49,13 +49,15 @@ FILE fqName: fileName:/multipleSmartCasts.kt if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false then: BLOCK type=kotlin.Unit origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.IC1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val] TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null VAR name:x1 type:kotlin.Int [val] CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in .IC1' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null + $this: TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null VAR name:x2 type:kotlin.String [val] CALL 'public abstract fun component2 (): kotlin.String [operator] declared in .IC2' type=kotlin.String origin=null $this: TYPE_OP type=.IC2 origin=IMPLICIT_CAST typeOperand=.IC2 - GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null + TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt index 077e7fa05d0..1255fb8d0c4 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt @@ -18,7 +18,7 @@ fun test(x: I1) { when { x !is I2 -> return Unit } - val : I2 = x /*as I2 */ - val c1: Int = .component1() - val c2: String = .component2() + val : I1 = x /*as I2 */ + val c1: Int = /*as I2 */.component1() + val c2: String = /*as I2 */.component2() } diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt index 5776b9e0b2c..fcb85af7862 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt @@ -48,12 +48,14 @@ FILE fqName: fileName:/smartCastsWithDestructuring.kt GET_VAR 'x: .I1 declared in .test' type=.I1 origin=null then: RETURN type=kotlin.Nothing from='public final fun test (x: .I1): kotlin.Unit declared in ' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.I2 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.I1 [val] TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 GET_VAR 'x: .I1 declared in .test' type=.I1 origin=null VAR name:c1 type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null - $receiver: GET_VAR 'val tmp_0: .I2 [val] declared in .test' type=.I2 origin=null + $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + GET_VAR 'val tmp_0: .I1 [val] declared in .test' type=.I1 origin=null VAR name:c2 type:kotlin.String [val] CALL 'public final fun component2 (): kotlin.String [operator] declared in ' type=kotlin.String origin=null - $receiver: GET_VAR 'val tmp_0: .I2 [val] declared in .test' type=.I2 origin=null + $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + GET_VAR 'val tmp_0: .I1 [val] declared in .test' type=.I1 origin=null diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index fe567f15a8d..291a14d1ad9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37446,6 +37446,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { 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 83e4f5b8d59..f5ffd7be0e1 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 @@ -37446,6 +37446,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4085b7eb97d..0125295a2e4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29921,6 +29921,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt index 65416d54d1a..bdda892a162 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt @@ -9,8 +9,8 @@ fun case_1() { val b = select(a) val c = a b - c - c.equals(10) + c + c.equals(10) b.equals(10) } @@ -18,8 +18,8 @@ fun case_1() { fun case_2(a: Any?) { if (a is String) { val b = a - b - b.length + b + b.length } } @@ -30,8 +30,8 @@ fun case_3(a: Any?) { val c = b val d = c val e = d - e - e.length + e + e.length } } @@ -46,12 +46,12 @@ fun case_4(a: Any?) { if (d is ClassLevel4) { val e = d if (e is ClassLevel5) { - e - e.test1() - e.test2() - e.test3() - e.test4() - e.test5() + e + e.test1() + e.test2() + e.test3() + e.test4() + e.test5() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt index 5dd0a55d89a..80abecf96f6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt @@ -13,8 +13,8 @@ fun case_1() { b b.equals(10) - c - c.equals(10) + c + c.equals(10) } // TESTCASE NUMBER: 2 @@ -22,8 +22,8 @@ fun case_2(x: Any) { if (x is String) { val y = x x - y - y.length + y + y.length } } @@ -34,10 +34,10 @@ fun case_3(x: Any?) { if (y == null) throw Exception() var z = y x - y - z - y.toByte() - z.toByte() + y + z + y.toByte() + z.toByte() } } @@ -48,10 +48,10 @@ fun case_4(x: Any?) { while (true && y != null) { var z = y x - y - z - y.toByte() - z.toByte() + y + z + y.toByte() + z.toByte() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt index 4523827f58f..6f4aaf0c91d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt @@ -11,16 +11,16 @@ fun case_1() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (a is String) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -33,16 +33,16 @@ fun case_2() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -55,16 +55,16 @@ fun case_3() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (true) - b - b.length + b + b.length } } @@ -77,16 +77,16 @@ fun case_4() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (false) - b - b.length + b + b.length } } @@ -99,16 +99,16 @@ fun case_5() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length for (i in 0..10) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -117,16 +117,16 @@ fun case_6() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length if (a is String) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -135,14 +135,14 @@ fun case_7() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length when (true) { true -> b = a } - b - b.length + b + b.length } } @@ -155,16 +155,16 @@ fun case_8() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } catch (e: Exception) { } - b - b.length + b + b.length } } @@ -173,18 +173,18 @@ fun case_9() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } catch (e: Exception) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -193,18 +193,18 @@ fun case_10() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } finally { } - b - b.length + b + b.length } } @@ -213,18 +213,18 @@ fun case_11() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } finally { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -237,15 +237,15 @@ fun case_12() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (if (true) { b = a; true } else true) { - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -254,12 +254,12 @@ fun case_13() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length a.plus(if (true) { b = a; true } else true) - b - b.length + b + b.length } } @@ -272,12 +272,12 @@ fun case_14() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else 3 - b - b.length + b + b.length } } } @@ -287,12 +287,12 @@ fun case_15() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else { b = a; } - b - b.length + b + b.length } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt index c32e6f134f3..887757f5a7e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt @@ -78,7 +78,7 @@ fun case_6(x: Any?, b: Class) { x val y = if (true) b::fun_1 else b::fun_1 x - z1 + z1 val z2: Int = z1 } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt index 321e2d48bea..eab764412c4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt @@ -57,16 +57,16 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) { - & Inv")!>b - & Inv")!>b.equals(null) - & Inv")!>b.propT - & Inv")!>b.propAny - & Inv")!>b.propNullableT - & Inv")!>b.propNullableAny - & Inv")!>b.funT() - & Inv")!>b.funAny() - & Inv")!>b.funNullableT() - & Inv")!>b.funNullableAny() + & Inv?")!>b + & Inv?")!>b.equals(null) + & Inv?")!>b.propT + & Inv?")!>b.propAny + & Inv?")!>b.propNullableT + & Inv?")!>b.propNullableAny + & Inv?")!>b.funT() + & Inv?")!>b.funAny() + & Inv?")!>b.funNullableT() + & Inv?")!>b.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt index 56172b08e81..59bd9a60449 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt @@ -61,16 +61,16 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) - & Inv")!>b - & Inv")!>b.equals(null) - & Inv")!>b.propT - & Inv")!>b.propAny - & Inv")!>b.propNullableT - & Inv")!>b.propNullableAny - & Inv")!>b.funT() - & Inv")!>b.funAny() - & Inv")!>b.funNullableT() - & Inv")!>b.funNullableAny() + & Inv?")!>b + & Inv?")!>b.equals(null) + & Inv?")!>b.propT + & Inv?")!>b.propAny + & Inv?")!>b.propNullableT + & Inv?")!>b.propNullableAny + & Inv?")!>b.funT() + & Inv?")!>b.funAny() + & Inv?")!>b.funNullableT() + & Inv?")!>b.funNullableAny() } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index e1bfd4bfe53..a2c682d5817 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25532,6 +25532,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 9c0fa9c796d..8e9184a794f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -25017,6 +25017,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index e93dce59051..49d053060d1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24977,6 +24977,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 318e3c70622..278e24bee54 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13594,6 +13594,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("multipleSmartCast.kt") public void testMultipleSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt");