Details
Description
When an interface takes two generic wildcard types (i.e. "?"), it is not (always) possible to use a specialized Functional Interface instead.
import java.util.function.Function; public class FunTypes { public static final Function<?, ?> NEW_OBJECT = anything -> new Object(); // FP }
Message states:
Refactor this code to use the more specialized Functional Interface ‘UnaryOperator<?>’
It is not possible, the first "?" is not necessarily the same as the second "?".
Attachments
Issue Links
- relates to
-
RSPEC-4276 Functional Interfaces should be as specialised as possible
- Active
- links to