[FIR] Fix collecting member candidates on receiver with smartcast
^KT-51460 Fixed ^KT-51827
This commit is contained in:
committed by
teamcity
parent
51bd0fd2db
commit
6e2402620f
@@ -0,0 +1,26 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
interface JPanel {
|
||||
val result: String
|
||||
}
|
||||
|
||||
open class ActivePanel : JPanel {
|
||||
override var result: String = ""
|
||||
|
||||
fun fire(event: String) {
|
||||
result = event
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
val panel: JPanel
|
||||
|
||||
init {
|
||||
panel = object : ActivePanel() {}
|
||||
|
||||
panel.fire("OK")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Test().panel.result
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// ISSUE: KT-51460, KT-51827
|
||||
|
||||
open class Base {
|
||||
protected open val a: CharSequence
|
||||
get() = "Fail: Base"
|
||||
|
||||
|
||||
fun test(other: Base): String {
|
||||
return when (other) {
|
||||
is Derived_1 -> other.a.toString()
|
||||
is Derived_2 -> other.a.toString()
|
||||
else -> "Fail: not Derived"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Derived_1: Base() {
|
||||
override val a: String
|
||||
get() = "Fail: Derived_1"
|
||||
}
|
||||
|
||||
class Derived_2: Base() {
|
||||
override val a: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = Derived_2()
|
||||
return x.test(x)
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// ISSUE: KT-51460
|
||||
|
||||
open class Base {
|
||||
protected open val a: CharSequence
|
||||
get() = "Fail: Base"
|
||||
|
||||
|
||||
fun test(other: Base): String {
|
||||
return when (other) {
|
||||
is Derived_1 -> other.a.toString()
|
||||
is Derived_2 -> other.a.toString()
|
||||
else -> "Fail: not Derived"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Derived_1: Base() {
|
||||
override val a: CharSequence
|
||||
get() = "Fail: Derived_1"
|
||||
}
|
||||
|
||||
class Derived_2: Base() {
|
||||
override val a: CharSequence
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = Derived_2()
|
||||
return x.test(x)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "O";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "K";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(x: Any): String {
|
||||
return when (x) {
|
||||
is A -> x.toString()
|
||||
is B -> x.toString()
|
||||
else -> "fail"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test(A()) + test(B())
|
||||
}
|
||||
Reference in New Issue
Block a user