-
Bug
-
Resolution: Unresolved
-
P4
-
None
Reported on compiler-dev:
https://mail.openjdk.org/pipermail/compiler-dev/2025-January/029306.html
This rule says that a 'null' case label is only allowed for a switch block if the selector expression has a reference type:
"If a null literal is associated with the switch block, then T is a reference type."
4.1 considers the null type as something distinct from the set of reference types. Other parts of JLS use "reference type" to refer to a set of types that *excludes* the null type (e.g., the typing rule for synchronized statements in 14.19).
The 14.11.1 rule should say
If a null literal is associated with the switch block, then T is a reference type **or the null type**.
https://mail.openjdk.org/pipermail/compiler-dev/2025-January/029306.html
This rule says that a 'null' case label is only allowed for a switch block if the selector expression has a reference type:
"If a null literal is associated with the switch block, then T is a reference type."
4.1 considers the null type as something distinct from the set of reference types. Other parts of JLS use "reference type" to refer to a set of types that *excludes* the null type (e.g., the typing rule for synchronized statements in 14.19).
The 14.11.1 rule should say
If a null literal is associated with the switch block, then T is a reference type **or the null type**.