[FIR] KT-54978 Prohibit explicit type arguments in property accesses
- Add a checker which ensures that property accesses have no explicit type arguments. If an error on the property access's callee reference already exists, the new error is not reported in favor of the existing error, as the property access may have been intended to be a function call. - `complicatedLTGT.fir.kt`: The underlying parser issue is not yet solved, which is why `x` is parsed as a property access with explicit type arguments. - `reservedExpressionSyntax` tests: This new check makes a lot of the access expressions in these tests illegal, so valid lines have been added and invalid lines appropriately marked with `EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS` errors. ^KT-54978 fixed
This commit is contained in:
committed by
teamcity
parent
4d20b43619
commit
d4e6a4ad54
+6
@@ -2844,6 +2844,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS) { firDiagnostic ->
|
||||
ExplicitTypeArgumentsInPropertyAccessImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.EXPECTED_DECLARATION_WITH_BODY) { firDiagnostic ->
|
||||
ExpectedDeclarationWithBodyImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+4
@@ -2008,6 +2008,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = LocalVariableWithTypeParameters::class
|
||||
}
|
||||
|
||||
abstract class ExplicitTypeArgumentsInPropertyAccess : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = ExplicitTypeArgumentsInPropertyAccess::class
|
||||
}
|
||||
|
||||
abstract class ExpectedDeclarationWithBody : KtFirDiagnostic<KtDeclaration>() {
|
||||
override val diagnosticClass get() = ExpectedDeclarationWithBody::class
|
||||
}
|
||||
|
||||
+5
@@ -2418,6 +2418,11 @@ internal class LocalVariableWithTypeParametersImpl(
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.LocalVariableWithTypeParameters(), KtAbstractFirDiagnostic<KtProperty>
|
||||
|
||||
internal class ExplicitTypeArgumentsInPropertyAccessImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.ExplicitTypeArgumentsInPropertyAccess(), KtAbstractFirDiagnostic<KtExpression>
|
||||
|
||||
internal class ExpectedDeclarationWithBodyImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
|
||||
+6
@@ -2159,6 +2159,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/expresssions/privateVisibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAccessWithExplicitTypeArguments.kt")
|
||||
public void testPropertyAccessWithExplicitTypeArguments() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/expresssions/propertyAccessWithExplicitTypeArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("protectedVisibility.kt")
|
||||
public void testProtectedVisibility() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user