[LL FIR] add missed ClassId check for combined Java classes symbol provider

findClasses works over regular `PsiElementFinder`, which doesn't know
about out ClassId conception. So, `a/b/A.B` and `a/b/A/B` are the same
from `FqName` point of view.
`FirJavaFacade` has this check, so this problem appears only in the case
of combined provider.

^KT-62892 Fixed
This commit is contained in:
Dmitrii Gridin
2024-01-03 15:53:29 +01:00
committed by Space Team
parent a39688ba10
commit 2bad2f37ce
10 changed files with 10 additions and 25 deletions
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtDotQualifiedExpression at (17,25-54)
ARGUMENT_TYPE_MISMATCH text ranges: [(169,198)]
PSI: KtDotQualifiedExpression at (17,25-54)
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtDotQualifiedExpression at (19,25-54)
ARGUMENT_TYPE_MISMATCH text ranges: [(171,200)]
PSI: KtDotQualifiedExpression at (19,25-54)
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtDotQualifiedExpression at (17,25-52)
ARGUMENT_TYPE_MISMATCH text ranges: [(169,196)]
PSI: KtDotQualifiedExpression at (17,25-52)
@@ -1,4 +1 @@
Diagnostics from elements:
for PSI element of type KtDotQualifiedExpression at (19,25-52)
ARGUMENT_TYPE_MISMATCH text ranges: [(171,198)]
PSI: KtDotQualifiedExpression at (19,25-52)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -8,18 +8,17 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.providers
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analysis.low.level.api.fir.caches.NullableCaffeineCache
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.llFirModuleData
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
import org.jetbrains.kotlin.fir.java.hasMetadataAnnotation
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProvider
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProviderWithoutCallables
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.load.java.JavaClassFinder
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.createJavaClassFinder
import org.jetbrains.kotlin.load.java.structure.classId
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
@@ -61,8 +60,10 @@ internal class LLFirCombinedJavaSymbolProvider private constructor(
classCache.get(classId) { computeClassLikeSymbolByClassId(it) }
private fun computeClassLikeSymbolByClassId(classId: ClassId): FirRegularClassSymbol? {
val javaClasses = javaClassFinder.findClasses(classId)
.filterNot { javaClass -> javaClass.annotations.any { it.isResolvedTo(JvmAnnotationNames.METADATA_FQ_NAME) } }
val javaClasses = javaClassFinder.findClasses(classId).filterNot { javaClass ->
javaClass.classId != classId || javaClass.hasMetadataAnnotation()
}
if (javaClasses.isEmpty()) return null
val (javaClass, provider) = selectFirstElementInClasspathOrder(javaClasses) { javaClass ->
@@ -3,11 +3,11 @@ FIR element: FirResolvedTypeRefImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
R|issue/pack/RowIcon/RClass|
R|issue/pack/RowIcon.RClass|
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] usage.kt
package usage
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] fun testJavaNestedClass([ResolvedTo(ANNOTATION_ARGUMENTS)] alignment: R|issue/pack/RowIcon/RClass|): R|kotlin/Unit| {
}
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] fun testJavaNestedClass([ResolvedTo(ANNOTATION_ARGUMENTS)] alignment: R|issue/pack/RowIcon.RClass|): R|kotlin/Unit| {
}