KT-21780 Wrong redundant setter inspection (#1453)
This commit is contained in:
committed by
Dmitry Jemerov
parent
640c28ceaf
commit
de185b79d0
@@ -42,6 +42,7 @@ class RedundantSetterInspection : AbstractKotlinInspection(), CleanupLocalInspec
|
||||
private fun KtPropertyAccessor.isRedundantSetter(): Boolean {
|
||||
if (!isSetter) return false
|
||||
if (annotationEntries.isNotEmpty()) return false
|
||||
if (property.hasModifier(KtTokens.OVERRIDE_KEYWORD)) return false
|
||||
if (hasLowerVisibilityThanProperty()) return false
|
||||
val expression = bodyExpression ?: return true
|
||||
if (expression is KtBlockExpression) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
interface A {
|
||||
var myVar: Boolean
|
||||
}
|
||||
|
||||
class X : A {
|
||||
override var myVar: Boolean = false
|
||||
<caret>set(value) {}
|
||||
}
|
||||
@@ -2897,6 +2897,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSetter/override.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sameVisibility1.kt")
|
||||
public void testSameVisibility1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSetter/sameVisibility1.kt");
|
||||
|
||||
Reference in New Issue
Block a user