FIR checker: more specific type for CONFLICTIONG_PROJECTION

This commit is contained in:
Jinseong Jeon
2021-05-10 15:24:30 -07:00
committed by teamcityserver
parent 8d474c0e7e
commit a3105da32e
7 changed files with 7 additions and 7 deletions
@@ -327,7 +327,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val ILLEGAL_PROJECTION_USAGE by error<PsiElement>()
val TYPE_PARAMETERS_IN_ENUM by error<PsiElement>()
val CONFLICTING_PROJECTION by error<PsiElement> {
parameter<String>("type") // TODO use ConeType instead of String
parameter<ConeKotlinType>("type")
}
val VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED by error<KtTypeParameter>(PositioningStrategy.VARIANCE_MODIFIER)
@@ -249,7 +249,7 @@ object FirErrors {
val TYPE_PARAMETERS_IN_OBJECT by error0<PsiElement>()
val ILLEGAL_PROJECTION_USAGE by error0<PsiElement>()
val TYPE_PARAMETERS_IN_ENUM by error0<PsiElement>()
val CONFLICTING_PROJECTION by error1<PsiElement, String>()
val CONFLICTING_PROJECTION by error1<PsiElement, ConeKotlinType>()
val VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED by error0<KtTypeParameter>(SourceElementPositioningStrategies.VARIANCE_MODIFIER)
val CATCH_PARAMETER_WITH_DEFAULT_VALUE by error0<PsiElement>()
val REIFIED_TYPE_IN_CATCH_CLAUSE by error0<PsiElement>()
@@ -66,7 +66,7 @@ object FirConflictingProjectionChecker : FirBasicDeclarationChecker() {
actual is ConeKotlinTypeProjectionIn && protoVariance == Variance.OUT_VARIANCE ||
actual is ConeKotlinTypeProjectionOut && protoVariance == Variance.IN_VARIANCE
) {
reporter.reportOn(typeRef.source, FirErrors.CONFLICTING_PROJECTION, typeRef.coneType.toString(), context)
reporter.reportOn(typeRef.source, FirErrors.CONFLICTING_PROJECTION, typeRef.coneType, context)
return
}
}
@@ -559,7 +559,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(
CONFLICTING_PROJECTION,
"Projection is conflicting with variance of the corresponding type parameter of {0}. Remove the projection or replace it with ''*''",
TO_STRING
RENDER_TYPE
)
map.put(
VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED,
@@ -1050,7 +1050,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
}
add(FirErrors.CONFLICTING_PROJECTION) { firDiagnostic ->
ConflictingProjectionImpl(
firDiagnostic.a,
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
@@ -743,7 +743,7 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract class ConflictingProjection : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = ConflictingProjection::class
abstract val type: String
abstract val type: KtType
}
abstract class VarianceOnTypeParameterNotAllowed : KtFirDiagnostic<KtTypeParameter>() {
@@ -1196,7 +1196,7 @@ internal class TypeParametersInEnumImpl(
}
internal class ConflictingProjectionImpl(
override val type: String,
override val type: KtType,
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.ConflictingProjection(), KtAbstractFirDiagnostic<PsiElement> {