Do not report "property can be private" in annotations #KT-19273 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
050744627d
commit
29dba9edb3
@@ -77,6 +77,8 @@ class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val classOrObject = declaration.containingClassOrObject ?: return false
|
val classOrObject = declaration.containingClassOrObject ?: return false
|
||||||
|
if (classOrObject.isAnnotation()) return false
|
||||||
|
|
||||||
val inheritable = classOrObject is KtClass && classOrObject.isInheritable()
|
val inheritable = classOrObject is KtClass && classOrObject.isInheritable()
|
||||||
if (!inheritable && declaration.hasModifier(KtTokens.PROTECTED_KEYWORD)) return false //reported by ProtectedInFinalInspection
|
if (!inheritable && declaration.hasModifier(KtTokens.PROTECTED_KEYWORD)) return false //reported by ProtectedInFinalInspection
|
||||||
if (declaration.isOverridable()) return false
|
if (declaration.isOverridable()) return false
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// ERROR: Body is not allowed for annotation class
|
||||||
|
// PROBLEM: none
|
||||||
|
|
||||||
|
annotation class Ann(val <caret>x: String) {
|
||||||
|
fun foo() {
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1022,6 +1022,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/memberVisibilityCanBePrivate"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/memberVisibilityCanBePrivate"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotation.kt")
|
||||||
|
public void testAnnotation() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/memberVisibilityCanBePrivate/annotation.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmFieldOnParameter.kt")
|
@TestMetadata("JvmFieldOnParameter.kt")
|
||||||
public void testJvmFieldOnParameter() throws Exception {
|
public void testJvmFieldOnParameter() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/memberVisibilityCanBePrivate/JvmFieldOnParameter.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/memberVisibilityCanBePrivate/JvmFieldOnParameter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user