RFR: 8340145: Problem with generic pattern matching results in internal compiler error
Vicente Romero
vromero at openjdk.org
Mon Oct 21 21:16:13 UTC 2024
On Mon, 21 Oct 2024 12:01:11 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:
> In the following code, when calculating recursively the covered binding patterns, the nested case assumed that the direct supertype of `T2` will always be represented by a `ClassSymbol`. This PR intervenes the erasure calculation.
>
>
> static <T, T2 extends T> T unwrapOrElse(Option<T2> option, T defaultValue) {
> return switch (option) {
> case Option.Some(T2 value) -> value;
> case Option.None<T2> _ -> defaultValue;
> };
> }
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 913:
> 911:
> 912: for (Type sup : types.directSupertypes(bpOne.type)) {
> 913: ClassSymbol clazz = (ClassSymbol) types.erasure(sup).tsym;
general comment: I think that erasure should happen in the desugaring phase, we are already doing some erasure in Flow and all of it is related to patterns. I think that we should consider moving all these erasure to either TransTypes or TransPatterns
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21606#discussion_r1809544754
More information about the compiler-dev
mailing list