FIR IDE: align resolution behavior of super with FE1.0
That is, for a labeled `super`, the keyword should resolve to the super type and the label should be resolved to the current type.
This commit is contained in:
+6
@@ -289,6 +289,12 @@ internal object FirReferenceResolveHelper {
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
symbolBuilder: KtSymbolByFirBuilder
|
symbolBuilder: KtSymbolByFirBuilder
|
||||||
): Collection<KtSymbol> {
|
): Collection<KtSymbol> {
|
||||||
|
// If the cursor position is on the label of `super`, we want to resolve to the current class. FIR represents `super` as
|
||||||
|
// accessing the `super` property on `this`, hence this weird looking if condition. In addition, the current class type is available
|
||||||
|
// from the dispatch receiver `this`.
|
||||||
|
if (expression is KtLabelReferenceExpression && fir is FirPropertyAccessExpression && fir.calleeReference is FirSuperReference) {
|
||||||
|
return listOfNotNull((fir.dispatchReceiver.typeRef as? FirResolvedTypeRef)?.toTargetSymbol(session, symbolBuilder))
|
||||||
|
}
|
||||||
val calleeReference =
|
val calleeReference =
|
||||||
if (fir is FirFunctionCall &&
|
if (fir is FirFunctionCall &&
|
||||||
fir.isImplicitFunctionCall() &&
|
fir.isImplicitFunctionCall() &&
|
||||||
|
|||||||
+12
@@ -474,6 +474,18 @@ public class FirReferenceResolveTestGenerated extends AbstractFirReferenceResolv
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/SeveralOverrides.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/SeveralOverrides.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superWithLabel_caretAtLabel.kt")
|
||||||
|
public void testSuperWithLabel_caretAtLabel() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/superWithLabel_caretAtLabel.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superWithLabel_caretAtSuper.kt")
|
||||||
|
public void testSuperWithLabel_caretAtSuper() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/superWithLabel_caretAtSuper.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SyntheticProperty.kt")
|
@TestMetadata("SyntheticProperty.kt")
|
||||||
public void testSyntheticProperty() throws Exception {
|
public void testSyntheticProperty() throws Exception {
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
interface A {
|
||||||
|
fun a() {}
|
||||||
|
}
|
||||||
|
class Foo : A {
|
||||||
|
fun foo() {
|
||||||
|
super@F<caret>oo.a()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
Resolved to:
|
||||||
|
0: (in ROOT) class Foo : A
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
interface A {
|
||||||
|
fun a() {}
|
||||||
|
}
|
||||||
|
class Foo : A {
|
||||||
|
fun foo() {
|
||||||
|
s<caret>uper@Foo.a()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
Resolved to:
|
||||||
|
0: (in ROOT) interface A
|
||||||
Reference in New Issue
Block a user