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

Luke Bemish updated GROOVY-10797:
---------------------------------
    Description: 
Stubs generated by groovyc for joint compilation that contain parameterized 
types as return values that use a raw type as a type parameter cannot be 
compiled by javac, even though the code generating these may compile just fine 
without joint compilation.

I am compiling against a java library that has two classes that look something 
like as follows:
{code:java}
public class Inner<T> {
}
{code}
{code:java}
public class Outer<T extends Inner<?>> {
}
{code}
My own class has the following method, which normally compiles fine:
{code:groovy}
static <T extends Inner> Outer<T> methodName() {
    return null
}
{code}
If joint compilation is enabled and a stub is generated for the class with that 
method, the following stub is generated:
{code:java}
public static <T extends Inner> Outer<T> someMethod() { return (Outer<T>)null;}
{code}
This throws the following error when compiled with javac:
{code:java}
error: type argument T#1 is not within bounds of type-variable T#2
    public static <T extends Inner> Outer<T> someMethod() { return 
(Outer<T>)null;}
                                          ^
  where T#1,T#2 are type-variables:
    T#1 extends Inner declared in method <T#1>someMethod()
    T#2 extends Inner<?> declared in class Outer{code}

  was:
Stubs generated by groovyc for joint compilation that contain parameterized 
types as return values that use a raw type as a type parameter cannot be 
compiled by javac, even though the code generating these may compile just fine 
without joint compilation.

I am compiling against a java library that has two classes that look something 
like as follows:
{code:java}
public class Inner<T> {
}
{code}
{code:java}
public class Outer<T extends Inner<?>> {
}
{code}
My own class has the following method:
{code:groovy}
static <T extends Inner> Outer<T> methodName() {
    return null
}
{code}
If joint compilation is enabled and a stub is generated for the class with that 
method, the following stub is generated:
{code:java}
public static <T extends Inner> Outer<T> someMethod() { return (Outer<T>)null;}
{code}
This throws the following error when compiled with javac:
{code:java}
error: type argument T#1 is not within bounds of type-variable T#2
    public static <T extends Inner> Outer<T> someMethod() { return 
(Outer<T>)null;}
                                          ^
  where T#1,T#2 are type-variables:
    T#1 extends Inner declared in method <T#1>someMethod()
    T#2 extends Inner<?> declared in class Outer{code}


> Stubs with raw type parameters generated through joint compilation cannot be 
> compiled by javac
> ----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10797
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10797
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.6
>            Reporter: Luke Bemish
>            Priority: Minor
>
> Stubs generated by groovyc for joint compilation that contain parameterized 
> types as return values that use a raw type as a type parameter cannot be 
> compiled by javac, even though the code generating these may compile just 
> fine without joint compilation.
> I am compiling against a java library that has two classes that look 
> something like as follows:
> {code:java}
> public class Inner<T> {
> }
> {code}
> {code:java}
> public class Outer<T extends Inner<?>> {
> }
> {code}
> My own class has the following method, which normally compiles fine:
> {code:groovy}
> static <T extends Inner> Outer<T> methodName() {
>     return null
> }
> {code}
> If joint compilation is enabled and a stub is generated for the class with 
> that method, the following stub is generated:
> {code:java}
> public static <T extends Inner> Outer<T> someMethod() { return 
> (Outer<T>)null;}
> {code}
> This throws the following error when compiled with javac:
> {code:java}
> error: type argument T#1 is not within bounds of type-variable T#2
>     public static <T extends Inner> Outer<T> someMethod() { return 
> (Outer<T>)null;}
>                                           ^
>   where T#1,T#2 are type-variables:
>     T#1 extends Inner declared in method <T#1>someMethod()
>     T#2 extends Inner<?> declared in class Outer{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to