[FIR] Print operator keyword and token to unresolved diagnostic message

#KT-55672 Fixed
This commit is contained in:
Kirill Rakhman
2023-08-23 13:29:16 +02:00
committed by Space Team
parent 85bb7faf10
commit c30ce4aabe
33 changed files with 257 additions and 49 deletions
@@ -296,6 +296,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
add(FirErrors.UNRESOLVED_REFERENCE) { firDiagnostic ->
UnresolvedReferenceImpl(
firDiagnostic.a,
firDiagnostic.b,
firDiagnostic as KtPsiDiagnostic,
token,
)
@@ -251,6 +251,7 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
interface UnresolvedReference : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = UnresolvedReference::class
val reference: String
val operator: String?
}
interface UnresolvedLabel : KtFirDiagnostic<PsiElement> {
@@ -285,6 +285,7 @@ internal class InvisibleReferenceImpl(
internal class UnresolvedReferenceImpl(
override val reference: String,
override val operator: String?,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.UnresolvedReference
@@ -13,6 +13,6 @@ FILE: [ResolvedTo(IMPORTS)] arrayIndexExpressionWithInc.kt
[ResolvedTo(BODY_RESOLVE)] lval <array>: <ERROR TYPE REF: Unresolved name: ArrayList> = R|<local>/a|
[ResolvedTo(BODY_RESOLVE)] lval <index_0>: R|kotlin/Int| = Int(0)
[ResolvedTo(BODY_RESOLVE)] lval <unary>: <ERROR TYPE REF: Unresolved name: get> = R|<local>/<array>|.<Unresolved name: get>#(R|<local>/<index_0>|)
R|<local>/<array>|.<Unresolved name: set>#(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc>#())
R|<local>/<array>|.<Unresolved name: set>#(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc (++)>#())
R|<local>/<unary>|
}
@@ -13,6 +13,6 @@ FILE: [ResolvedTo(IMPORTS)] arrayIndexExpressionWithInc.kt
[ResolvedTo(BODY_RESOLVE)] lval <array>: R|java/util/ArrayList<kotlin/String>| = R|<local>/a|
[ResolvedTo(BODY_RESOLVE)] lval <index_0>: R|kotlin/Int| = Int(0)
[ResolvedTo(BODY_RESOLVE)] lval <unary>: R|kotlin/String| = R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.get: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|)
R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.set: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc>#())
R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.set: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc (++)>#())
R|<local>/<unary>|
}
@@ -17,6 +17,6 @@ FILE: [ResolvedTo(IMPORTS)] arrayIndexExpressionWithIncScript.kts
[ResolvedTo(BODY_RESOLVE)] lval <array>: R|java/util/ArrayList<kotlin/String>| = R|<local>/a|
[ResolvedTo(BODY_RESOLVE)] lval <index_0>: R|kotlin/Int| = Int(0)
[ResolvedTo(BODY_RESOLVE)] lval <unary>: R|kotlin/String| = R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.get: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|)
R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.set: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc>#())
R|<local>/<array>|.R|SubstitutionOverride<java/util/ArrayList.set: R|@EnhancedNullability kotlin/String|>|(R|<local>/<index_0>|, R|<local>/<unary>|.<Unresolved name: inc (++)>#())
R|<local>/<unary>|
}
}
@@ -16,7 +16,7 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedPartOfQualifiedCallUnresolved.kt
{
[ResolvedTo(BODY_RESOLVE)] lval <receiver>: R|ERROR CLASS: Unresolved name: peek| = <Unresolved name: peek>#()
[ResolvedTo(BODY_RESOLVE)] lval <unary>: <ERROR TYPE REF: Unresolved name: braceBalance> = R|<local>/<receiver>|.<Unresolved name: braceBalance>#
R|<local>/<receiver>|.<Unresolved name: braceBalance># = R|<local>/<unary>|.<Unresolved name: inc>#()
R|<local>/<receiver>|.<Unresolved name: braceBalance># = R|<local>/<unary>|.<Unresolved name: inc (++)>#()
R|<local>/<unary>|
}
@@ -20,10 +20,10 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedPartOfQualifiedCallUnresolvedScript.kts
{
[ResolvedTo(BODY_RESOLVE)] lval <receiver>: R|ERROR CLASS: Unresolved name: peek| = <Unresolved name: peek>#()
[ResolvedTo(BODY_RESOLVE)] lval <unary>: <ERROR TYPE REF: Unresolved name: braceBalance> = R|<local>/<receiver>|.<Unresolved name: braceBalance>#
R|<local>/<receiver>|.<Unresolved name: braceBalance># = R|<local>/<unary>|.<Unresolved name: inc>#()
R|<local>/<receiver>|.<Unresolved name: braceBalance># = R|<local>/<unary>|.<Unresolved name: inc (++)>#()
R|<local>/<unary>|
}
}
}
}
@@ -23958,6 +23958,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt");
}
@Test
@TestMetadata("unresolvedOperator.kt")
public void testUnresolvedOperator() throws Exception {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/unresolvedOperator.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/operatorsOverloading/until")
@TestDataPath("$PROJECT_ROOT")
@@ -23958,6 +23958,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt");
}
@Test
@TestMetadata("unresolvedOperator.kt")
public void testUnresolvedOperator() throws Exception {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/unresolvedOperator.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/operatorsOverloading/until")
@TestDataPath("$PROJECT_ROOT")