[
https://issues.apache.org/jira/browse/GROOVY-11616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949811#comment-17949811
]
Eric Milles commented on GROOVY-11616:
--------------------------------------
This item is in the hopper for getting fixed. It is not a high priority item
at the moment. User can add a type argument or a typecast as a temporary
workaround.
> Functions that take var args will default the type of the first argument,
> java tries to find the common parent type from all arguments
> --------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11616
> URL: https://issues.apache.org/jira/browse/GROOVY-11616
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.24, 5.0.0-alpha-12
> Reporter: Saravanan
> Assignee: Eric Milles
> Priority: Minor
>
>
> {code:java}
> public class Interfaces {
> class Blah {
> }
> class BlahBlah extends Blah {
> }
> class BlahBlahBlah extends Blah {
> }
> public String myThing() {
> // This fails with
> // Incompatible generic argument types. Cannot assign
> java.util.List<? extends com.org.interfaces.Interfaces.Blah>
> // to: java.util.List<com.org.interfaces.Interfaces.Blah>
> // To fix change to explicitly define generic type
> // Arrays.<Blah> asList(...)
> List<Blah> myArray = Arrays.asList(new Blah(), new BlahBlah(), new
> BlahBlahBlah(), new Blah());
> }
> }
> {code}
> Arrays.asList takes a vararg parameter. Groovy defaults to assuming that the
> first parameter type is the type (or parent type) for all parameters that
> follow. If we use instances of multiple derived types, Groovy errors out
> without trying to find the common parent type
--
This message was sent by Atlassian Jira
(v8.20.10#820010)