Process FirErrorResolvedQualifiers in KtFirReferenceShortener
Also, add `classId` default value to the `FirErrorResolvedQualifierImpl` just as in `FirResolvedQualifierImpl` - it seemed inconsistent that we can have a class symbol in error-resolved qualifier, but the `classId` field will be `null`
This commit is contained in:
committed by
TeamCityServer
parent
f6e49776f8
commit
08e9a3bc4f
+7
-2
@@ -34,7 +34,6 @@ class FirErrorResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, Fi
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override lateinit var packageFqName: FqName
|
||||
override var relativeClassFqName: FqName? = null
|
||||
override var classId: ClassId? = null
|
||||
override var symbol: FirClassLikeSymbol<*>? = null
|
||||
override var isNullableLHSForCallableReference: Boolean = false
|
||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic> = mutableListOf()
|
||||
@@ -47,7 +46,6 @@ class FirErrorResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, Fi
|
||||
annotations,
|
||||
packageFqName,
|
||||
relativeClassFqName,
|
||||
classId,
|
||||
symbol,
|
||||
isNullableLHSForCallableReference,
|
||||
nonFatalDiagnostics,
|
||||
@@ -64,6 +62,13 @@ class FirErrorResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, Fi
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'classId' has no impact for FirErrorResolvedQualifierBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var classId: ClassId?
|
||||
get() = throw IllegalStateException()
|
||||
set(_) {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
|
||||
@Deprecated("Modification of 'resolvedToCompanionObject' has no impact for FirErrorResolvedQualifierBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override var resolvedToCompanionObject: Boolean
|
||||
get() = throw IllegalStateException()
|
||||
|
||||
+3
-1
@@ -27,7 +27,6 @@ internal class FirErrorResolvedQualifierImpl(
|
||||
override val annotations: MutableList<FirAnnotationCall>,
|
||||
override val packageFqName: FqName,
|
||||
override val relativeClassFqName: FqName?,
|
||||
override val classId: ClassId?,
|
||||
override val symbol: FirClassLikeSymbol<*>?,
|
||||
override var isNullableLHSForCallableReference: Boolean,
|
||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
||||
@@ -35,6 +34,9 @@ internal class FirErrorResolvedQualifierImpl(
|
||||
override val diagnostic: ConeDiagnostic,
|
||||
) : FirErrorResolvedQualifier() {
|
||||
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
|
||||
override val classId: ClassId? get() = relativeClassFqName?.let {
|
||||
ClassId(packageFqName, it, false)
|
||||
}
|
||||
override val resolvedToCompanionObject: Boolean get() = false
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
|
||||
+15
-8
@@ -276,14 +276,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(resolvedQualifier) {
|
||||
isMutable("packageFqName", "relativeClassFqName", "isNullableLHSForCallableReference")
|
||||
default("classId") {
|
||||
value = """
|
||||
|relativeClassFqName?.let {
|
||||
| ClassId(packageFqName, it, false)
|
||||
|}
|
||||
""".trimMargin()
|
||||
withGetter = true
|
||||
}
|
||||
defaultClassIdFromRelativeClassName()
|
||||
}
|
||||
|
||||
impl(resolvedReifiedParameterReference)
|
||||
@@ -495,6 +488,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(errorResolvedQualifier) {
|
||||
defaultFalse("resolvedToCompanionObject", withGetter = true)
|
||||
defaultClassIdFromRelativeClassName()
|
||||
}
|
||||
|
||||
noImpl(userTypeRef)
|
||||
@@ -574,4 +568,17 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
useTypes(implicitTypeRefType)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ImplementationContext.defaultClassIdFromRelativeClassName() {
|
||||
default("classId") {
|
||||
value = """
|
||||
|relativeClassFqName?.let {
|
||||
| ClassId(packageFqName, it, false)
|
||||
|}
|
||||
""".trimMargin()
|
||||
withGetter = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildImport
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
@@ -317,6 +318,12 @@ private class ElementsToShortenCollector(
|
||||
processTypeQualifier(resolvedQualifier)
|
||||
}
|
||||
|
||||
override fun visitErrorResolvedQualifier(errorResolvedQualifier: FirErrorResolvedQualifier) {
|
||||
super.visitErrorResolvedQualifier(errorResolvedQualifier)
|
||||
|
||||
processTypeQualifier(errorResolvedQualifier)
|
||||
}
|
||||
|
||||
override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) {
|
||||
super.visitResolvedNamedReference(resolvedNamedReference)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user