eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
164 stars 130 forks source link

[Sealed types] Discovery and wiring of implicitly permitted subtypes can be significantly simplified. #3111

Closed srikanth-sankaran closed 3 weeks ago

srikanth-sankaran commented 3 weeks ago

Presently, we have a completely separate pass and algorithms to detect the permitted subtypes of a sealed type when the declaration lacks a permits clause. This is unnecessary. While wiring super types and superinterfaces, we can also discover the implicit subtypes of sealed types.

For example given:

sealed class X {} final class Y extends X {}

when discovering that Y's super class is X, we can check if X is sealed; if so, whether it lacks a permits clause; if so add Y add a permitted subtype of X;