You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a switch expression that covers all values of an enum but does not have a default case, it seems that Checker does not account for the implicit default case added by the compiler and thinks that the resulting value may be uninitialized:
Not having this explicit default should be allowed, as per the spec this is preferrable:
In practice this normally means that a default clause is required; however, in the case of an enum switch expression that covers all known constants, a default clause is inserted by the compiler to indicate that the enum definition has changed between compile-time and runtime. Relying on this implicit default clause insertion makes for more robust code; now when code is recompiled, the compiler checks that all cases are explicitly handled.
Funnily enough, this isn't a problem when using the switch statement directly on return:
All of the examples were ran using the command .\bin\javac.bat -cp . -processor nullness Foo.java, with the code being placed in the Foo.java file, and with the current directory being the root directory of the Checker 3.27.0 release artifact.
The text was updated successfully, but these errors were encountered:
When using a switch expression that covers all values of an enum but does not have a
default
case, it seems that Checker does not account for the implicitdefault
case added by the compiler and thinks that the resulting value may be uninitialized:If I add a default case, the error goes away:
Not having this explicit default should be allowed, as per the spec this is preferrable:
Funnily enough, this isn't a problem when using the switch statement directly on return:
All of the examples were ran using the command
.\bin\javac.bat -cp . -processor nullness Foo.java
, with the code being placed in theFoo.java
file, and with the current directory being the root directory of the Checker 3.27.0 release artifact.The text was updated successfully, but these errors were encountered: