Default modality is abstract for interface. REDUNDANT_MODIFIER_FOR_TARGET applicability reduced #KT-12302 Fixed
This commit is contained in:
@@ -93,9 +93,7 @@ object ModifierCheckerCore {
|
||||
|
||||
// NOTE: redundant targets must be possible!
|
||||
private val redundantTargetMap = mapOf<KtModifierKeywordToken, Set<KotlinTarget>>(
|
||||
ABSTRACT_KEYWORD to EnumSet.of(INTERFACE),
|
||||
OPEN_KEYWORD to EnumSet.of(INTERFACE),
|
||||
FINAL_KEYWORD to EnumSet.of(ENUM_CLASS, OBJECT)
|
||||
OPEN_KEYWORD to EnumSet.of(INTERFACE)
|
||||
)
|
||||
|
||||
val possibleParentTargetMap = mapOf<KtModifierKeywordToken, Set<KotlinTarget>>(
|
||||
|
||||
+2
-2
@@ -6,13 +6,13 @@
|
||||
<!WRONG_MODIFIER_TARGET!>override<!> companion object {}
|
||||
<!WRONG_MODIFIER_TARGET!>open<!> companion object {}
|
||||
<!WRONG_MODIFIER_TARGET!>abstract<!> companion object {}
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>final<!> companion object {}
|
||||
final companion object {}
|
||||
}
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>override<!> object B1 {}
|
||||
<!WRONG_MODIFIER_TARGET!>open<!> object B2 {}
|
||||
<!WRONG_MODIFIER_TARGET!>abstract<!> object B3 {}
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>final<!> object B4 {}
|
||||
final object B4 {}
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>override<!> enum class C {}
|
||||
<!WRONG_MODIFIER_TARGET!>override<!> interface D {}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface First
|
||||
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>abstract<!> interface Second
|
||||
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>final<!> enum class Third {
|
||||
// Now inspection
|
||||
abstract interface Second
|
||||
// Now inspection
|
||||
final enum class Third {
|
||||
FOURTH,
|
||||
FIFTH
|
||||
}
|
||||
|
||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>final<!> object Sixth
|
||||
// Now inspection
|
||||
final object Sixth
|
||||
@@ -229,7 +229,10 @@ fun KtModifierListOwner.canBeProtected(): Boolean {
|
||||
}
|
||||
|
||||
fun KtDeclaration.implicitModality(): KtModifierKeywordToken {
|
||||
if (this is KtClassOrObject) return KtTokens.FINAL_KEYWORD
|
||||
if (this is KtClassOrObject) {
|
||||
if (this is KtClass && this.isInterface()) return KtTokens.ABSTRACT_KEYWORD
|
||||
return KtTokens.FINAL_KEYWORD
|
||||
}
|
||||
val klass = containingClassOrObject ?: return KtTokens.FINAL_KEYWORD
|
||||
if (hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
if (klass.hasModifier(KtTokens.ABSTRACT_KEYWORD) ||
|
||||
|
||||
+16
@@ -87,4 +87,20 @@
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant modality modifier</problem_class>
|
||||
<description>Redundant modality modifier</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>redundantModalityModifier.kt</file>
|
||||
<line>56</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantModalityModifier.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant modality modifier</problem_class>
|
||||
<description>Redundant modality modifier</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>redundantModalityModifier.kt</file>
|
||||
<line>58</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantModalityModifier.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant modality modifier</problem_class>
|
||||
<description>Redundant modality modifier</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+6
@@ -52,3 +52,9 @@ abstract class AbstractDerived2 : Interface {
|
||||
// Redundant
|
||||
override open val gav = 13
|
||||
}
|
||||
// Redundant abstract interface
|
||||
abstract interface AbstractInterface
|
||||
// Redundant final object
|
||||
final object FinalObject
|
||||
// Open interface
|
||||
open interface OpenInterface
|
||||
|
||||
Reference in New Issue
Block a user