K2: use MutableOrEmptyList for nonFatalDiagnostics
This commit is contained in:
committed by
Space Team
parent
582b640bec
commit
dff71a9602
+6
-1
@@ -139,7 +139,12 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
qualifiedAccessExpression.replaceContextReceiverArguments(subCandidate.contextReceiverArguments())
|
||||
|
||||
if (qualifiedAccessExpression is FirPropertyAccessExpressionImpl && calleeReference.candidate.currentApplicability == CandidateApplicability.K2_PROPERTY_AS_OPERATOR) {
|
||||
qualifiedAccessExpression.nonFatalDiagnostics.add(ConePropertyAsOperator(calleeReference.candidate.symbol as FirPropertySymbol))
|
||||
val conePropertyAsOperator = ConePropertyAsOperator(calleeReference.candidate.symbol as FirPropertySymbol)
|
||||
val nonFatalDiagnostics: List<ConeDiagnostic> = buildList {
|
||||
addAll(qualifiedAccessExpression.nonFatalDiagnostics)
|
||||
add(conePropertyAsOperator)
|
||||
}
|
||||
qualifiedAccessExpression.replaceNonFatalDiagnostics(nonFatalDiagnostics)
|
||||
}
|
||||
|
||||
if (qualifiedAccessExpression is FirQualifiedAccessExpression) {
|
||||
|
||||
+2
@@ -56,6 +56,8 @@ abstract class FirPropertyAccessExpression : FirQualifiedAccessExpression() {
|
||||
|
||||
abstract override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression)
|
||||
|
||||
abstract fun replaceNonFatalDiagnostics(newNonFatalDiagnostics: List<ConeDiagnostic>)
|
||||
|
||||
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirPropertyAccessExpression
|
||||
|
||||
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirPropertyAccessExpression
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class FirErrorResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, Fi
|
||||
relativeClassFqName,
|
||||
symbol,
|
||||
isNullableLHSForCallableReference,
|
||||
nonFatalDiagnostics,
|
||||
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||
typeArguments,
|
||||
diagnostic,
|
||||
)
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class FirPropertyAccessExpressionBuilder : FirQualifiedAccessBuilder, FirAnnotat
|
||||
explicitReceiver,
|
||||
dispatchReceiver,
|
||||
extensionReceiver,
|
||||
nonFatalDiagnostics,
|
||||
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class FirResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, FirAnno
|
||||
relativeClassFqName,
|
||||
symbol,
|
||||
isNullableLHSForCallableReference,
|
||||
nonFatalDiagnostics,
|
||||
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||
typeArguments,
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ internal class FirErrorResolvedQualifierImpl(
|
||||
override val relativeClassFqName: FqName?,
|
||||
override val symbol: FirClassLikeSymbol<*>?,
|
||||
override var isNullableLHSForCallableReference: Boolean,
|
||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
||||
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||
override val typeArguments: MutableList<FirTypeProjection>,
|
||||
override val diagnostic: ConeDiagnostic,
|
||||
) : FirErrorResolvedQualifier() {
|
||||
|
||||
+5
-1
@@ -35,7 +35,7 @@ class FirPropertyAccessExpressionImpl @FirImplementationDetail constructor(
|
||||
override var explicitReceiver: FirExpression?,
|
||||
override var dispatchReceiver: FirExpression,
|
||||
override var extensionReceiver: FirExpression,
|
||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
||||
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||
) : FirPropertyAccessExpression() {
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
typeRef.accept(visitor, data)
|
||||
@@ -126,4 +126,8 @@ class FirPropertyAccessExpressionImpl @FirImplementationDetail constructor(
|
||||
override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression) {
|
||||
extensionReceiver = newExtensionReceiver
|
||||
}
|
||||
|
||||
override fun replaceNonFatalDiagnostics(newNonFatalDiagnostics: List<ConeDiagnostic>) {
|
||||
nonFatalDiagnostics = newNonFatalDiagnostics.toMutableOrEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ internal class FirResolvedQualifierImpl(
|
||||
override var relativeClassFqName: FqName?,
|
||||
override val symbol: FirClassLikeSymbol<*>?,
|
||||
override var isNullableLHSForCallableReference: Boolean,
|
||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
||||
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||
override val typeArguments: MutableList<FirTypeProjection>,
|
||||
) : FirResolvedQualifier() {
|
||||
override val classId: ClassId? get() = relativeClassFqName?.let {
|
||||
|
||||
+7
-6
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.fir.tree.generator.FieldSets.typeParameters
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.typeRefField
|
||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.visibility
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFieldConfigurator
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder.Companion.baseFirElement
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.*
|
||||
@@ -38,7 +37,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
|
||||
object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuilder) {
|
||||
fun configureFields() = configure {
|
||||
AbstractFirTreeBuilder.baseFirElement.configure {
|
||||
baseFirElement.configure {
|
||||
+field("source", sourceElementType, nullable = true)
|
||||
}
|
||||
|
||||
@@ -213,7 +212,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
}
|
||||
|
||||
propertyAccessExpression.configure {
|
||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType)
|
||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType, useMutableOrEmpty = true, withReplace = true)
|
||||
}
|
||||
|
||||
qualifiedErrorAccessExpression.configure {
|
||||
@@ -267,7 +266,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
|
||||
classLikeDeclaration.configure {
|
||||
+symbol("FirClassLikeSymbol", "out FirClassLikeDeclaration")
|
||||
+field("deprecationsProvider", deprecationsProviderType).withReplace().apply { isMutable = true}
|
||||
+field("deprecationsProvider", deprecationsProviderType).withReplace().apply { isMutable = true }
|
||||
}
|
||||
|
||||
klass.configure {
|
||||
@@ -591,7 +590,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
+field("symbol", classLikeSymbolType, nullable = true)
|
||||
+booleanField("isNullableLHSForCallableReference", withReplace = true)
|
||||
+booleanField("resolvedToCompanionObject", withReplace = true)
|
||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType)
|
||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType, useMutableOrEmpty = true)
|
||||
+typeArguments.withTransform()
|
||||
}
|
||||
|
||||
@@ -733,6 +732,8 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
|
||||
fun Element.withArgs(vararg replacements: Pair<String, String>): AbstractElement {
|
||||
val replaceMap = replacements.toMap()
|
||||
val newArguments = typeArguments.map { replaceMap[it.name]?.let { SimpleTypeArgument(it, null) } ?: it }
|
||||
val newArguments = typeArguments.map { typeArgument ->
|
||||
replaceMap[typeArgument.name]?.let { SimpleTypeArgument(it, null) } ?: typeArgument
|
||||
}
|
||||
return ElementWithArguments(this, newArguments)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user