[ 
https://issues.apache.org/jira/browse/GROOVY-9555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles closed GROOVY-9555.
-------------------------------
    Resolution: Cannot Reproduce

I added a couple versions of your example as tests, but cannot reproduce.  
[https://github.com/apache/groovy/commit/aefc40b0dac30c2630d342925a84db462fa2726a]

 

I think it has something with how the default package is handled when you 
compile separately with javac and then groovyc.  Is you example still 
reproduced on Groovy 2.5.13 or Groovy 3.0.5?

> Generic return type with raw upper bound is not inferred from argument 
> properly
> -------------------------------------------------------------------------------
>
>                 Key: GROOVY-9555
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9555
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.11
>            Reporter: Daniil Ovchinnikov
>            Assignee: Eric Milles
>            Priority: Critical
>
> {code:title=classes.java}
> interface I<T> {}
> class C implements I<Object> {}
> interface Container {
>     <T extends I> T getInstance(Class<T> c);
> }
> {code}
> {code:title=playground.groovy}
> @groovy.transform.CompileStatic
> def usage(Container pc) {
>     C instance = pc.getInstance(C)
>     println(instance)
> }
> {code}
> {noformat}
> $ groovy -version
> Groovy Version: 2.5.11 JVM: 1.8.0_231 Vendor: Oracle Corporation OS: Mac OS X
> $ javac classes.java
> $ groovyc playground.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> playground.groovy: 3: [Static type checking] - Cannot assign value of type I 
> <T extends java.lang.Object> to variable of type C
>  @ line 3, column 18.
>        C instance = pc.getInstance(C)
>                     ^
> 1 error
> {noformat}
> PS real life use case:
> - {{I}} is {{org.gradle.api.Plugin}}
> - {{C}} is {{org.gradle.plugins.ear.EarPlugin}}
> - {{Container#getInstance}} is 
> {{org.gradle.api.plugins.PluginContainer#findPlugin}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to