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())
|
qualifiedAccessExpression.replaceContextReceiverArguments(subCandidate.contextReceiverArguments())
|
||||||
|
|
||||||
if (qualifiedAccessExpression is FirPropertyAccessExpressionImpl && calleeReference.candidate.currentApplicability == CandidateApplicability.K2_PROPERTY_AS_OPERATOR) {
|
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) {
|
if (qualifiedAccessExpression is FirQualifiedAccessExpression) {
|
||||||
|
|||||||
+2
@@ -56,6 +56,8 @@ abstract class FirPropertyAccessExpression : FirQualifiedAccessExpression() {
|
|||||||
|
|
||||||
abstract override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression)
|
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> transformAnnotations(transformer: FirTransformer<D>, data: D): FirPropertyAccessExpression
|
||||||
|
|
||||||
abstract override fun <D> transformCalleeReference(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,
|
relativeClassFqName,
|
||||||
symbol,
|
symbol,
|
||||||
isNullableLHSForCallableReference,
|
isNullableLHSForCallableReference,
|
||||||
nonFatalDiagnostics,
|
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||||
typeArguments,
|
typeArguments,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ class FirPropertyAccessExpressionBuilder : FirQualifiedAccessBuilder, FirAnnotat
|
|||||||
explicitReceiver,
|
explicitReceiver,
|
||||||
dispatchReceiver,
|
dispatchReceiver,
|
||||||
extensionReceiver,
|
extensionReceiver,
|
||||||
nonFatalDiagnostics,
|
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ class FirResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, FirAnno
|
|||||||
relativeClassFqName,
|
relativeClassFqName,
|
||||||
symbol,
|
symbol,
|
||||||
isNullableLHSForCallableReference,
|
isNullableLHSForCallableReference,
|
||||||
nonFatalDiagnostics,
|
nonFatalDiagnostics.toMutableOrEmpty(),
|
||||||
typeArguments,
|
typeArguments,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ internal class FirErrorResolvedQualifierImpl(
|
|||||||
override val relativeClassFqName: FqName?,
|
override val relativeClassFqName: FqName?,
|
||||||
override val symbol: FirClassLikeSymbol<*>?,
|
override val symbol: FirClassLikeSymbol<*>?,
|
||||||
override var isNullableLHSForCallableReference: Boolean,
|
override var isNullableLHSForCallableReference: Boolean,
|
||||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||||
override val typeArguments: MutableList<FirTypeProjection>,
|
override val typeArguments: MutableList<FirTypeProjection>,
|
||||||
override val diagnostic: ConeDiagnostic,
|
override val diagnostic: ConeDiagnostic,
|
||||||
) : FirErrorResolvedQualifier() {
|
) : FirErrorResolvedQualifier() {
|
||||||
|
|||||||
+5
-1
@@ -35,7 +35,7 @@ class FirPropertyAccessExpressionImpl @FirImplementationDetail constructor(
|
|||||||
override var explicitReceiver: FirExpression?,
|
override var explicitReceiver: FirExpression?,
|
||||||
override var dispatchReceiver: FirExpression,
|
override var dispatchReceiver: FirExpression,
|
||||||
override var extensionReceiver: FirExpression,
|
override var extensionReceiver: FirExpression,
|
||||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||||
) : FirPropertyAccessExpression() {
|
) : FirPropertyAccessExpression() {
|
||||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||||
typeRef.accept(visitor, data)
|
typeRef.accept(visitor, data)
|
||||||
@@ -126,4 +126,8 @@ class FirPropertyAccessExpressionImpl @FirImplementationDetail constructor(
|
|||||||
override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression) {
|
override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression) {
|
||||||
extensionReceiver = newExtensionReceiver
|
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 var relativeClassFqName: FqName?,
|
||||||
override val symbol: FirClassLikeSymbol<*>?,
|
override val symbol: FirClassLikeSymbol<*>?,
|
||||||
override var isNullableLHSForCallableReference: Boolean,
|
override var isNullableLHSForCallableReference: Boolean,
|
||||||
override val nonFatalDiagnostics: MutableList<ConeDiagnostic>,
|
override var nonFatalDiagnostics: MutableOrEmptyList<ConeDiagnostic>,
|
||||||
override val typeArguments: MutableList<FirTypeProjection>,
|
override val typeArguments: MutableList<FirTypeProjection>,
|
||||||
) : FirResolvedQualifier() {
|
) : FirResolvedQualifier() {
|
||||||
override val classId: ClassId? get() = relativeClassFqName?.let {
|
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.typeRefField
|
||||||
import org.jetbrains.kotlin.fir.tree.generator.FieldSets.visibility
|
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.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.AbstractFirTreeBuilder.Companion.baseFirElement
|
||||||
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
||||||
import org.jetbrains.kotlin.fir.tree.generator.model.*
|
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) {
|
object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuilder) {
|
||||||
fun configureFields() = configure {
|
fun configureFields() = configure {
|
||||||
AbstractFirTreeBuilder.baseFirElement.configure {
|
baseFirElement.configure {
|
||||||
+field("source", sourceElementType, nullable = true)
|
+field("source", sourceElementType, nullable = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +212,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
}
|
}
|
||||||
|
|
||||||
propertyAccessExpression.configure {
|
propertyAccessExpression.configure {
|
||||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType)
|
+fieldList("nonFatalDiagnostics", coneDiagnosticType, useMutableOrEmpty = true, withReplace = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
qualifiedErrorAccessExpression.configure {
|
qualifiedErrorAccessExpression.configure {
|
||||||
@@ -267,7 +266,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
|
|
||||||
classLikeDeclaration.configure {
|
classLikeDeclaration.configure {
|
||||||
+symbol("FirClassLikeSymbol", "out FirClassLikeDeclaration")
|
+symbol("FirClassLikeSymbol", "out FirClassLikeDeclaration")
|
||||||
+field("deprecationsProvider", deprecationsProviderType).withReplace().apply { isMutable = true}
|
+field("deprecationsProvider", deprecationsProviderType).withReplace().apply { isMutable = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
klass.configure {
|
klass.configure {
|
||||||
@@ -591,7 +590,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
+field("symbol", classLikeSymbolType, nullable = true)
|
+field("symbol", classLikeSymbolType, nullable = true)
|
||||||
+booleanField("isNullableLHSForCallableReference", withReplace = true)
|
+booleanField("isNullableLHSForCallableReference", withReplace = true)
|
||||||
+booleanField("resolvedToCompanionObject", withReplace = true)
|
+booleanField("resolvedToCompanionObject", withReplace = true)
|
||||||
+fieldList("nonFatalDiagnostics", coneDiagnosticType)
|
+fieldList("nonFatalDiagnostics", coneDiagnosticType, useMutableOrEmpty = true)
|
||||||
+typeArguments.withTransform()
|
+typeArguments.withTransform()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,6 +732,8 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
|
|
||||||
fun Element.withArgs(vararg replacements: Pair<String, String>): AbstractElement {
|
fun Element.withArgs(vararg replacements: Pair<String, String>): AbstractElement {
|
||||||
val replaceMap = replacements.toMap()
|
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)
|
return ElementWithArguments(this, newArguments)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user