1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Suppressions for `unchecked` or `rawtypes` warnings should have an accompanying
comment to explain why the javac warning is safe to ignore.
Rather than just suppressing the warning:
```java
@SuppressWarnings("unchecked")
public ImmutableList<Object> performScaryCast(ImmutableList<String> strings) {
return (ImmutableList<Object>) (ImmutableList<?>) strings;
}
```
Provide a concise explanation for why it is safe:
```java
@SuppressWarnings("unchecked") // Safe covariant cast, given ImmutableList cannot be added to.
public ImmutableList<Object> performScaryCast(ImmutableList<String> strings) {
return (ImmutableList<Object>) (ImmutableList<?>) strings;
}
```
|