Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
Description
Somewhat related to GROOVY-11254.
I have the following program
import java.util.function.*; class Foo<T> { Foo(Supplier<? super T> x) {} } class Main { static final void test() { Supplier<CharSequence> func = null; Foo<StringBuffer> x = new Foo<>(func); } }
Actual behaviour
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign Foo<java.lang.CharSequence> to: Foo<java.lang.StringBuffer> @ line 10, column 27. Foo<StringBuffer> x = new Foo<>(func); ^ 1 error
Expected behaviour
Compile successfully
Notes
Tested against master
Test case adapted from:
class Main { static final void test() { final org.apache.commons.collections4.functors.NotPredicate<CharSequence> x = null; final org.apache.commons.collections4.functors.PredicateDecorator<StringBuffer> y = new org.apache.commons.collections4.functors.NullIsTruePredicate<>(x); } }