Skip to content

Commit

Permalink
Improve condition of nested inner class type fetching (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 authored Dec 16, 2023
1 parent 52af835 commit 22cae35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ public static String firElementToString(FirElement firElement) {
return printConeKotlinType(coneKotlinType);
} else if (firElement instanceof FirResolvedNamedReference) {
return ((FirResolvedNamedReference) firElement).getName().toString();
} else if (firElement instanceof FirResolvedQualifier) {
FirResolvedQualifier qualifier = (FirResolvedQualifier) firElement;
FqName fqName = qualifier.getRelativeClassFqName();
return fqName != null ? " RelativeClassFqName: " + fqName : "";
} else if (firElement instanceof FirFunctionCall) {
FirFunctionCall functionCall = (FirFunctionCall) firElement;
if (functionCall.getExplicitReceiver() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ class PsiElementAssociations(val typeMapping: KotlinTypeMapping, val file: FirFi

private fun matchClassId(psi: PsiElement, classId: ClassId): ClassId {
if (psi.parent is KtDotQualifiedExpression) {
val parts = psi.parent.text.split(".")
if (classId.packageFqName.isRoot && parts.size == 2 && psi.text == parts[0]) {
val parent: KtDotQualifiedExpression = psi.parent as KtDotQualifiedExpression
if (classId.packageFqName.isRoot && psi !is KtDotQualifiedExpression && psi == parent.receiverExpression) {
// Match the current PSI to the ClassId if the PSI is the outermost class of a dot qualified expression.
// For a multi-nested class like A.B.A.C, the PSI#parent field will have the same result (A.B) for both the LHS A and B.
// To match the PSI to the ClassId the outermost class `A` should use the current PSI rather than the parent field `A.B`.
Expand Down

0 comments on commit 22cae35

Please sign in to comment.