Sealed interface quick fix in IntelliJ
Brian Goetz
brian.goetz at oracle.com
Thu Oct 8 21:42:29 UTC 2020
I suspct what they're doing is saying "well, A was extensible before, so
let's not change that." But I too would prefer that they default to
`final` unless the user requests otherwise. non-sealed should be rare.
On 10/8/2020 5:31 PM, Remi Forax wrote:
> 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