diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 8cc23620c9e..74379992d27 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -159,9 +159,9 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error() val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error() - val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error() - val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error() - val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error() + val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) + val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) + val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) } val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index d5fa41b192e..fb931d76616 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -165,9 +165,9 @@ object FirErrors { val NEWER_VERSION_IN_SINCE_KOTLIN by warning1() val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error0() val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error0() - val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error0() - val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error0() - val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error0() + val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error0(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED) + val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error0(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED) + val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error0(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED) // Exposed visibility val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3(SourceElementPositioningStrategies.DECLARATION_NAME) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt index b14e73f336d..b42ad46b5d9 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.argumentMapping import org.jetbrains.kotlin.fir.resolve.fqName import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.StandardClassIds object FirAnnotationChecker : FirAnnotatedDeclarationChecker() { private val deprecatedClassId = FqName("kotlin.Deprecated") @@ -40,33 +41,27 @@ object FirAnnotationChecker : FirAnnotatedDeclarationChecker() { if (deprecatedSinceKotlinCall != null) { val closestFirFile = context.findClosest() - if (closestFirFile != null) { - val packageName = closestFirFile.packageFqName.asString() - if (packageName != "kotlin" && !packageName.startsWith("kotlin.")) { - reporter.reportOn( - deprecatedSinceKotlinCall.source, - FirErrors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE, - context - ) - } + if (closestFirFile != null && !closestFirFile.packageFqName.startsWith(StandardClassIds.BASE_KOTLIN_PACKAGE.shortName())) { + reporter.reportOn( + deprecatedSinceKotlinCall.source, + FirErrors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE, + context + ) } if (deprecatedCall == null) { reporter.reportOn(deprecatedSinceKotlinCall.source, FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, context) } else { val argumentMapping = deprecatedCall.argumentMapping ?: return - var report = false - for ((_, value) in argumentMapping) { - report = value.name.identifier == "level" - if (report) + for (value in argumentMapping.values) { + if (value.name.identifier == "level") { + reporter.reportOn( + deprecatedSinceKotlinCall.source, + FirErrors.DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, + context + ) break - } - if (report) { - reporter.reportOn( - deprecatedSinceKotlinCall.source, - FirErrors.DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, - context - ) + } } } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index 892c24ce5b7..c2b7e705e2e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -501,6 +501,15 @@ object LightTreePositioningStrategies { if (node.tokenType == KtNodeTypes.PROPERTY_DELEGATE) { return markElement(tree.findExpressionDeep(node) ?: node, startOffset, endOffset, tree, node) } + if (node.tokenType == KtNodeTypes.ANNOTATION_ENTRY) { + return markElement( + tree.findDescendantByType(node, KtNodeTypes.CONSTRUCTOR_CALLEE) ?: node, + startOffset, + endOffset, + tree, + node + ) + } if (node.tokenType in nodeTypesWithOperation) { return markElement(tree.operationReference(node) ?: node, startOffset, endOffset, tree, node) } diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt index 1bb14470517..a478c46a14d 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.syntax.FirAnonymousFunctionSyn object CommonExpressionCheckers : ExpressionCheckers() { override val annotationCallCheckers: Set get() = setOf( - FirAnnotationArgumentChecker + FirAnnotationArgumentChecker, ) override val basicExpressionCheckers: Set diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt index 3f1b01a5b5c..71e8b0de09c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt @@ -101,4 +101,4 @@ class NullForNotNullType( class ManyLambdaExpressionArguments( val argument: FirExpression -) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR) +) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR) \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 1b1780ab177..f60f8f82fce 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -9,7 +9,9 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSymbolOwner import org.jetbrains.kotlin.fir.FirVisibilityChecker import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.resolve.inference.* import org.jetbrains.kotlin.fir.resolve.toSymbol @@ -20,7 +22,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visibilityChecker -import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -143,7 +144,6 @@ internal object CheckArguments : CheckerStage() { override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) { val argumentMapping = candidate.argumentMapping ?: error("Argument should be already mapped while checking arguments!") - for (argument in callInfo.arguments) { val parameter = argumentMapping[argument] candidate.resolveArgument( @@ -155,17 +155,10 @@ internal object CheckArguments : CheckerStage() { context = context ) } - if (candidate.system.hasContradiction && callInfo.arguments.isNotEmpty()) { sink.yieldDiagnostic(InapplicableCandidate) } } - - private val deprecatedSinceKotlin = CallableId( - FqName("kotlin"), - FqName("DeprecatedSinceKotlin"), - Name.identifier("DeprecatedSinceKotlin") - ) } internal object EagerResolveOfCallableReferences : CheckerStage() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index e630b8c671e..b3808b1bce3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -885,6 +885,7 @@ object PositioningStrategies { is KtSuperTypeCallEntry -> element.calleeExpression is KtOperationExpression -> element.operationReference is KtWhenConditionInRange -> element.operationReference + is KtAnnotationEntry -> element.calleeExpression ?: element else -> element } while (locateReferencedName && result is KtParenthesizedExpression) { diff --git a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt index 4169d622a37..afa3068031f 100644 --- a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt index b5b4766706f..9a375e6471a 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinDeclaration.fir.kt @@ -5,23 +5,23 @@ package kotlin.sub @DeprecatedSinceKotlin(warningSince = "1.0", errorSince = "1.1", hiddenSince = "1.2") fun good() {} -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() class Clazz @Deprecated("", level = DeprecationLevel.WARNING) -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() fun fooWarning() {} @Deprecated("", ReplaceWith(""), DeprecationLevel.WARNING) -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() fun fooDefaultWarning() {} @Deprecated("", level = DeprecationLevel.ERROR) -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() fun fooError() {} @Deprecated("", level = DeprecationLevel.HIDDEN) -@DeprecatedSinceKotlin() +@DeprecatedSinceKotlin() fun fooHidden() {} @Deprecated("") diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.fir.kt deleted file mode 100644 index dc58d5d0808..00000000000 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.fir.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo.bar - -@Deprecated("") -@DeprecatedSinceKotlin("1.3") -fun test() {} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.kt index 77dcdc69c5e..37880e47a62 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinOutsideKotlinPackage.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package foo.bar @Deprecated("") diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt index 09a5baf7bce..bf11ce01f7f 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/typeParameterAsUpperBound.fir.kt @@ -1,7 +1,7 @@ // !CHECK_TYPE -@kotlin.internal.InlineOnly +@kotlin.internal.InlineOnly public inline fun C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this public fun listOf(t: T): List = TODO() diff --git a/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt b/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt index 6173a7cf742..f95ca28dae9 100644 --- a/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt +++ b/compiler/testData/diagnostics/tests/privateInFile/topLevelAnnotationCall.fir.kt @@ -17,11 +17,11 @@ class C1 // FILE: 2.kt package pp -@A(foo) +@A(foo) fun f2() {} -@A(foo) +@A(foo) val p2 = "" -@A(foo) +@A(foo) class C2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt index 28db1f988a1..07ca5e7b209 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.fir.kt @@ -25,6 +25,6 @@ public @interface A { @A fun test8() {} -@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {} -@A(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {} +@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {} +@A(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {} @A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {} diff --git a/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt b/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt index 929b2af4669..826f8c217af 100644 --- a/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt +++ b/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt @@ -2,5 +2,5 @@ package a.b -@kotlin.internal.InlineOnly +@kotlin.internal.InlineOnly inline fun foo() {}