K2: don't resolve callable reference to enum entries #KT-59611 Fixed
This commit is contained in:
committed by
Space Team
parent
9bbfdb708c
commit
15b070b494
+6
@@ -11062,6 +11062,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToEnumEntry.kt")
|
||||
public void testReferenceToEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/referenceToEnumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SecondaryConstructorCall.kt")
|
||||
public void testSecondaryConstructorCall() throws Exception {
|
||||
|
||||
+6
@@ -11062,6 +11062,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToEnumEntry.kt")
|
||||
public void testReferenceToEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/referenceToEnumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SecondaryConstructorCall.kt")
|
||||
public void testSecondaryConstructorCall() throws Exception {
|
||||
|
||||
+6
@@ -11062,6 +11062,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToEnumEntry.kt")
|
||||
public void testReferenceToEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/referenceToEnumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SecondaryConstructorCall.kt")
|
||||
public void testSecondaryConstructorCall() throws Exception {
|
||||
|
||||
+6
@@ -11068,6 +11068,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToEnumEntry.kt")
|
||||
public void testReferenceToEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/referenceToEnumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SecondaryConstructorCall.kt")
|
||||
public void testSecondaryConstructorCall() throws Exception {
|
||||
|
||||
+12
-3
@@ -83,11 +83,20 @@ class CandidateFactory private constructor(
|
||||
)
|
||||
|
||||
// The counterpart in FE 1.0 checks if the given descriptor is VariableDescriptor yet not PropertyDescriptor.
|
||||
// Here, we explicitly check if the referred declaration/symbol is value parameter, local variable, or backing field.
|
||||
// Here, we explicitly check if the referred declaration/symbol is value parameter, local variable, enum entry, or backing field.
|
||||
val callSite = callInfo.callSite
|
||||
if (callSite is FirCallableReferenceAccess) {
|
||||
if (symbol is FirValueParameterSymbol || symbol is FirPropertySymbol && symbol.isLocal || symbol is FirBackingFieldSymbol) {
|
||||
result.addDiagnostic(Unsupported("References to variables aren't supported yet", callSite.calleeReference.source))
|
||||
when {
|
||||
symbol is FirValueParameterSymbol || symbol is FirPropertySymbol && symbol.isLocal || symbol is FirBackingFieldSymbol -> {
|
||||
result.addDiagnostic(
|
||||
Unsupported("References to variables aren't supported yet", callSite.calleeReference.source)
|
||||
)
|
||||
}
|
||||
symbol is FirEnumEntrySymbol -> {
|
||||
result.addDiagnostic(
|
||||
Unsupported("References to enum entries aren't supported", callSite.calleeReference.source)
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (objectsByName && symbol.isRegularClassWithoutCompanion(callInfo.session)) {
|
||||
result.addDiagnostic(NoCompanionObject)
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ class InfixCallOfNonInfixFunction(val function: FirNamedFunctionSymbol) : Resolu
|
||||
class OperatorCallOfNonOperatorFunction(val function: FirNamedFunctionSymbol) : ResolutionDiagnostic(CONVENTION_ERROR)
|
||||
|
||||
class InferenceError(val constraintError: ConstraintSystemError) : ResolutionDiagnostic(constraintError.applicability)
|
||||
class Unsupported(val message: String, val source: KtSourceElement? = null) : ResolutionDiagnostic(K2_UNSUPPORTED)
|
||||
class Unsupported(val message: String, val source: KtSourceElement?) : ResolutionDiagnostic(K2_UNSUPPORTED)
|
||||
|
||||
object PropertyAsOperator : ResolutionDiagnostic(K2_PROPERTY_AS_OPERATOR)
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// !LANGUAGE: +EnumEntries
|
||||
// !LANGUAGE: +EnumEntries -PrioritizedEnumEntries
|
||||
// KT-59611
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, NATIVE, WASM
|
||||
// IGNORE_BACKEND: JS, JVM
|
||||
// WITH_STDLIB
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
enum class My { V }
|
||||
|
||||
fun test() {
|
||||
val ref = My::<!UNSUPPORTED!>V<!>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
enum class My { V }
|
||||
|
||||
fun test() {
|
||||
val ref = My::<!UNRESOLVED_REFERENCE!>V<!>
|
||||
}
|
||||
Generated
+6
@@ -11068,6 +11068,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToEnumEntry.kt")
|
||||
public void testReferenceToEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/enum/referenceToEnumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("SecondaryConstructorCall.kt")
|
||||
public void testSecondaryConstructorCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user