FirClassSubstitutionScope: fix overridden symbols traversing
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// FILE: Named.java
|
||||
|
||||
public interface Named {
|
||||
String getName();
|
||||
}
|
||||
|
||||
// FILE: Psi.java
|
||||
|
||||
public interface Psi<D> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: Member.java
|
||||
|
||||
public interface Member<D> extends Psi<D> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: Test.kt
|
||||
|
||||
public interface Light
|
||||
|
||||
public class LightMember<D> : Light, Member<D> {
|
||||
override fun getName(): String = "Light"
|
||||
}
|
||||
|
||||
public interface Field : Named
|
||||
|
||||
public class LightField<D> : LightMember<Any>(), Field {
|
||||
fun test(other: Any?) {
|
||||
if (other is LightField<*>) {
|
||||
other.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
FILE: Test.kt
|
||||
public abstract interface Light : R|kotlin/Any| {
|
||||
}
|
||||
public final class LightMember<D> : R|Light|, R|Member<D>| {
|
||||
public constructor<D>(): R|LightMember<D>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final override fun getName(): R|kotlin/String| {
|
||||
^getName String(Light)
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface Field : R|Named| {
|
||||
}
|
||||
public final class LightField<D> : R|LightMember<kotlin/Any>|, R|Field| {
|
||||
public constructor<D>(): R|LightField<D>| {
|
||||
super<R|LightMember<kotlin/Any>|>()
|
||||
}
|
||||
|
||||
public final fun test(other: R|kotlin/Any?|): R|kotlin/Unit| {
|
||||
when () {
|
||||
(R|<local>/other| is R|LightField<*>|) -> {
|
||||
R|<local>/other|.R|/LightMember.name|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Generated
+5
@@ -1807,6 +1807,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorsComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinOverridesJavaComplex.kt")
|
||||
public void testKotlinOverridesJavaComplex() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBackingFieldForExtension.kt")
|
||||
public void testNoBackingFieldForExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt");
|
||||
|
||||
+5
@@ -1807,6 +1807,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorsComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinOverridesJavaComplex.kt")
|
||||
public void testKotlinOverridesJavaComplex() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/kotlinOverridesJavaComplex.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBackingFieldForExtension.kt")
|
||||
public void testNoBackingFieldForExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/properties/noBackingFieldForExtension.kt");
|
||||
|
||||
+6
-4
@@ -68,13 +68,15 @@ class FirClassSubstitutionScope(
|
||||
functionSymbol: FirFunctionSymbol<*>,
|
||||
processor: (FirFunctionSymbol<*>, Int) -> ProcessorAction
|
||||
): ProcessorAction {
|
||||
val unwrapped = functionSymbol.overriddenSymbol as FirFunctionSymbol<*>? ?: functionSymbol
|
||||
val overriddenDepth = if (unwrapped != functionSymbol) 1 else 0
|
||||
if (!processor(unwrapped, overriddenDepth)) {
|
||||
if (!useSiteMemberScope.processOverriddenFunctionsWithDepth(functionSymbol, processor)) {
|
||||
return ProcessorAction.STOP
|
||||
}
|
||||
val unwrapped = functionSymbol.overriddenSymbol as FirFunctionSymbol<*>? ?: return ProcessorAction.NEXT
|
||||
if (!processor(unwrapped, 1)) {
|
||||
return ProcessorAction.STOP
|
||||
}
|
||||
return useSiteMemberScope.processOverriddenFunctionsWithDepth(unwrapped) { symbol, depth ->
|
||||
processor(symbol, depth + overriddenDepth)
|
||||
processor(symbol, depth + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user