K2: drop unused qualifier in FirJavaTypeRef
This commit is contained in:
committed by
Space Team
parent
e9fbeb9be2
commit
f33f87e3d4
@@ -119,7 +119,7 @@ abstract class FirJavaFacade(
|
||||
}
|
||||
}.apply {
|
||||
// TODO: should be lazy (in case annotations refer to the containing class)
|
||||
addAnnotationsFromJava(session, this@toFirTypeParameter, javaTypeParameterStack)
|
||||
setAnnotationsFromJava(session, this@toFirTypeParameter, javaTypeParameterStack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ abstract class FirJavaFacade(
|
||||
// 1. Resolve annotations
|
||||
// 2. Enhance type parameter bounds - may refer to each other, take default nullability from annotations
|
||||
// 3. Enhance super types - may refer to type parameter bounds, take default nullability from annotations
|
||||
firJavaClass.addAnnotationsFromJava(session, javaClass, javaTypeParameterStack)
|
||||
firJavaClass.setAnnotationsFromJava(session, javaClass, javaTypeParameterStack)
|
||||
|
||||
enhancement.enhanceTypeParameterBoundsAfterFirstRound(firJavaClass.typeParameters, initialBounds)
|
||||
|
||||
@@ -515,7 +515,7 @@ abstract class FirJavaFacade(
|
||||
}.apply {
|
||||
containingClassForStaticMemberAttr = ConeClassLikeLookupTagImpl(classId)
|
||||
// TODO: check if this works properly with annotations that take the enum class as an argument
|
||||
addAnnotationsFromJava(session, javaField, javaTypeParameterStack)
|
||||
setAnnotationsFromJava(session, javaField, javaTypeParameterStack)
|
||||
}
|
||||
else -> buildJavaField {
|
||||
source = javaField.toSourceElement()
|
||||
|
||||
@@ -49,7 +49,7 @@ internal fun JavaAnnotationOwner.convertAnnotationsToFir(
|
||||
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack
|
||||
): List<FirAnnotation> = annotations.convertAnnotationsToFir(session, javaTypeParameterStack)
|
||||
|
||||
internal fun FirAnnotationContainer.addAnnotationsFromJava(
|
||||
internal fun FirAnnotationContainer.setAnnotationsFromJava(
|
||||
session: FirSession,
|
||||
javaAnnotationOwner: JavaAnnotationOwner,
|
||||
javaTypeParameterStack: JavaTypeParameterStack
|
||||
|
||||
@@ -21,8 +21,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaType
|
||||
|
||||
class FirJavaTypeRef(
|
||||
val type: JavaType,
|
||||
annotationBuilder: () -> List<FirAnnotation>,
|
||||
override val qualifier: MutableList<FirQualifierPart>
|
||||
annotationBuilder: () -> List<FirAnnotation>
|
||||
) : FirUserTypeRef() {
|
||||
override val customRenderer: Boolean
|
||||
get() = true
|
||||
@@ -35,6 +34,9 @@ class FirJavaTypeRef(
|
||||
|
||||
override val annotations: List<FirAnnotation> by lazy { annotationBuilder() }
|
||||
|
||||
override val qualifier: List<FirQualifierPart>
|
||||
get() = emptyList()
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
for (part in qualifier) {
|
||||
part.typeArgumentList.typeArguments.forEach { it.accept(visitor, data) }
|
||||
@@ -66,10 +68,9 @@ class FirJavaTypeRef(
|
||||
class FirJavaTypeRefBuilder {
|
||||
lateinit var annotationBuilder: () -> List<FirAnnotation>
|
||||
lateinit var type: JavaType
|
||||
val qualifier: MutableList<FirQualifierPart> = mutableListOf()
|
||||
|
||||
fun build(): FirJavaTypeRef {
|
||||
return FirJavaTypeRef(type, annotationBuilder, qualifier)
|
||||
return FirJavaTypeRef(type, annotationBuilder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -701,10 +701,11 @@ open class RawFirBuilder(
|
||||
|
||||
private fun KtAnnotated.extractAnnotationsTo(container: FirAnnotationContainer) {
|
||||
if (annotationEntries.isEmpty()) return
|
||||
val annotations = mutableListOf<FirAnnotation>()
|
||||
annotations.addAll(container.annotations)
|
||||
for (annotationEntry in annotationEntries) {
|
||||
annotations += annotationEntry.convert<FirAnnotation>()
|
||||
val annotations = buildList {
|
||||
addAll(container.annotations)
|
||||
for (annotationEntry in annotationEntries) {
|
||||
add(annotationEntry.convert<FirAnnotation>())
|
||||
}
|
||||
}
|
||||
container.replaceAnnotations(annotations)
|
||||
}
|
||||
|
||||
+4
-1
@@ -39,7 +39,10 @@ object FieldSets {
|
||||
|
||||
val annotations by lazy {
|
||||
fieldList(
|
||||
"annotations", annotation, withReplace = true, useMutableOrEmpty = true
|
||||
"annotations",
|
||||
annotation,
|
||||
withReplace = true,
|
||||
useMutableOrEmpty = true
|
||||
).withTransform(needTransformInOtherChildren = true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user