Skip to content

Commit

Permalink
Add an explanation for WrongOneOf
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 443398259
  • Loading branch information
cushon authored and Error Prone Team committed Apr 21, 2022
1 parent bfd9b1d commit 330375e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/bugpattern/WrongOneof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
When switching over a proto `one_of`, getters that don't match the current case
are guaranteed to be return a default instance:

```java
switch (foo.getBlahCase()) {
case FOO:
return foo.getFoo();
case BAR:
return foo.getFoo(); // should be foo.getBar()
}
```

0 comments on commit 330375e

Please sign in to comment.