diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt b/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt new file mode 100644 index 00000000000..86a490f3cb7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt @@ -0,0 +1,14 @@ +interface A +interface B + +fun foo(x: A) {} +fun foo(x: B) {} + +open class C : A, B + +fun main(a: A) { + foo(a) + + val anonymousA: A = object : C() {} + foo(anonymousA) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.txt b/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.txt new file mode 100644 index 00000000000..2cf6c0b9e47 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.txt @@ -0,0 +1,26 @@ +FILE: questionableSmartCast.kt + public abstract interface A : R|kotlin/Any| { + } + public abstract interface B : R|kotlin/Any| { + } + public final fun foo(x: R|A|): R|kotlin/Unit| { + } + public final fun foo(x: R|B|): R|kotlin/Unit| { + } + public open class C : R|A|, R|B| { + public constructor(): R|C| { + super() + } + + } + public final fun main(a: R|A|): R|kotlin/Unit| { + R|/foo|(R|/a|) + lval anonymousA: R|A| = object : R|C| { + private constructor(): R|| { + super() + } + + } + + R|/foo|(R|/anonymousA|) + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 87b998865de..23c8183147d 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -2074,6 +2074,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @TestMetadata("questionableSmartCast.kt") + public void testQuestionableSmartCast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt"); + } + @TestMetadata("safeCallInvoke.kt") public void testSafeCallInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/safeCallInvoke.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index c974f775714..59c78f4a0d2 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -2074,6 +2074,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @TestMetadata("questionableSmartCast.kt") + public void testQuestionableSmartCast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt"); + } + @TestMetadata("safeCallInvoke.kt") public void testSafeCallInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/safeCallInvoke.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 0e32f18e276..a3bc2533eec 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2074,6 +2074,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @TestMetadata("questionableSmartCast.kt") + public void testQuestionableSmartCast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt"); + } + @TestMetadata("safeCallInvoke.kt") public void testSafeCallInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/safeCallInvoke.kt"); diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt index ad3bb7a7adf..be162b7cc8a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt @@ -145,6 +145,7 @@ class VariableStorage(private val session: FirSession) { returns(true) implies(this@isStable != null) } when (this) { + is FirAnonymousObjectSymbol -> return false is FirFunctionSymbol<*>, is FirClassSymbol<*>, is FirBackingFieldSymbol -> return true diff --git a/compiler/testData/codegen/box/reflection/typeOf/typeOfCapturedStar.kt b/compiler/testData/codegen/box/reflection/typeOf/typeOfCapturedStar.kt index 3213ed18905..ea4e80adbe9 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/typeOfCapturedStar.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/typeOfCapturedStar.kt @@ -1,6 +1,5 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi // !LANGUAGE: +NewInference -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS, JS_IR // IGNORE_BACKEND: JS_IR_ES6 // WITH_REFLECT diff --git a/compiler/testData/codegen/boxInline/suspend/stateMachine/objectInsideLambdas.kt b/compiler/testData/codegen/boxInline/suspend/stateMachine/objectInsideLambdas.kt index 642c5ccc0a9..7f7855a0873 100644 --- a/compiler/testData/codegen/boxInline/suspend/stateMachine/objectInsideLambdas.kt +++ b/compiler/testData/codegen/boxInline/suspend/stateMachine/objectInsideLambdas.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // COMMON_COROUTINES_TEST // WITH_RUNTIME // WITH_COROUTINES