[FIR] KT-54507 Report REDUNDANT_MODALITY_MODIFIER for open interface

- `REDUNDANT_MODIFIER_FOR_TARGET` is already reported for `open`
  interfaces, but for consistency and IDE support, the compiler now
  reports `REDUNDANT_MODALITY_MODIFIER` as well via the extended
  checker.
- `REDUNDANT_MODIFIER_FOR_TARGET` cannot be disabled for this case
  because it's reported via a basic checker while
  `REDUNDANT_MODALITY_MODIFIER` is reported via an extended checker.
- Rename `implicitModality` to `redundantModalities` and return a set of
  modalities. The idea of a *single* implicit/redundant modality doesn't
  stand up to scrutiny. For example, for interfaces with `ABSTRACT`
  implicit modality, `OPEN` is also a redundant modifier. But this is
  not necessarily the case for all kinds of declarations.
  Hypothetically, if it was possible to declare a class that is abstract
  by default, adding an `open` modifier to that class would not be
  redundant, as it would make the class instantiable.
This commit is contained in:
Marco Pennekamp
2023-02-06 19:12:53 +01:00
committed by Space Team
parent 76ca96d2e2
commit 5909b191a5
4 changed files with 20 additions and 16 deletions
@@ -12,6 +12,7 @@ interface Interface {
// error
<!PRIVATE_FUNCTION_WITH_NO_BODY!>private<!> <!WRONG_MODIFIER_CONTAINING_DECLARATION!>final<!> fun bar()
<!REDUNDANT_MODALITY_MODIFIER, REDUNDANT_OPEN_IN_INTERFACE!>open<!> fun loo()
<!REDUNDANT_MODALITY_MODIFIER!>open<!> fun goo() {}
<!REDUNDANT_MODALITY_MODIFIER!>abstract<!> fun tar()
@@ -84,7 +85,7 @@ abstract class AbstractDerived2 : Interface {
// Redundant final object
<!REDUNDANT_MODALITY_MODIFIER!>final<!> object FinalObject
// Open interface
<!REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface OpenInterface
<!REDUNDANT_MODALITY_MODIFIER, REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface OpenInterface
class FinalDerived2(override <!REDUNDANT_MODALITY_MODIFIER!>final<!> val gav: Int) : Base() {
override fun bar() {}