FIR: Change diagnostic for ConeHiddenCandidate to UNRESOLVED_REFERENCE.
The KDoc for @Deprecated states that DeprecationLevel.HIDDEN usages should look like unresolved references.
This commit is contained in:
committed by
TeamCityServer
parent
7425986bf0
commit
b8ed46066e
+15
-2
@@ -22,29 +22,42 @@ import org.jetbrains.kotlin.fir.resolve.inference.model.ConeExpectedTypeConstrai
|
|||||||
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeLambdaArgumentConstraintPosition
|
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeLambdaArgumentConstraintPosition
|
||||||
import org.jetbrains.kotlin.fir.resolve.isTypeMismatchDueToNullability
|
import org.jetbrains.kotlin.fir.resolve.isTypeMismatchDueToNullability
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.typeContext
|
import org.jetbrains.kotlin.fir.typeContext
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
|
import org.jetbrains.kotlin.name.SpecialNames
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
|
|
||||||
private fun ConeDiagnostic.toFirDiagnostic(
|
private fun ConeDiagnostic.toFirDiagnostic(
|
||||||
source: FirSourceElement,
|
source: FirSourceElement,
|
||||||
qualifiedAccessSource: FirSourceElement?
|
qualifiedAccessSource: FirSourceElement?
|
||||||
): FirDiagnostic? = when (this) {
|
): FirDiagnostic? = when (this) {
|
||||||
is ConeUnresolvedReferenceError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.name?.asString() ?: "<No name>")
|
is ConeUnresolvedReferenceError -> FirErrors.UNRESOLVED_REFERENCE.createOn(
|
||||||
|
source,
|
||||||
|
(this.name ?: SpecialNames.NO_NAME_PROVIDED).asString()
|
||||||
|
)
|
||||||
is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.classId.asString())
|
is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.classId.asString())
|
||||||
is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.name.asString())
|
is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.name.asString())
|
||||||
is ConeUnresolvedQualifierError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier)
|
is ConeUnresolvedQualifierError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier)
|
||||||
is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters)
|
is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters)
|
||||||
is ConeFunctionExpectedError -> FirErrors.FUNCTION_EXPECTED.createOn(source, this.expression, this.type)
|
is ConeFunctionExpectedError -> FirErrors.FUNCTION_EXPECTED.createOn(source, this.expression, this.type)
|
||||||
is ConeResolutionToClassifierError -> FirErrors.RESOLUTION_TO_CLASSIFIER.createOn(source, this.candidateSymbol)
|
is ConeResolutionToClassifierError -> FirErrors.RESOLUTION_TO_CLASSIFIER.createOn(source, this.candidateSymbol)
|
||||||
is ConeHiddenCandidateError -> FirErrors.INVISIBLE_REFERENCE.createOn(source, this.candidateSymbol)
|
is ConeHiddenCandidateError -> {
|
||||||
|
// Usages of callables with @Deprecated(DeprecationLevel.HIDDEN) should look like unresolved references.
|
||||||
|
// See: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-deprecated/
|
||||||
|
FirErrors.UNRESOLVED_REFERENCE.createOn(
|
||||||
|
source,
|
||||||
|
(this.candidateSymbol.safeAs<FirCallableSymbol<*>>()?.name ?: SpecialNames.NO_NAME_PROVIDED).asString()
|
||||||
|
)
|
||||||
|
}
|
||||||
is ConeVisibilityError -> FirErrors.INVISIBLE_REFERENCE.createOn(source, this.candidateSymbol)
|
is ConeVisibilityError -> FirErrors.INVISIBLE_REFERENCE.createOn(source, this.candidateSymbol)
|
||||||
is ConeInapplicableWrongReceiver -> FirErrors.UNRESOLVED_REFERENCE_WRONG_RECEIVER.createOn(source, this.candidateSymbols)
|
is ConeInapplicableWrongReceiver -> FirErrors.UNRESOLVED_REFERENCE_WRONG_RECEIVER.createOn(source, this.candidateSymbols)
|
||||||
is ConeNoCompanionObject -> FirErrors.NO_COMPANION_OBJECT.createOn(source, this.candidateSymbol)
|
is ConeNoCompanionObject -> FirErrors.NO_COMPANION_OBJECT.createOn(source, this.candidateSymbol)
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ fun use(
|
|||||||
) {
|
) {
|
||||||
wd.<!DEPRECATION!>f<!>()
|
wd.<!DEPRECATION!>f<!>()
|
||||||
ed.<!DEPRECATION_ERROR!>f<!>()
|
ed.<!DEPRECATION_ERROR!>f<!>()
|
||||||
hd.<!INVISIBLE_REFERENCE!>f<!>()
|
hd.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||||
|
|
||||||
we.f()
|
we.f()
|
||||||
wh.f()
|
wh.f()
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ fun use(
|
|||||||
) {
|
) {
|
||||||
wd.<!DEPRECATION!>f<!>()
|
wd.<!DEPRECATION!>f<!>()
|
||||||
ed.<!DEPRECATION_ERROR!>f<!>()
|
ed.<!DEPRECATION_ERROR!>f<!>()
|
||||||
hd.<!INVISIBLE_REFERENCE!>f<!>()
|
hd.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||||
|
|
||||||
we.f()
|
we.f()
|
||||||
wh.f()
|
wh.f()
|
||||||
|
|||||||
+3
-3
@@ -107,8 +107,8 @@ fun use(
|
|||||||
setterDeprecated.p
|
setterDeprecated.p
|
||||||
setterDeprecated.p <!DEPRECATION!>=<!> 1
|
setterDeprecated.p <!DEPRECATION!>=<!> 1
|
||||||
|
|
||||||
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!>
|
hiddenDeprecated.<!UNRESOLVED_REFERENCE!>p<!>
|
||||||
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!> = 1
|
hiddenDeprecated.<!UNRESOLVED_REFERENCE!>p<!> = 1
|
||||||
|
|
||||||
wd.p
|
wd.p
|
||||||
wd.p = 1
|
wd.p = 1
|
||||||
@@ -132,5 +132,5 @@ fun use(
|
|||||||
ned.p = 1
|
ned.p = 1
|
||||||
|
|
||||||
diff.<!DEPRECATION_ERROR!>p<!>
|
diff.<!DEPRECATION_ERROR!>p<!>
|
||||||
diff.<!INVISIBLE_REFERENCE!>p<!> = 1
|
diff.<!UNRESOLVED_REFERENCE!>p<!> = 1
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -107,8 +107,8 @@ fun use(
|
|||||||
setterDeprecated.p
|
setterDeprecated.p
|
||||||
setterDeprecated.p <!DEPRECATION!>=<!> 1
|
setterDeprecated.p <!DEPRECATION!>=<!> 1
|
||||||
|
|
||||||
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!>
|
hiddenDeprecated.<!UNRESOLVED_REFERENCE!>p<!>
|
||||||
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!> = 1
|
hiddenDeprecated.<!UNRESOLVED_REFERENCE!>p<!> = 1
|
||||||
|
|
||||||
wd.p
|
wd.p
|
||||||
wd.p = 1
|
wd.p = 1
|
||||||
@@ -132,5 +132,5 @@ fun use(
|
|||||||
ned.p = 1
|
ned.p = 1
|
||||||
|
|
||||||
diff.<!DEPRECATION_ERROR!>p<!>
|
diff.<!DEPRECATION_ERROR!>p<!>
|
||||||
diff.<!INVISIBLE_REFERENCE!>p<!> = 1
|
diff.<!UNRESOLVED_REFERENCE!>p<!> = 1
|
||||||
}
|
}
|
||||||
|
|||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
// !API_VERSION: 1.4
|
|
||||||
|
|
||||||
package kotlin
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.4")
|
|
||||||
class ClassCur
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.4")
|
|
||||||
fun funCur() {}
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.4")
|
|
||||||
val valCur = Unit
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.5")
|
|
||||||
class ClassNext
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.5")
|
|
||||||
fun funNext() {}
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
@DeprecatedSinceKotlin(hiddenSince = "1.5")
|
|
||||||
val valNext = Unit
|
|
||||||
|
|
||||||
fun usage() {
|
|
||||||
<!DEPRECATION_ERROR!>ClassCur<!>()
|
|
||||||
<!INVISIBLE_REFERENCE!>funCur<!>()
|
|
||||||
<!INVISIBLE_REFERENCE!>valCur<!>
|
|
||||||
|
|
||||||
ClassNext()
|
|
||||||
funNext()
|
|
||||||
valNext
|
|
||||||
}
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !API_VERSION: 1.4
|
// !API_VERSION: 1.4
|
||||||
|
|
||||||
package kotlin
|
package kotlin
|
||||||
|
|||||||
+8
-8
@@ -27,14 +27,14 @@ var v6: String
|
|||||||
set(value) {}
|
set(value) {}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
<!INVISIBLE_REFERENCE!>v1<!>
|
<!UNRESOLVED_REFERENCE!>v1<!>
|
||||||
<!INVISIBLE_REFERENCE!>v2<!>
|
<!UNRESOLVED_REFERENCE!>v2<!>
|
||||||
<!INVISIBLE_REFERENCE!>v3<!>
|
<!UNRESOLVED_REFERENCE!>v3<!>
|
||||||
v3 = ""
|
v3 = ""
|
||||||
v4
|
v4
|
||||||
<!INVISIBLE_REFERENCE!>v4<!> = ""
|
<!UNRESOLVED_REFERENCE!>v4<!> = ""
|
||||||
<!INVISIBLE_REFERENCE!>v5<!>
|
<!UNRESOLVED_REFERENCE!>v5<!>
|
||||||
<!INVISIBLE_REFERENCE!>v5<!> = ""
|
<!UNRESOLVED_REFERENCE!>v5<!> = ""
|
||||||
<!INVISIBLE_REFERENCE!>v6<!>
|
<!UNRESOLVED_REFERENCE!>v6<!>
|
||||||
<!INVISIBLE_REFERENCE!>v6<!> = ""
|
<!UNRESOLVED_REFERENCE!>v6<!> = ""
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ object A {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
takeString(<!ARGUMENT_TYPE_MISMATCH!>A <!INVISIBLE_REFERENCE!>%<!> 123<!>)
|
takeString(<!ARGUMENT_TYPE_MISMATCH!>A <!UNRESOLVED_REFERENCE!>%<!> 123<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun takeString(s: String) {}
|
fun takeString(s: String) {}
|
||||||
|
|||||||
@@ -38,23 +38,23 @@ open class A {
|
|||||||
val String.memberExtensionProperty: Int get() = 1
|
val String.memberExtensionProperty: Int get() = 1
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
<!INVISIBLE_REFERENCE!>topLevelFun<!>()
|
<!UNRESOLVED_REFERENCE!>topLevelFun<!>()
|
||||||
<!INVISIBLE_REFERENCE!>topLevelFun<!>(1)
|
<!UNRESOLVED_REFERENCE!>topLevelFun<!>(1)
|
||||||
<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>topLevelProperty<!>++
|
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>topLevelProperty<!>++
|
||||||
"".<!INVISIBLE_REFERENCE!>topLevelExtensionFun<!>()
|
"".<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>()
|
||||||
1.<!INVISIBLE_REFERENCE!>topLevelExtensionFun<!>()
|
1.<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>()
|
||||||
"".<!INVISIBLE_REFERENCE!>topLevelExtensionProperty<!>
|
"".<!UNRESOLVED_REFERENCE!>topLevelExtensionProperty<!>
|
||||||
1.<!INVISIBLE_REFERENCE!>topLevelExtensionProperty<!>
|
1.<!UNRESOLVED_REFERENCE!>topLevelExtensionProperty<!>
|
||||||
|
|
||||||
<!INVISIBLE_REFERENCE!>memberFun<!>()
|
<!UNRESOLVED_REFERENCE!>memberFun<!>()
|
||||||
<!INVISIBLE_REFERENCE!>memberFun<!>(1)
|
<!UNRESOLVED_REFERENCE!>memberFun<!>(1)
|
||||||
<!INVISIBLE_REFERENCE!>privateFun<!>()
|
<!UNRESOLVED_REFERENCE!>privateFun<!>()
|
||||||
<!INVISIBLE_REFERENCE!>privateFun<!>(1)
|
<!UNRESOLVED_REFERENCE!>privateFun<!>(1)
|
||||||
<!INVISIBLE_REFERENCE!>memberProperty<!>
|
<!UNRESOLVED_REFERENCE!>memberProperty<!>
|
||||||
"".<!INVISIBLE_REFERENCE!>memberExtensionFun<!>()
|
"".<!UNRESOLVED_REFERENCE!>memberExtensionFun<!>()
|
||||||
1.<!INVISIBLE_REFERENCE!>memberExtensionFun<!>()
|
1.<!UNRESOLVED_REFERENCE!>memberExtensionFun<!>()
|
||||||
"".<!INVISIBLE_REFERENCE!>memberExtensionProperty<!>
|
"".<!UNRESOLVED_REFERENCE!>memberExtensionProperty<!>
|
||||||
1.<!INVISIBLE_REFERENCE!>memberExtensionProperty<!>
|
1.<!UNRESOLVED_REFERENCE!>memberExtensionProperty<!>
|
||||||
|
|
||||||
A(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
|
A(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
|
||||||
}
|
}
|
||||||
@@ -76,9 +76,9 @@ interface I {
|
|||||||
class B : A(<!ARGUMENT_TYPE_MISMATCH!>""<!>) {
|
class B : A(<!ARGUMENT_TYPE_MISMATCH!>""<!>) {
|
||||||
// still can override it
|
// still can override it
|
||||||
override fun <!OVERRIDE_DEPRECATION!>memberFun<!>() {
|
override fun <!OVERRIDE_DEPRECATION!>memberFun<!>() {
|
||||||
super.<!INVISIBLE_REFERENCE!>memberFun<!>() // but cannot call super :)
|
super.<!UNRESOLVED_REFERENCE!>memberFun<!>() // but cannot call super :)
|
||||||
<!INVISIBLE_REFERENCE!>privateFun<!>()
|
<!UNRESOLVED_REFERENCE!>privateFun<!>()
|
||||||
<!INVISIBLE_REFERENCE!>privateFun<!>(1)
|
<!UNRESOLVED_REFERENCE!>privateFun<!>(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user