[FIR] Rename PLUGIN_ANNOTATION_AMBIGUITY to COMPILER_REQUIRED_ANNOTATION_AMBIGUITY
This diagnostic may be reported even without any compiler plugins (e.g. for annotation named `Target` or `Deprecated`), so the old name and message were quite confusing ^KT-64654
This commit is contained in:
committed by
Space Team
parent
5728b34733
commit
56221467ff
+2
-2
@@ -1154,8 +1154,8 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
|||||||
token,
|
token,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
add(FirErrors.PLUGIN_ANNOTATION_AMBIGUITY) { firDiagnostic ->
|
add(FirErrors.COMPILER_REQUIRED_ANNOTATION_AMBIGUITY) { firDiagnostic ->
|
||||||
PluginAnnotationAmbiguityImpl(
|
CompilerRequiredAnnotationAmbiguityImpl(
|
||||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
|
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
|
||||||
firDiagnostic as KtPsiDiagnostic,
|
firDiagnostic as KtPsiDiagnostic,
|
||||||
|
|||||||
+2
-2
@@ -839,8 +839,8 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
|||||||
override val diagnosticClass get() = AnnotationInWhereClauseError::class
|
override val diagnosticClass get() = AnnotationInWhereClauseError::class
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PluginAnnotationAmbiguity : KtFirDiagnostic<PsiElement> {
|
interface CompilerRequiredAnnotationAmbiguity : KtFirDiagnostic<PsiElement> {
|
||||||
override val diagnosticClass get() = PluginAnnotationAmbiguity::class
|
override val diagnosticClass get() = CompilerRequiredAnnotationAmbiguity::class
|
||||||
val typeFromCompilerPhase: KtType
|
val typeFromCompilerPhase: KtType
|
||||||
val typeFromTypesPhase: KtType
|
val typeFromTypesPhase: KtType
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1004,12 +1004,12 @@ internal class AnnotationInWhereClauseErrorImpl(
|
|||||||
token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
) : KtAbstractFirDiagnostic<KtAnnotationEntry>(firDiagnostic, token), KtFirDiagnostic.AnnotationInWhereClauseError
|
) : KtAbstractFirDiagnostic<KtAnnotationEntry>(firDiagnostic, token), KtFirDiagnostic.AnnotationInWhereClauseError
|
||||||
|
|
||||||
internal class PluginAnnotationAmbiguityImpl(
|
internal class CompilerRequiredAnnotationAmbiguityImpl(
|
||||||
override val typeFromCompilerPhase: KtType,
|
override val typeFromCompilerPhase: KtType,
|
||||||
override val typeFromTypesPhase: KtType,
|
override val typeFromTypesPhase: KtType,
|
||||||
firDiagnostic: KtPsiDiagnostic,
|
firDiagnostic: KtPsiDiagnostic,
|
||||||
token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.PluginAnnotationAmbiguity
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.CompilerRequiredAnnotationAmbiguity
|
||||||
|
|
||||||
internal class AmbiguousAnnotationArgumentImpl(
|
internal class AmbiguousAnnotationArgumentImpl(
|
||||||
override val symbols: List<KtSymbol>,
|
override val symbols: List<KtSymbol>,
|
||||||
|
|||||||
+1
-1
@@ -385,7 +385,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
|||||||
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING by warning<KtAnnotationEntry>()
|
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING by warning<KtAnnotationEntry>()
|
||||||
val ANNOTATION_IN_WHERE_CLAUSE_ERROR by error<KtAnnotationEntry>()
|
val ANNOTATION_IN_WHERE_CLAUSE_ERROR by error<KtAnnotationEntry>()
|
||||||
|
|
||||||
val PLUGIN_ANNOTATION_AMBIGUITY by error<PsiElement> {
|
val COMPILER_REQUIRED_ANNOTATION_AMBIGUITY by error<PsiElement> {
|
||||||
parameter<ConeKotlinType>("typeFromCompilerPhase")
|
parameter<ConeKotlinType>("typeFromCompilerPhase")
|
||||||
parameter<ConeKotlinType>("typeFromTypesPhase")
|
parameter<ConeKotlinType>("typeFromTypesPhase")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -303,7 +303,7 @@ object FirErrors {
|
|||||||
val WRONG_EXTENSION_FUNCTION_TYPE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
val WRONG_EXTENSION_FUNCTION_TYPE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
||||||
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING: KtDiagnosticFactory0 by warning0<KtAnnotationEntry>()
|
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING: KtDiagnosticFactory0 by warning0<KtAnnotationEntry>()
|
||||||
val ANNOTATION_IN_WHERE_CLAUSE_ERROR: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
val ANNOTATION_IN_WHERE_CLAUSE_ERROR: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
||||||
val PLUGIN_ANNOTATION_AMBIGUITY: KtDiagnosticFactory2<ConeKotlinType, ConeKotlinType> by error2<PsiElement, ConeKotlinType, ConeKotlinType>()
|
val COMPILER_REQUIRED_ANNOTATION_AMBIGUITY: KtDiagnosticFactory2<ConeKotlinType, ConeKotlinType> by error2<PsiElement, ConeKotlinType, ConeKotlinType>()
|
||||||
val AMBIGUOUS_ANNOTATION_ARGUMENT: KtDiagnosticFactory1<List<FirBasedSymbol<*>>> by error1<PsiElement, List<FirBasedSymbol<*>>>()
|
val AMBIGUOUS_ANNOTATION_ARGUMENT: KtDiagnosticFactory1<List<FirBasedSymbol<*>>> by error1<PsiElement, List<FirBasedSymbol<*>>>()
|
||||||
val VOLATILE_ON_VALUE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
val VOLATILE_ON_VALUE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
||||||
val VOLATILE_ON_DELEGATE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
val VOLATILE_ON_DELEGATE: KtDiagnosticFactory0 by error0<KtAnnotationEntry>()
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(
|
|||||||
"NOT_A_CLASS",
|
"NOT_A_CLASS",
|
||||||
"WRONG_EXTENSION_FUNCTION_TYPE",
|
"WRONG_EXTENSION_FUNCTION_TYPE",
|
||||||
"ANNOTATION_IN_WHERE_CLAUSE_ERROR",
|
"ANNOTATION_IN_WHERE_CLAUSE_ERROR",
|
||||||
"PLUGIN_ANNOTATION_AMBIGUITY",
|
"COMPILER_REQUIRED_ANNOTATION_AMBIGUITY",
|
||||||
"AMBIGUOUS_ANNOTATION_ARGUMENT",
|
"AMBIGUOUS_ANNOTATION_ARGUMENT",
|
||||||
"VOLATILE_ON_VALUE",
|
"VOLATILE_ON_VALUE",
|
||||||
"VOLATILE_ON_DELEGATE",
|
"VOLATILE_ON_DELEGATE",
|
||||||
|
|||||||
+3
-3
@@ -500,7 +500,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OVERRIDING_FINAL_
|
|||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PACKAGE_CANNOT_BE_IMPORTED
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PACKAGE_CANNOT_BE_IMPORTED
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PACKAGE_OR_CLASSIFIER_REDECLARATION
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PACKAGE_OR_CLASSIFIER_REDECLARATION
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PLATFORM_CLASS_MAPPED_TO_KOTLIN
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PLATFORM_CLASS_MAPPED_TO_KOTLIN
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PLUGIN_ANNOTATION_AMBIGUITY
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.COMPILER_REQUIRED_ANNOTATION_AMBIGUITY
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.POTENTIALLY_NON_REPORTED_ANNOTATION
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.POTENTIALLY_NON_REPORTED_ANNOTATION
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRE_RELEASE_CLASS
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRE_RELEASE_CLASS
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED
|
||||||
@@ -1110,8 +1110,8 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
|||||||
"Type parameter annotations are prohibited inside 'where' clauses. You should probably move the annotations to the type parameter declaration.",
|
"Type parameter annotations are prohibited inside 'where' clauses. You should probably move the annotations to the type parameter declaration.",
|
||||||
)
|
)
|
||||||
map.put(
|
map.put(
|
||||||
PLUGIN_ANNOTATION_AMBIGUITY,
|
COMPILER_REQUIRED_ANNOTATION_AMBIGUITY,
|
||||||
"Resolution of the annotation type is ambiguous between ''{1}'' and the plugin annotation ''{0}''. Please specify a fully qualified annotation name.",
|
"Resolution of the annotation type is ambiguous between ''{1}'' and the compiler-required annotation ''{0}''. Please specify a fully qualified annotation name.",
|
||||||
RENDER_TYPE,
|
RENDER_TYPE,
|
||||||
RENDER_TYPE
|
RENDER_TYPE
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-2
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isLocalMember
|
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isLocalMember
|
||||||
import org.jetbrains.kotlin.fir.analysis.getChild
|
import org.jetbrains.kotlin.fir.analysis.getChild
|
||||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.*
|
import org.jetbrains.kotlin.fir.diagnostics.*
|
||||||
@@ -182,7 +181,7 @@ private fun ConeDiagnostic.toKtDiagnostic(
|
|||||||
is ConeUnresolvedParentInImport -> null // reported in FirUnresolvedImportChecker
|
is ConeUnresolvedParentInImport -> null // reported in FirUnresolvedImportChecker
|
||||||
is ConeAmbiguousAlteredAssign -> FirErrors.AMBIGUOUS_ALTERED_ASSIGN.createOn(source, this.altererNames)
|
is ConeAmbiguousAlteredAssign -> FirErrors.AMBIGUOUS_ALTERED_ASSIGN.createOn(source, this.altererNames)
|
||||||
is ConeAmbiguouslyResolvedAnnotationFromPlugin -> {
|
is ConeAmbiguouslyResolvedAnnotationFromPlugin -> {
|
||||||
FirErrors.PLUGIN_ANNOTATION_AMBIGUITY.createOn(source, typeFromCompilerPhase, typeFromTypesPhase)
|
FirErrors.COMPILER_REQUIRED_ANNOTATION_AMBIGUITY.createOn(source, typeFromCompilerPhase, typeFromTypesPhase)
|
||||||
}
|
}
|
||||||
is ConeAmbiguouslyResolvedAnnotationArgument ->
|
is ConeAmbiguouslyResolvedAnnotationArgument ->
|
||||||
FirErrors.AMBIGUOUS_ANNOTATION_ARGUMENT.createOn(source, listOfNotNull(symbolFromCompilerPhase, symbolFromAnnotationArgumentsPhase))
|
FirErrors.AMBIGUOUS_ANNOTATION_ARGUMENT.createOn(source, listOfNotNull(symbolFromCompilerPhase, symbolFromAnnotationArgumentsPhase))
|
||||||
|
|||||||
compiler/testData/diagnostics/testsWithStdLib/annotations/annotationTargetResolvedAmbiguously.fir.kt
Vendored
+1
-1
@@ -36,7 +36,7 @@ abstract class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Derived : Base() {
|
class Derived : Base() {
|
||||||
@<!PLUGIN_ANNOTATION_AMBIGUITY!>Target<!>(<!ARGUMENT_TYPE_MISMATCH!>AnnotationTarget.<!AMBIGUOUS_ANNOTATION_ARGUMENT!>TYPE<!><!>)
|
@<!COMPILER_REQUIRED_ANNOTATION_AMBIGUITY!>Target<!>(<!ARGUMENT_TYPE_MISMATCH!>AnnotationTarget.<!AMBIGUOUS_ANNOTATION_ARGUMENT!>TYPE<!><!>)
|
||||||
annotation class Ann
|
annotation class Ann
|
||||||
|
|
||||||
fun foo(x: <!WRONG_ANNOTATION_TARGET!>@Ann<!> String) {}
|
fun foo(x: <!WRONG_ANNOTATION_TARGET!>@Ann<!> String) {}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ open class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Derived : Base() {
|
class Derived : Base() {
|
||||||
@<!PLUGIN_ANNOTATION_AMBIGUITY!>Open<!> // should be an error
|
@<!COMPILER_REQUIRED_ANNOTATION_AMBIGUITY!>Open<!> // should be an error
|
||||||
@Ann // should be ok
|
@Ann // should be ok
|
||||||
class ShouldBeFinal
|
class ShouldBeFinal
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user