FIR: Allow a field override another field with the same name
This commit is contained in:
+1
-1
@@ -37,7 +37,7 @@ abstract class AbstractFirOverrideScope(val session: FirSession, protected val o
|
|||||||
}
|
}
|
||||||
is FirConstructor -> false
|
is FirConstructor -> false
|
||||||
is FirProperty -> baseDeclaration is FirProperty && isOverriddenProperty(overrideCandidate, baseDeclaration)
|
is FirProperty -> baseDeclaration is FirProperty && isOverriddenProperty(overrideCandidate, baseDeclaration)
|
||||||
is FirField -> false
|
is FirField -> baseDeclaration is FirField
|
||||||
else -> error("Unknown fir callable type: $overrideCandidate, $baseDeclaration")
|
else -> error("Unknown fir callable type: $overrideCandidate, $baseDeclaration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
public class A {
|
||||||
|
public String x = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
public class B extends A {
|
||||||
|
public int x = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun main(b: B) {
|
||||||
|
b.x + 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
FILE: main.kt
|
||||||
|
public final fun main(b: R|B|): R|kotlin/Unit| {
|
||||||
|
R|<local>/b|.R|/B.x|.R|kotlin/Int.plus|(Int(1))
|
||||||
|
}
|
||||||
Generated
+5
@@ -585,6 +585,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
|||||||
runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/FieldAndGetter.kt");
|
runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/FieldAndGetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fieldOverride.kt")
|
||||||
|
public void testFieldOverride() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/fieldOverride.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("FieldSubstitution.kt")
|
@TestMetadata("FieldSubstitution.kt")
|
||||||
public void testFieldSubstitution() throws Exception {
|
public void testFieldSubstitution() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/FieldSubstitution.kt");
|
runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/FieldSubstitution.kt");
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
// FILE: A.java
|
|
||||||
|
|
||||||
public class A {
|
|
||||||
public int size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: B.java
|
|
||||||
|
|
||||||
public class B implements A {
|
|
||||||
public int size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
B().<!AMBIGUITY!>size<!>
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FILE: A.java
|
// FILE: A.java
|
||||||
|
|
||||||
public class A {
|
public class A {
|
||||||
|
|||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
// !CHECK_TYPE
|
|
||||||
|
|
||||||
// FILE: A.java
|
|
||||||
|
|
||||||
public class A {
|
|
||||||
public int size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: B.java
|
|
||||||
|
|
||||||
public class B extends A {
|
|
||||||
public String size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
B().<!AMBIGUITY!>size<!>.<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !CHECK_TYPE
|
// !CHECK_TYPE
|
||||||
|
|
||||||
// FILE: A.java
|
// FILE: A.java
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ public open class Frame : R|kotlin/Any| {
|
|||||||
public open class JFrame : R|awt/Frame| {
|
public open class JFrame : R|awt/Frame| {
|
||||||
protected/*protected and package*/ open field accessibleContext: R|ft<kotlin/String, kotlin/String?>!|
|
protected/*protected and package*/ open field accessibleContext: R|ft<kotlin/String, kotlin/String?>!|
|
||||||
|
|
||||||
public/*package*/ open field accessibleContext: R|ft<kotlin/String, kotlin/String?>!|
|
|
||||||
|
|
||||||
public constructor(): R|test/JFrame|
|
public constructor(): R|test/JFrame|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user