[Assign plugin] Use FqName to match annotations in FirAssignAnnotationMatchingService
All other compiler plugins accept "pkg1.pkg2.Class1" classes notation
and correctly match against it
But Assignment plugin used `ClassId` on such qualified names and got
`ClassId("/pkg1.pkg2.Class1")` instead of `ClassId("pkg1/pkg2/Class1")`,
and that lead to unexpected problems
This commit fixes that by using `FqName` instead of `ClassId`
^KT-57406 Fixed
This commit is contained in:
committed by
Space Team
parent
f035f80ad5
commit
4e0b68b516
+5
-5
@@ -15,16 +15,16 @@ import org.jetbrains.kotlin.fir.extensions.FirExtensionSessionComponent.Factory
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
internal class FirAssignAnnotationMatchingService(
|
||||
session: FirSession,
|
||||
private val annotationClassIds: List<ClassId>
|
||||
private val annotationClassIds: List<FqName>
|
||||
) : FirExtensionSessionComponent(session) {
|
||||
|
||||
companion object {
|
||||
fun getFactory(annotations: List<String>): Factory {
|
||||
return Factory { session -> FirAssignAnnotationMatchingService(session, annotations.map { ClassId.fromString(it) }) }
|
||||
return Factory { session -> FirAssignAnnotationMatchingService(session, annotations.map { FqName(it) }) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ internal class FirAssignAnnotationMatchingService(
|
||||
}
|
||||
|
||||
private fun FirRegularClassSymbol.annotated(): Boolean {
|
||||
if (this.annotations.any { it.toAnnotationClassId(session) in annotationClassIds }) return true
|
||||
if (this.annotations.any { it.toAnnotationClassId(session)?.asSingleFqName() in annotationClassIds }) return true
|
||||
return resolvedSuperTypeRefs.any { superTypeRef ->
|
||||
val symbol = superTypeRef.type.fullyExpandedType(session).toRegularClassSymbol(session) ?: return@any false
|
||||
symbol.annotations.any { it.toAnnotationClassId(session) in annotationClassIds }
|
||||
symbol.annotations.any { it.toAnnotationClassId(session)?.asSingleFqName() in annotationClassIds }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user