Skip to content

Commit

Permalink
[FIR DFA] Don't consider anonymous object as stable initializer to bind
Browse files Browse the repository at this point in the history
#KT-43332 Fixed
  • Loading branch information
mglukhikh committed Nov 26, 2020
1 parent 1dc8973 commit 0a0b5b5
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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|)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
Expand Down

0 comments on commit 0a0b5b5

Please sign in to comment.