Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
None
-
None
Description
I have the following code:
import java.util.concurrent.*; class Main { static final void test() { ExecutorService z = null; Future<CharSequence> future = z.<CharSequence>submit(() -> "fd"); } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 7: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.concurrent.Future<? extends java.lang.Object> to: java.util.concurrent.Future<java.lang.CharSequence> @ line 7, column 35. Future<CharSequence> future = z.<CharSequence>submit(() -> "fd"); ^ 1 error
Expected behavior
Compile successfully
Notes
It seems that the compiler chooses to call the variant that takes no type arguments (see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ExecutorService.html#submit(java.lang.Runnable), even though explicit type arguments are given.
Attachments
Issue Links
- duplicates
-
GROOVY-10714 STC: Callable, Runnable, Serializable overload preference for functional argument (closure, lambda, etc.)
- Reopened