[K2]: compiler crash on unresolved delegated extention receiver
A report of UNRESOLVED_REFERENCE should not be made for elements like FirImplicitThisReference that don't have a source, as they are implicit. #KT-65044 Fixed
This commit is contained in:
committed by
Space Team
parent
1d817e2ace
commit
ee143e9370
+6
@@ -404,6 +404,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-65044.kt")
|
||||
public void testKT_65044() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/KT-65044.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt41984.kt")
|
||||
public void testKt41984() throws Exception {
|
||||
|
||||
+6
@@ -404,6 +404,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-65044.kt")
|
||||
public void testKT_65044() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/KT-65044.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt41984.kt")
|
||||
public void testKt41984() throws Exception {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FILE: KT-65044.kt
|
||||
public final val <ERROR TYPE REF: Symbol not found for A>.b: <ERROR TYPE REF: Symbol not found for A?>by <Unresolved name: A>#.<Unresolved name: test>#()
|
||||
public get(): <ERROR TYPE REF: Symbol not found for A?> {
|
||||
^ D|/b|.<Unresolved name: getValue>#(this@R|/b|, ::R|/b|)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
val <!UNRESOLVED_REFERENCE!>A<!>.b: <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>A<!>? by <!UNRESOLVED_REFERENCE!>A<!>.test()
|
||||
+6
@@ -404,6 +404,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-65044.kt")
|
||||
public void testKT_65044() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/KT-65044.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt41984.kt")
|
||||
public void testKt41984() throws Exception {
|
||||
|
||||
+6
@@ -404,6 +404,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("KT-65044.kt")
|
||||
public void testKT_65044() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/KT-65044.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt41984.kt")
|
||||
public void testKt41984() throws Exception {
|
||||
|
||||
+13
-5
@@ -59,15 +59,23 @@ private fun ConeDiagnostic.toKtDiagnostic(
|
||||
is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.classId.asString(), null)
|
||||
is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, name.asString(), operatorToken)
|
||||
is ConeUnresolvedTypeQualifierError -> {
|
||||
if (source?.kind == KtRealSourceElementKind) {
|
||||
when {
|
||||
// There could be an implicit reference here, such as FirImplicitThisReference,
|
||||
// or other implicit elements without a source.
|
||||
// In that case, it's not necessary to report UNRESOLVED_REFERENCE because they are implicit.
|
||||
source == null -> null
|
||||
|
||||
// this.qualifiers will contain all resolved qualifiers from the left up to (including) the first unresolved qualifier.
|
||||
// We want to report UNRESOLVED_REFERENCE exactly on the first unresolved qualifier with its name as argument.
|
||||
// Examples: <!UNRESOLVED_REFERENCE!>Unresolved<!>, <!UNRESOLVED_REFERENCE!>Unresolved<!>.Foo,
|
||||
// Resolved.<!UNRESOLVED_REFERENCE!>Unresolved<!>, Resolved.<!UNRESOLVED_REFERENCE!>Unresolved<!>.Foo
|
||||
val lastQualifier = this.qualifiers.last()
|
||||
FirErrors.UNRESOLVED_REFERENCE.createOn(lastQualifier.source, lastQualifier.name.asString(), null)
|
||||
} else {
|
||||
FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier, null)
|
||||
source.kind == KtRealSourceElementKind -> {
|
||||
val lastQualifier = this.qualifiers.last()
|
||||
FirErrors.UNRESOLVED_REFERENCE.createOn(lastQualifier.source, lastQualifier.name.asString(), null)
|
||||
}
|
||||
else -> {
|
||||
FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters)
|
||||
|
||||
Reference in New Issue
Block a user