K2 resolve: prefer derived class property to base class field
#KT-50082 Fixed
This commit is contained in:
committed by
teamcity
parent
642bbd38ba
commit
59bafedd8a
+30
@@ -0,0 +1,30 @@
|
||||
FILE: KotlinBase.kt
|
||||
public open class KotlinBase : R|kotlin/Any| {
|
||||
public constructor(): R|KotlinBase| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val abcd: R|kotlin/String| = String(abcd)
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
FILE: KotlinProxy.kt
|
||||
public abstract interface KotlinProxy : R|kotlin/Any| {
|
||||
public open val zyxw: R|kotlin/String|
|
||||
public get(): R|kotlin/String| {
|
||||
^ String(zyxw)
|
||||
}
|
||||
|
||||
}
|
||||
FILE: test.kt
|
||||
public final class Derived : R|Test|, R|KotlinProxy| {
|
||||
public constructor(): R|Derived| {
|
||||
super<R|Test|>()
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
this@R|/Derived|.R|/Test.abcd|
|
||||
this@R|/Derived|.R|/Test.zyxw|
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test extends KotlinBase {
|
||||
public final String abcd = "ABCD";
|
||||
|
||||
public final String zyxw = "ZYXW";
|
||||
}
|
||||
|
||||
// FILE: KotlinBase.kt
|
||||
|
||||
open class KotlinBase {
|
||||
val abcd = "abcd"
|
||||
}
|
||||
|
||||
// FILE: KotlinProxy.kt
|
||||
|
||||
interface KotlinProxy {
|
||||
val zyxw get() = "zyxw"
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Derived : Test(), KotlinProxy {
|
||||
fun test() {
|
||||
abcd // field!
|
||||
zyxw // field!
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FILE: KotlinBase.kt
|
||||
public open class KotlinBase : R|kotlin/Any| {
|
||||
public constructor(): R|KotlinBase| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val abcd: R|kotlin/String| = String(abcd)
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
FILE: test.kt
|
||||
public final fun test(d: R|JavaDerived|): R|kotlin/Unit| {
|
||||
R|<local>/d|.R|/JavaDerived.abcd|
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test extends KotlinBase {
|
||||
public final String abcd = "ABCD";
|
||||
}
|
||||
|
||||
// FILE: KotlinBase.kt
|
||||
|
||||
open class KotlinBase {
|
||||
val abcd = "abcd"
|
||||
}
|
||||
|
||||
// FILE: JavaDerived.java
|
||||
|
||||
public class JavaDerived extends Test {
|
||||
public final String abcd = "AaBbCcDd"
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test(d: JavaDerived) {
|
||||
d.abcd // JavaDerived
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
FILE: test.kt
|
||||
public final class Test2 : R|Test| {
|
||||
public constructor(): R|Test2| {
|
||||
super<R|Test|>()
|
||||
}
|
||||
|
||||
private final val text: R|kotlin/String| = String(BCDE)
|
||||
private get(): R|kotlin/String|
|
||||
|
||||
private final val publicPrivateText: R|kotlin/String| = String(YXWV)
|
||||
private get(): R|kotlin/String|
|
||||
|
||||
public final fun check(): R|kotlin/String| {
|
||||
^check this@R|/Test2|.R|/Test2.text|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun check(): R|kotlin/String!| {
|
||||
^check R|/Test2.Test2|().R|/Test.publicPrivateText|
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
protected final String text = "ABCD";
|
||||
|
||||
public final String publicPrivateText = "ZYXW";
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Test2 : Test() {
|
||||
private val text = "BCDE"
|
||||
|
||||
private val publicPrivateText = "YXWV"
|
||||
|
||||
fun check() = text // Should be resolved to Test2.text, not to Test.text
|
||||
}
|
||||
|
||||
fun check() = Test2().publicPrivateText // Should be resolved to Test.publicPrivateText (Test2 member is private)
|
||||
|
||||
Reference in New Issue
Block a user