[FIR] Prohibit class literals with empty left-hand side

^KT-59165 Fixed
This commit is contained in:
Nikolay Lunyak
2023-07-26 13:41:04 +03:00
committed by Space Team
parent d748fe7696
commit 713c2136cc
18 changed files with 76 additions and 23 deletions
@@ -2440,6 +2440,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.UNSUPPORTED_CLASS_LITERALS_WITH_EMPTY_LHS) { firDiagnostic ->
UnsupportedClassLiteralsWithEmptyLhsImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.NOTHING_TO_OVERRIDE) { firDiagnostic ->
NothingToOverrideImpl(
firSymbolBuilder.callableBuilder.buildCallableSymbol(firDiagnostic.a),
@@ -1730,6 +1730,10 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
val lhsType: KtType
}
interface UnsupportedClassLiteralsWithEmptyLhs : KtFirDiagnostic<KtElement> {
override val diagnosticClass get() = UnsupportedClassLiteralsWithEmptyLhs::class
}
interface NothingToOverride : KtFirDiagnostic<KtModifierListOwner> {
override val diagnosticClass get() = NothingToOverride::class
val declaration: KtCallableSymbol
@@ -2080,6 +2080,11 @@ internal class ExpressionOfNullableTypeInClassLiteralLhsImpl(
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.ExpressionOfNullableTypeInClassLiteralLhs
internal class UnsupportedClassLiteralsWithEmptyLhsImpl(
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.UnsupportedClassLiteralsWithEmptyLhs
internal class NothingToOverrideImpl(
override val declaration: KtCallableSymbol,
firDiagnostic: KtPsiDiagnostic,
@@ -297,6 +297,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
}
@Test
@TestMetadata("emptyLhsClassLiterals.kt")
public void testEmptyLhsClassLiterals() throws Exception {
runTest("compiler/testData/diagnostics/tests/emptyLhsClassLiterals.kt");
}
@Test
@TestMetadata("EnumEntryAsType.kt")
public void testEnumEntryAsType() throws Exception {
@@ -297,6 +297,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
}
@Test
@TestMetadata("emptyLhsClassLiterals.kt")
public void testEmptyLhsClassLiterals() throws Exception {
runTest("compiler/testData/diagnostics/tests/emptyLhsClassLiterals.kt");
}
@Test
@TestMetadata("EnumEntryAsType.kt")
public void testEnumEntryAsType() throws Exception {