From 8578a0bf6aa36ab9701608c172a3cc7e56223b37 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 7 Nov 2023 17:41:22 +0200 Subject: [PATCH] [FIR2IR] Properly insert casts for smartcasts in argument position Previously cast inserter didn't consider expected type for arguments of function calls ^KT-63257 Fixed --- ...LFirBlackBoxCodegenBasedTestGenerated.java | 6 ++ ...rsedBlackBoxCodegenBasedTestGenerated.java | 6 ++ .../fir/backend/Fir2IrImplicitCastInserter.kt | 25 +++++- .../generators/CallAndReferenceGenerator.kt | 17 +++- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 ++ ...hIrFakeOverrideGeneratorTestGenerated.java | 6 ++ .../FirPsiBlackBoxCodegenTestGenerated.java | 6 ++ .../smartcastFromGenericToString.ir.txt | 84 +++++++++++++++++++ .../smartcastFromGenericToString.kt | 22 +++++ .../boxWasmJsInterop/externalTypeOperators.kt | 3 +- .../samConversionsWithSmartCasts.fir.ir.txt | 15 ++-- .../samConversionsWithSmartCasts.fir.kt.txt | 8 +- .../samConversionsWithSmartCasts.fir.ir.txt | 18 ++-- .../samConversionsWithSmartCasts.fir.kt.txt | 10 +-- ...ConversionOnArbitraryExpression.fir.ir.txt | 6 +- ...ConversionOnArbitraryExpression.fir.kt.txt | 4 +- .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../fir/FirJsCodegenBoxTestGenerated.java | 6 ++ .../fir/FirJsES6CodegenBoxTestGenerated.java | 6 ++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 6 ++ .../ir/IrJsES6CodegenBoxTestGenerated.java | 6 ++ .../FirNativeCodegenBoxTestGenerated.java | 6 ++ .../FirNativeCodegenBoxTestNoPLGenerated.java | 6 ++ .../NativeCodegenBoxTestGenerated.java | 6 ++ .../NativeCodegenBoxTestNoPLGenerated.java | 6 ++ .../test/FirWasmCodegenBoxTestGenerated.java | 6 ++ .../test/K1WasmCodegenBoxTestGenerated.java | 6 ++ 30 files changed, 292 insertions(+), 33 deletions(-) create mode 100644 compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.ir.txt create mode 100644 compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java index f5986d6f3ee..3f23d67004b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java @@ -51308,6 +51308,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java index a17e1fb2522..f00d5c8e00b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java @@ -51308,6 +51308,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index 84f51667df3..74183500cae 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -234,6 +234,19 @@ class Fir2IrImplicitCastInserter( } } + internal fun IrExpression.insertCastForSmartcastWithIntersection( + argumentType: ConeKotlinType, + expectedType: ConeKotlinType + ): IrExpression { + if (argumentType !is ConeIntersectionType) return this + val approximatedArgumentType = argumentType.approximateForIrOrNull() ?: argumentType + if (approximatedArgumentType.isSubtypeOf(expectedType, session)) return this + + return findComponentOfIntersectionForExpectedType(argumentType, expectedType)?.let { + implicitCast(this, it.toIrType()) + } ?: this + } + private fun ConeKotlinType.acceptsNullValues(): Boolean { return canBeNull || hasEnhancedNullability } @@ -333,9 +346,15 @@ class Fir2IrImplicitCastInserter( } } - for (componentType in receiverExpressionType.intersectedTypes) { - if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, receiverType)) { - return implicitCastOrExpression(originalIrReceiver, componentType, typeOrigin) + return findComponentOfIntersectionForExpectedType(receiverExpressionType, receiverType)?.let { + implicitCastOrExpression(originalIrReceiver, it, typeOrigin) + } + } + + private fun findComponentOfIntersectionForExpectedType(type: ConeIntersectionType, expectedType: ConeKotlinType): ConeKotlinType? { + for (componentType in type.intersectedTypes) { + if (AbstractTypeChecker.isSubtypeOf(session.typeContext, componentType, expectedType)) { + return componentType } } return null diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 75e271c4bf7..aa7cbeeb9ef 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -1021,17 +1021,26 @@ class CallAndReferenceGenerator( parameter: FirValueParameter?, substitutor: ConeSubstitutor, ): IrExpression { - val parameterConeType = parameter?.returnTypeRef?.coneType + val unsubstitutedParameterType = parameter?.returnTypeRef?.coneType?.fullyExpandedType(session) // Normally argument type should be correct itself. // However, for deserialized annotations it's possible to have imprecise Array type // for empty integer literal arguments. // In this case we have to use parameter type itself which is more precise, like Array or IntArray. // See KT-62598 and its fix for details. - val expectedType = parameterConeType.takeIf { visitor.annotationMode && parameterConeType?.isArrayType == true } + val expectedType = unsubstitutedParameterType.takeIf { visitor.annotationMode && unsubstitutedParameterType?.isArrayType == true } var irArgument = visitor.convertToIrExpression(argument, expectedType = expectedType) - if (parameterConeType != null) { + if (unsubstitutedParameterType != null) { with(visitor.implicitCastInserter) { - irArgument = irArgument.cast(argument, argument.resolvedType, parameterConeType) + val argumentType = argument.resolvedType.fullyExpandedType(session) + if (argument is FirSmartCastExpression) { + val substitutedParameterType = substitutor.substituteOrSelf(unsubstitutedParameterType) + // here we should use a substituted parameter type to properly choose the component of an intersection type + // to provide a proper cast to the smartcasted type + irArgument = irArgument.insertCastForSmartcastWithIntersection(argumentType, substitutedParameterType) + } + // here we should pass unsubstituted parameter type to properly infer if the original type accepts null or not + // to properly insert nullability check + irArgument = irArgument.cast(argument, argumentType, unsubstitutedParameterType) } } with(adapterGenerator) { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 96c7a5c2a4b..fc71a8162ed 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -50733,6 +50733,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 7bc71fc35af..27b1c779023 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -50733,6 +50733,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 002ad75de60..169b670476f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -50733,6 +50733,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() throws Exception { diff --git a/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.ir.txt b/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.ir.txt new file mode 100644 index 00000000000..49e9c156c5f --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.ir.txt @@ -0,0 +1,84 @@ +FILE fqName: fileName:/smartcastFromGenericToString.kt + CLASS CLASS name:Some modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Some.Some> + TYPE_PARAMETER name:V index:0 variance: superTypes:[kotlin.Any] reified:false + CONSTRUCTOR visibility:public <> (map:kotlin.collections.Map.Some>) returnType:.Some.Some> [primary] + VALUE_PARAMETER name:map index:0 type:kotlin.collections.Map.Some> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Some modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:map visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.Some> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'map: kotlin.collections.Map.Some> declared in .Some.' type=kotlin.collections.Map.Some> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Some.Some>) returnType:kotlin.collections.Map.Some> + correspondingProperty: PROPERTY name:map visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Some.Some> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.Map.Some> declared in .Some' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.Some> visibility:private [final]' type=kotlin.collections.Map.Some> origin=null + receiver: GET_VAR ': .Some.Some> declared in .Some.' type=.Some.Some> origin=null + FUN name:test visibility:public modality:FINAL <> ($this:.Some.Some>, key:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Some.Some> + VALUE_PARAMETER name:key index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test (key: kotlin.String): kotlin.String declared in .Some' + BLOCK type=kotlin.String origin=WHEN + VAR name:value type:V of .Some [val] + CALL 'public final fun getValue (key: K of kotlin.collections.getValue): V of kotlin.collections.getValue declared in kotlin.collections' type=V of .Some origin=null + : kotlin.String + : V of .Some + $receiver: CALL 'public final fun (): kotlin.collections.Map.Some> declared in .Some' type=kotlin.collections.Map.Some> origin=GET_PROPERTY + $this: GET_VAR ': .Some.Some> declared in .Some.test' type=.Some.Some> origin=null + key: GET_VAR 'key: kotlin.String declared in .Some.test' type=kotlin.String origin=null + WHEN type=kotlin.String origin=WHEN + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String + GET_VAR 'val value: V of .Some declared in .Some.test' type=V of .Some origin=null + then: CALL 'public final fun addK (s: kotlin.String): kotlin.String declared in .Some' type=kotlin.String origin=null + $this: GET_VAR ': .Some.Some> declared in .Some.test' type=.Some.Some> origin=null + s: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR 'val value: V of .Some declared in .Some.test' type=V of .Some origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Fail: " + GET_VAR 'val value: V of .Some declared in .Some.test' type=V of .Some origin=null + FUN name:addK visibility:public modality:FINAL <> ($this:.Some.Some>, s:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Some.Some> + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun addK (s: kotlin.String): kotlin.String declared in .Some' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUS + $this: GET_VAR 's: kotlin.String declared in .Some.addK' type=kotlin.String origin=null + other: CONST String type=kotlin.String value="K" + 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 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 + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:x type:.Some [val] + CONSTRUCTOR_CALL 'public constructor (map: kotlin.collections.Map.Some>) declared in .Some' type=.Some origin=null + : kotlin.String + map: CALL 'public final fun mapOf (pair: kotlin.Pair): kotlin.collections.Map declared in kotlin.collections' type=kotlin.collections.Map origin=null + : kotlin.String + : kotlin.String + pair: CALL 'public final fun to (that: B of kotlin.to): kotlin.Pair declared in kotlin' type=kotlin.Pair origin=null + : kotlin.String + : kotlin.String + $receiver: CONST String type=kotlin.String value="key" + that: CONST String type=kotlin.String value="O" + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun test (key: kotlin.String): kotlin.String declared in .Some' type=kotlin.String origin=null + $this: GET_VAR 'val x: .Some declared in .box' type=.Some origin=null + key: CONST String type=kotlin.String value="key" diff --git a/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt b/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt new file mode 100644 index 00000000000..a5fce227ad6 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-62863 +// FIR_IDENTICAL +// WITH_STDLIB +// DUMP_IR + +class Some(val map: Map) { + fun test(key: String): String { + return when (val value = map.getValue(key)) { + is String -> addK(value) + else -> "Fail: $value" + } + } + + fun addK(s: String): String { + return s + "K" + } +} + +fun box(): String { + val x = Some(mapOf("key" to "O")) + return x.test("key") +} diff --git a/compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt b/compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt index 50af03a9edd..25e2db63ac7 100644 --- a/compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt +++ b/compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_K2: WASM // WITH_STDLIB // FILE: externals.js @@ -229,4 +228,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt index 75515488fb6..f6a2af9bdac 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt @@ -44,7 +44,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null + r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:.KRunnable) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.KRunnable BLOCK_BODY @@ -62,8 +63,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r2: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 VALUE_PARAMETER name:b index:1 type:kotlin.Function0 @@ -74,7 +77,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null r2: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit @@ -101,7 +105,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null + r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt index fcf30b8eb81..92c1426616c 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt @@ -20,7 +20,7 @@ fun test0(a: T) where T : KRunnable, T : Function0 { fun test1(a: Function0) { when { a is KRunnable -> { // BLOCK - run1(r = a) + run1(r = a /*as KRunnable */) } } } @@ -33,7 +33,7 @@ fun test2(a: KRunnable) { fun test3(a: Function0) { when { a is KRunnable -> { // BLOCK - run2(r1 = a, r2 = a) + run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */) } } } @@ -41,7 +41,7 @@ fun test3(a: Function0) { fun test4(a: Function0, b: Function0) { when { a is KRunnable -> { // BLOCK - run2(r1 = a, r2 = b /*-> KRunnable */) + run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */) } } } @@ -58,7 +58,7 @@ fun test5x(a: Any) { when { a is KRunnable -> { // BLOCK a /*as KRunnable */ as Function0 /*~> Unit */ - run1(r = a) + run1(r = a /*as KRunnable */) } } } diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt index 36e97d7b23b..2efbfd24ec3 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt @@ -8,7 +8,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun runStatic (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - r: GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY @@ -19,7 +20,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY @@ -30,8 +32,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null + r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 VALUE_PARAMETER name:b index:1 type:kotlin.Function0 @@ -43,7 +47,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null + r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null r2: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable? GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit @@ -72,7 +77,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null + r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt index 5ae781b9b52..3cce03d83ee 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt @@ -1,7 +1,7 @@ fun test1(a: Function0) { when { a is Runnable -> { // BLOCK - runStatic(r = a) + runStatic(r = a /*as Runnable */) } } } @@ -9,7 +9,7 @@ fun test1(a: Function0) { fun test2(a: Function0) { when { a is Runnable -> { // BLOCK - J().run1(r = a) + J().run1(r = a /*as Runnable */) } } } @@ -17,7 +17,7 @@ fun test2(a: Function0) { fun test3(a: Function0) { when { a is Runnable -> { // BLOCK - J().run2(r1 = a, r2 = a) + J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */) } } } @@ -25,7 +25,7 @@ fun test3(a: Function0) { fun test4(a: Function0, b: Function0) { when { a is Runnable -> { // BLOCK - J().run2(r1 = a, r2 = b /*-> @FlexibleNullability Runnable? */) + J().run2(r1 = a /*as Runnable */, r2 = b /*-> @FlexibleNullability Runnable? */) } } } @@ -42,7 +42,7 @@ fun test5x(a: Any) { when { a is Runnable -> { // BLOCK a /*as Runnable */ as Function0 /*~> Unit */ - J().run1(r = a) + J().run1(r = a /*as Runnable */) } } } diff --git a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt index 4c79bd7c4f5..1a83edb4f10 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt @@ -254,7 +254,8 @@ FILE fqName: fileName:/suspendConversionOnArbitraryExpression.kt TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=CAST typeOperand=kotlin.coroutines.SuspendFunction0 GET_VAR 'a: kotlin.Function0 declared in .testSmartCastVsSuspendConversion' type=kotlin.Function0 origin=null CALL 'public final fun useSuspend (sfn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - sfn: GET_VAR 'a: kotlin.Function0 declared in .testSmartCastVsSuspendConversion' type=kotlin.Function0 origin=null + sfn: TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=IMPLICIT_CAST typeOperand=kotlin.coroutines.SuspendFunction0 + GET_VAR 'a: kotlin.Function0 declared in .testSmartCastVsSuspendConversion' type=kotlin.Function0 origin=null FUN name:testSmartCastOnVarVsSuspendConversion visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY @@ -264,7 +265,8 @@ FILE fqName: fileName:/suspendConversionOnArbitraryExpression.kt TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=CAST typeOperand=kotlin.coroutines.SuspendFunction0 GET_VAR 'var b: kotlin.Function0 declared in .testSmartCastOnVarVsSuspendConversion' type=kotlin.Function0 origin=null CALL 'public final fun useSuspend (sfn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - sfn: GET_VAR 'var b: kotlin.Function0 declared in .testSmartCastOnVarVsSuspendConversion' type=kotlin.Function0 origin=null + sfn: TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=IMPLICIT_CAST typeOperand=kotlin.coroutines.SuspendFunction0 + GET_VAR 'var b: kotlin.Function0 declared in .testSmartCastOnVarVsSuspendConversion' type=kotlin.Function0 origin=null FUN name:testIntersectionVsSuspendConversion visibility:public modality:FINAL (x:T of .testIntersectionVsSuspendConversion) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function0; kotlin.coroutines.SuspendFunction0] reified:false VALUE_PARAMETER name:x index:0 type:T of .testIntersectionVsSuspendConversion diff --git a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt index 9eb213112ad..6161955eac5 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt @@ -175,13 +175,13 @@ fun testSmartCastOnVarWithSuspendConversion(a: Any) { fun testSmartCastVsSuspendConversion(a: Function0) { a as SuspendFunction0 /*~> Unit */ - useSuspend(sfn = a) + useSuspend(sfn = a /*as SuspendFunction0 */) } fun testSmartCastOnVarVsSuspendConversion(a: Function0) { var b: Function0 = a b as SuspendFunction0 /*~> Unit */ - useSuspend(sfn = b) + useSuspend(sfn = b /*as SuspendFunction0 */) } fun testIntersectionVsSuspendConversion(x: T) where T : Function0, T : SuspendFunction0 { 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 1eb1f3147e1..8e9ac9c77a2 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 @@ -47739,6 +47739,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() 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 9cd9dc95dc4..050ca6c7217 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 @@ -50733,6 +50733,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index c3d7bf017db..64dee0bd438 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -50733,6 +50733,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() 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 cf66ea1f693..f180e51c4ad 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -40816,6 +40816,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") public void testSmartcastOnImplicitDispatchReceiver() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 0ec71611bce..9f934dcde51 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -35109,6 +35109,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index 8fcb8b87a78..5400548fc35 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -35109,6 +35109,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 522a0f47f5b..ce2cf368a31 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -35109,6 +35109,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 063c64493e1..b811ba2c548 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -35109,6 +35109,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastOnDynamic.kt") public void testSmartcastOnDynamic() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index 67d67263e42..53f60e13c0b 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -38795,6 +38795,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index a1be4ac2b37..270bb403fd4 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -39793,6 +39793,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java index 30d895aaa85..1985e167603 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java @@ -38297,6 +38297,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java index 2d91f86d919..300216fe85c 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java @@ -38796,6 +38796,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index 0729f8e8341..1af4b36d7ed 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -34785,6 +34785,12 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index 17a7a5eadce..0734a1576fc 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -34785,6 +34785,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastFromGenericToString.kt") + public void testSmartcastFromGenericToString() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastFromGenericToString.kt"); + } + @Test @TestMetadata("smartcastToStarType.kt") public void testSmartcastToStarType() throws Exception {