HL API: Handle resolve case when source for FirResolvedQualifier is a

KtCallExpression.
This commit is contained in:
Mark Punzalan
2021-08-28 06:40:47 +00:00
committed by Ilya Kirillov
parent cba77452f3
commit c2529a4abb
4 changed files with 17 additions and 6 deletions
@@ -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
@@ -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>
@@ -0,0 +1,2 @@
Resolved to:
0: (in ROOT) class Test<T>
@@ -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 {