Sealed interface quick fix in IntelliJ

Remi Forax forax at univ-mlv.fr
Thu Oct 8 21:31:50 UTC 2020


I've just discovered that if there is already an existing interface with a class,
  interface I { }
  class A implements I { }

you can ask IntelliJ to seal the interface using Alt+Enter (context actions) on the interface then choose "Seal",
but what IntelliJ does goes in the wrong direction IMO, it also adds "non-sealed" to the class A.

  sealed interface I permits A { }
  non-sealed class A implements I { }

Adding "non-sealed" seems wrong for me, usually what a user want is to close the hierarchy and not close only the interface, otherwise we would not have introduce the "non-sealed" keyword.
Adding the keyword "sealed" on the interface makes the class A to not compile anymore, i get that, but i think it's important to let the user choose if he wants to declare the class A final or non-sealed.

regards,
Rémi


More information about the amber-dev mailing list