HL API: Handle resolve case when source for FirResolvedQualifier is a
KtCallExpression.
This commit is contained in:
committed by
Ilya Kirillov
parent
cba77452f3
commit
c2529a4abb
+3
-6
@@ -399,13 +399,10 @@ internal object FirReferenceResolveHelper {
|
||||
val referencedClass = referencedSymbol.fir
|
||||
val referencedSymbolsByFir = listOfNotNull(symbolBuilder.buildSymbol(referencedClass))
|
||||
val firSourcePsi = fir.source.psi ?: referencedSymbolsByFir
|
||||
// The source of an `FirResolvedQualifier` is either a KtNamedReferenceExpression or a KtDotQualifiedExpression. In the former case,
|
||||
// it implies the qualifier is an atomic reference and therefore, it should be identical with the `expression`. In the latter case,
|
||||
// we need to manually break up the qualified access and resolve individual parts of it because in FIR, the entire qualified access
|
||||
// is one element.
|
||||
if (firSourcePsi === expression) return referencedSymbolsByFir
|
||||
require(firSourcePsi is KtDotQualifiedExpression)
|
||||
if (firSourcePsi !is KtDotQualifiedExpression) return referencedSymbolsByFir
|
||||
|
||||
// When the source of an `FirResolvedQualifier` is a KtDotQualifiedExpression, we need to manually break up the qualified access and
|
||||
// resolve individual parts of it because in FIR, the entire qualified access is one element.
|
||||
if (referencedClass.isLocal) {
|
||||
// TODO: handle local classes after KT-47135 is fixed
|
||||
return referencedSymbolsByFir
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test<T>
|
||||
|
||||
// The lack of `()` in the constructor call is intentional. The addition of type arguments is also needed so we have a KtCallExpression.
|
||||
// We want to test finding the symbol for a FirResolvedQualifier (and not a FirFunctionCall) whose source is a KtCallExpression
|
||||
// (and not a KtSimpleNameExpression).
|
||||
val t = <caret>Test<Int>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in ROOT) class Test<T>
|
||||
+6
@@ -378,6 +378,12 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest
|
||||
runTest("idea/idea-frontend-fir/testData/referenceResolve/ResolveClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ResolveClassNameInCallExpression.kt")
|
||||
public void testResolveClassNameInCallExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/referenceResolve/ResolveClassNameInCallExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ResolvePackageInProperty.kt")
|
||||
public void testResolvePackageInProperty() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user