-
Notifications
You must be signed in to change notification settings - Fork 329
Closed
Labels
Description
This is using NullAway 0.12.4.
If using a switch expression with discard patterns, NullAway fails with a NullPointerException. This can be worked around by changing to something like var _. Interestingly enough, this only occurs when the switch has more than one pattern.
<snip>/java/nullaway/app/src/main/java/org/example/NullAwayDiscardError.java:10: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
switch(i) {
^
Please report this at https://github.com/google/error-prone/issues/new and include the following:
error-prone version: 2.36.0
BugPattern: NullAway
Stack Trace:
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2087)
Example that reproduces the issue:
package org.example;
public class NullAwayDiscardError {
public sealed interface IntOrBool {}
public record WrappedInt(int a) implements IntOrBool {}
public record WrappedBoolean(boolean b) implements IntOrBool {}
public static void unwrap(IntOrBool i) {
switch(i) {
case WrappedInt(_) -> {}
case WrappedBoolean(_) -> {}
}
}
}