[FIR DFA] Don't consider anonymous object as stable initializer to bind
#KT-43332 Fixed
This commit is contained in:
+14
@@ -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)
|
||||
}
|
||||
+26
@@ -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<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun main(a: R|A|): R|kotlin/Unit| {
|
||||
R|/foo|(R|<local>/a|)
|
||||
lval anonymousA: R|A| = object : R|C| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|C|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
R|/foo|(R|<local>/anonymousA|)
|
||||
}
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// COMMON_COROUTINES_TEST
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
Reference in New Issue
Block a user