FIR: handle synthetic properties with unstable smartcast

Synthetic properties from Java getter/setters need to be specially
handled so that candidates from such symbols are marked with unstable.
This commit is contained in:
Tianyu Geng
2021-06-09 15:25:16 -07:00
committed by TeamCityServer
parent ce767046eb
commit 3c8693758b
9 changed files with 90 additions and 40 deletions
@@ -0,0 +1,29 @@
// FIR_IDENTICAL
// FILE: p/Super.java
package p
public interface Super {
public String getName()
public void setName(String name)
}
// FILE: p/test.kt
package p
class Sub : Super {
val onlyInSub: Int = 1
override fun getName(): String = ""
override fun setName(name: String) {}
}
var s: Super = Sub()
fun test() {
if (s is Sub) {
s.name
s.name = ""
<!SMARTCAST_IMPOSSIBLE!>s<!>.onlyInSub
}
}
@@ -0,0 +1,25 @@
package
package p {
public var s: p.Super
public fun test(): kotlin.Unit
public final class Sub : p.Super {
public constructor Sub()
public final val onlyInSub: kotlin.Int = 1
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ fun getName(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ fun setName(/*0*/ name: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Super {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun getName(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun setName(/*0*/ name: kotlin.String!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -1,37 +0,0 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence?
fun baz(x: Any) {}
}
interface B {
fun foo(): String
fun baz(x: Int): String =""
fun baz(x: Int, y: Int) {}
fun foobar(): CharSequence?
}
interface C {
fun foo(): String
fun baz(x: Int): String =""
fun baz(x: Int, y: Int) {}
fun foobar(): String
}
var x: A = null!!
fun test() {
x.foo().checkType { _<CharSequence?>() }
if (x is B && x is C) {
x.foo().checkType { _<CharSequence?>() }
x.baz("")
x.baz(1).checkType { _<Unit>() }
x.baz(1, <!TOO_MANY_ARGUMENTS!>2<!>)
x.<!UNRESOLVED_REFERENCE!>foobar<!>().checkType { _<String>() }
}
}