FIR: Fix processOverriddenFunctions implementations
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
// FILE: JA.java
|
||||
public interface JA<E> {
|
||||
public E getFoo();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface KB<F> {
|
||||
override fun getFoo(): F
|
||||
override fun getBar(): F
|
||||
}
|
||||
|
||||
interface D1 : JA<String>, KB<String>
|
||||
interface E1 : D1 {
|
||||
override fun getFoo(): String
|
||||
override fun getBar(): String
|
||||
}
|
||||
|
||||
interface D2 : KB<String>, JA<String>
|
||||
interface E2 : D2 {
|
||||
override fun getFoo(): String
|
||||
override fun getBar(): String
|
||||
}
|
||||
|
||||
fun main(
|
||||
d1: D1, e1: E1,
|
||||
d2: D2, e2: E2,
|
||||
) {
|
||||
d1.foo
|
||||
d1.<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
e1.foo
|
||||
e1.<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
|
||||
d2.foo
|
||||
d2.<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
e2.foo
|
||||
e2.<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
FILE: main.kt
|
||||
public abstract interface KB<F> : R|kotlin/Any| {
|
||||
public abstract override fun getFoo(): R|F|
|
||||
|
||||
public abstract override fun getBar(): R|F|
|
||||
|
||||
}
|
||||
public abstract interface D1 : R|JA<kotlin/String>|, R|KB<kotlin/String>| {
|
||||
}
|
||||
public abstract interface E1 : R|D1| {
|
||||
public abstract override fun getFoo(): R|kotlin/String|
|
||||
|
||||
public abstract override fun getBar(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public abstract interface D2 : R|KB<kotlin/String>|, R|JA<kotlin/String>| {
|
||||
}
|
||||
public abstract interface E2 : R|D2| {
|
||||
public abstract override fun getFoo(): R|kotlin/String|
|
||||
|
||||
public abstract override fun getBar(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final fun main(d1: R|D1|, e1: R|E1|, d2: R|D2|, e2: R|E2|): R|kotlin/Unit| {
|
||||
R|<local>/d1|.R|/D1.foo|
|
||||
R|<local>/d1|.<Unresolved name: bar>#
|
||||
R|<local>/e1|.R|/E1.foo|
|
||||
R|<local>/e1|.<Unresolved name: bar>#
|
||||
R|<local>/d2|.R|/D2.foo|
|
||||
R|<local>/d2|.<Unresolved name: bar>#
|
||||
R|<local>/e2|.R|/E2.foo|
|
||||
R|<local>/e2|.<Unresolved name: bar>#
|
||||
}
|
||||
Generated
+5
@@ -1732,6 +1732,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaAccessorsComplex.kt")
|
||||
public void testJavaAccessorsComplex() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorsComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBackingFieldForExtension.kt")
|
||||
public void testNoBackingFieldForExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt");
|
||||
|
||||
+5
@@ -1732,6 +1732,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaAccessorsComplex.kt")
|
||||
public void testJavaAccessorsComplex() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorsComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBackingFieldForExtension.kt")
|
||||
public void testNoBackingFieldForExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt");
|
||||
|
||||
+16
-3
@@ -41,6 +41,8 @@ class FirTypeIntersectionScope private constructor(
|
||||
|
||||
private val typeContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session)
|
||||
|
||||
private val overriddenSymbols = mutableMapOf<FirCallableSymbol<*>, Collection<FirCallableSymbol<*>>>()
|
||||
|
||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||
if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) {
|
||||
super.processFunctionsByName(name, processor)
|
||||
@@ -81,9 +83,11 @@ class FirTypeIntersectionScope private constructor(
|
||||
|
||||
membersByScope.singleOrNull()?.let { members ->
|
||||
for (member in members) {
|
||||
overriddenSymbols[member] = listOf(member)
|
||||
processor(member)
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -94,7 +98,7 @@ class FirTypeIntersectionScope private constructor(
|
||||
val extractedOverrides = extractBothWaysOverridable(maxByVisibility, allMembers)
|
||||
|
||||
val mostSpecific = selectMostSpecificMember(extractedOverrides)
|
||||
|
||||
overriddenSymbols[mostSpecific] = extractedOverrides
|
||||
processor(mostSpecific)
|
||||
}
|
||||
|
||||
@@ -245,8 +249,17 @@ class FirTypeIntersectionScope private constructor(
|
||||
functionSymbol: FirFunctionSymbol<*>,
|
||||
processor: (FirFunctionSymbol<*>) -> ProcessorAction
|
||||
): ProcessorAction {
|
||||
for (scope in scopes) {
|
||||
if (!scope.processOverriddenFunctions(functionSymbol, processor)) return ProcessorAction.STOP
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val directOverriddenSymbols =
|
||||
overriddenSymbols[functionSymbol] as Collection<FirFunctionSymbol<*>>?
|
||||
?: return ProcessorAction.NEXT
|
||||
|
||||
for (directOverridden in directOverriddenSymbols) {
|
||||
// TODO: Preserve the scope where directOverridden came from
|
||||
for (scope in scopes) {
|
||||
if (!processor(directOverridden)) return ProcessorAction.STOP
|
||||
if (!scope.processOverriddenFunctions(directOverridden, processor)) return ProcessorAction.STOP
|
||||
}
|
||||
}
|
||||
|
||||
return ProcessorAction.NEXT
|
||||
|
||||
@@ -34,6 +34,6 @@ abstract class FirTypeScope : FirScope() {
|
||||
if (!baseScope.processOverriddenFunctions(overridden, processor)) return ProcessorAction.STOP
|
||||
}
|
||||
|
||||
return ProcessorAction.NEXT
|
||||
return baseScope.processOverriddenFunctions(functionSymbol, processor)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user