K2: add checker detecting protected Java field shadowed by a property
This commit is contained in:
committed by
teamcity
parent
6234da4c86
commit
949a39b80f
+8
@@ -4737,6 +4737,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE) { firDiagnostic ->
|
||||
JavaShadowedProtectedFieldReferenceImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic.b,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.IMPLEMENTING_FUNCTION_INTERFACE) { firDiagnostic ->
|
||||
ImplementingFunctionInterfaceImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+6
@@ -3294,6 +3294,12 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = JavaSamInterfaceConstructorReference::class
|
||||
}
|
||||
|
||||
abstract class JavaShadowedProtectedFieldReference : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = JavaShadowedProtectedFieldReference::class
|
||||
abstract val containerClass: ClassId
|
||||
abstract val shadowingClass: ClassId
|
||||
}
|
||||
|
||||
abstract class ImplementingFunctionInterface : KtFirDiagnostic<KtClassOrObject>() {
|
||||
override val diagnosticClass get() = ImplementingFunctionInterface::class
|
||||
}
|
||||
|
||||
+7
@@ -3986,6 +3986,13 @@ internal class JavaSamInterfaceConstructorReferenceImpl(
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.JavaSamInterfaceConstructorReference(), KtAbstractFirDiagnostic<PsiElement>
|
||||
|
||||
internal class JavaShadowedProtectedFieldReferenceImpl(
|
||||
override val containerClass: ClassId,
|
||||
override val shadowingClass: ClassId,
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.JavaShadowedProtectedFieldReference(), KtAbstractFirDiagnostic<PsiElement>
|
||||
|
||||
internal class ImplementingFunctionInterfaceImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
|
||||
+18
@@ -405,6 +405,24 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt")
|
||||
public void testJavaFieldKotlinPropertyJavaFieldInPackagePrivate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaFieldKotlinPropertyJavaPackagePrivateField.kt")
|
||||
public void testJavaFieldKotlinPropertyJavaPackagePrivateField() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaPackagePrivateField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaProtectedFieldAndKotlinInvisiblePropertyReference.kt")
|
||||
public void testJavaProtectedFieldAndKotlinInvisiblePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/javaProtectedFieldAndKotlinInvisiblePropertyReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt11167.kt")
|
||||
public void testKt11167() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user