[FIR] Improve locations for DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE and other diagnostics, refactor
This commit is contained in:
committed by
TeamCityServer
parent
52c32d3d85
commit
598501aaf0
+3
-3
@@ -159,9 +159,9 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
|
||||
}
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
|
||||
val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
|
||||
}
|
||||
|
||||
val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") {
|
||||
|
||||
+3
-3
@@ -165,9 +165,9 @@ object FirErrors {
|
||||
val NEWER_VERSION_IN_SINCE_KOTLIN by warning1<KtExpression, String>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS by error0<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS by error0<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error0<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error0<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error0<PsiElement>()
|
||||
val DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED by error0<PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
||||
val DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL by error0<PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
||||
val DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE by error0<PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
||||
|
||||
// Exposed visibility
|
||||
val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3<KtNamedDeclaration, EffectiveVisibility, FirMemberDeclaration, EffectiveVisibility>(SourceElementPositioningStrategies.DECLARATION_NAME)
|
||||
|
||||
+15
-20
@@ -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<FirFile>()
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -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)
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.syntax.FirAnonymousFunctionSyn
|
||||
object CommonExpressionCheckers : ExpressionCheckers() {
|
||||
override val annotationCallCheckers: Set<FirAnnotationCallChecker>
|
||||
get() = setOf(
|
||||
FirAnnotationArgumentChecker
|
||||
FirAnnotationArgumentChecker,
|
||||
)
|
||||
|
||||
override val basicExpressionCheckers: Set<FirBasicExpressionChecker>
|
||||
|
||||
+1
-1
@@ -101,4 +101,4 @@ class NullForNotNullType(
|
||||
|
||||
class ManyLambdaExpressionArguments(
|
||||
val argument: FirExpression
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
) : ResolutionDiagnostic(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR)
|
||||
+3
-10
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
package test
|
||||
|
||||
|
||||
+5
-5
@@ -5,23 +5,23 @@ package kotlin.sub
|
||||
@DeprecatedSinceKotlin(warningSince = "1.0", errorSince = "1.1", hiddenSince = "1.2")
|
||||
fun good() {}
|
||||
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED!>@DeprecatedSinceKotlin()<!>
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>@<!DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED!>DeprecatedSinceKotlin<!>()<!>
|
||||
class Clazz
|
||||
|
||||
@Deprecated("", level = DeprecationLevel.WARNING)
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>@DeprecatedSinceKotlin()<!>
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>()<!>
|
||||
fun fooWarning() {}
|
||||
|
||||
@Deprecated("", ReplaceWith(""), DeprecationLevel.WARNING)
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>@DeprecatedSinceKotlin()<!>
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>()<!>
|
||||
fun fooDefaultWarning() {}
|
||||
|
||||
@Deprecated("", level = DeprecationLevel.ERROR)
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>@DeprecatedSinceKotlin()<!>
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>()<!>
|
||||
fun fooError() {}
|
||||
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>@DeprecatedSinceKotlin()<!>
|
||||
<!DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS!>@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>()<!>
|
||||
fun fooHidden() {}
|
||||
|
||||
@Deprecated("")
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package foo.bar
|
||||
|
||||
@Deprecated("")
|
||||
<!DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE!>@DeprecatedSinceKotlin("1.3")<!>
|
||||
fun test() {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
package foo.bar
|
||||
|
||||
@Deprecated("")
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
<!INVISIBLE_REFERENCE!>@kotlin.internal.InlineOnly<!>
|
||||
@<!INVISIBLE_REFERENCE!>kotlin.internal.InlineOnly<!>
|
||||
public inline fun <C, R> C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this
|
||||
|
||||
public fun <T> listOf(t: T): List<T> = TODO()
|
||||
|
||||
+3
-3
@@ -17,11 +17,11 @@ class C1
|
||||
// FILE: 2.kt
|
||||
package pp
|
||||
|
||||
<!INVISIBLE_REFERENCE!>@A(<!INVISIBLE_REFERENCE!>foo<!>)<!>
|
||||
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
|
||||
fun f2() {}
|
||||
|
||||
<!INVISIBLE_REFERENCE!>@A(<!INVISIBLE_REFERENCE!>foo<!>)<!>
|
||||
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
|
||||
val p2 = ""
|
||||
|
||||
<!INVISIBLE_REFERENCE!>@A(<!INVISIBLE_REFERENCE!>foo<!>)<!>
|
||||
@<!INVISIBLE_REFERENCE!>A<!>(<!INVISIBLE_REFERENCE!>foo<!>)
|
||||
class C2
|
||||
|
||||
+2
-2
@@ -25,6 +25,6 @@ public @interface A {
|
||||
|
||||
@A fun test8() {}
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>@A(x = Any::class, *arrayOf("5", "6"), "7", y = 3)<!> fun test9() {}
|
||||
<!INAPPLICABLE_CANDIDATE!>@A(x = Any::class, value = ["5", "6"], "7", y = 3)<!> fun test10() {}
|
||||
@<!INAPPLICABLE_CANDIDATE!>A<!>(x = Any::class, *arrayOf("5", "6"), "7", y = 3) fun test9() {}
|
||||
@<!INAPPLICABLE_CANDIDATE!>A<!>(x = Any::class, value = ["5", "6"], "7", y = 3) fun test10() {}
|
||||
@A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
|
||||
package a.b
|
||||
|
||||
<error descr="[INVISIBLE_REFERENCE] Symbol kotlin/internal/InlineOnly.InlineOnly is invisible">@kotlin.internal.InlineOnly</error>
|
||||
@<error descr="[INVISIBLE_REFERENCE] Symbol kotlin/internal/InlineOnly.InlineOnly is invisible">kotlin.internal.InlineOnly</error>
|
||||
inline fun foo() {}
|
||||
|
||||
Reference in New Issue
Block a user