Community
Participate
Working Groups
Casting the result of a generic method is ignored when inferring the value of any type parameters. Other uses of the return value appear to be fine. For example, the following code fails with an error: foo((Set<String>) Collections.emptySet()); Whereas this code is fine: Set<String> a = Collections.emptySet(); foo(a);
Unfortunately, this isn't a bug; but rather a law imposed by the spec. So pls blame the spec instead (I would favor considering cast during inference). *** This bug has been marked as a duplicate of 100271 ***