Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
Description
This might be related to GROOVY-11002.
I have the following program
import java.util.Comparator; class Foo<T> {} class Bar<T> { static <T> Bar<T> concat(Bar<? extends T>... x) { return null; } static <T> Bar<T> concat(Bar<? extends Bar<? extends T>> x) { return null; } void toSortedSet(Comparator<? super T> x) {} } class Main { static final void test() { Bar<Foo<Number>> x = null; Comparator<Foo<Number>> y = null; Bar.concat(x).toSortedSet(y); } }
Actual behavior
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy35.groovy: 15: [Static type checking] - Cannot call <T> Bar#concat(Bar<? extends Bar<? extends T>>) with arguments [Bar<Foo<java.lang.Number>>] @ line 15, column 15. Bar.concat(x).toSortedSet(y); ^ groovy35.groovy: 15: [Static type checking] - Cannot find matching method java.lang.Object#toSortedSet(java.util.Comparator<Foo<java.lang.Number>>). Please check if the declared type is correct and if the method exists. @ line 15, column 5. Bar.concat(x).toSortedSet(y); ^ 2 errors
Expected behavior
Compile successfully
Notes
Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d)
To reproduce the bug, two overloaded methods are needed; one of them should contain variable arguments.
Test cased adapted from the following program that uses the Guava library
import com.google.common.collect.*; import java.util.Comparator; class Foo<K> {} class Main { static final void test() { Iterable<? extends Foo<Number>> x = null; Comparator<? super Foo<Number>> y = null; FluentIterable.concat(x).toSortedSet(y); } }