akshattandon / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

Generics and static factory methods with @XArgsConstructor #776

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

public class Bar<T extends java.util.Collection<E>, E> {
}

@lombok.RequiredArgsConstructor(staticName = "create")
public class Foo<T extends java.util.Collection<E>, E> {
    public final Bar<T, E> bar;
}

When compiling these two classes with AndroidStudio (IntelliJ IDEA) or with 
"java -jar lombok.jar delombok", the following error occurs:

error: type argument T#1 is not within bounds of type-variable T#2
  where T#1,E#1,E#2,T#2,E#3 are type-variables:
    T#1 extends Collection<E#2> declared in method <T#1,E#1>create(Bar<T#1,E#1>)
    E#1 extends Object declared in method <T#1,E#1>create(Bar<T#1,E#1>)
    E#2 extends Object declared in class Foo
    T#2 extends Collection<E#3> declared in class Bar
    E#3 extends Object declared in class Bar

What is the expected output? What do you see instead?

Using eclipse with its own compiler, compiling works without errors. However, 
using "java -jar lombok.jar delombok" the error occurs too, but the class is 
nevertheless processed correctly. It generates the following code (which is 
desired):

public class Foo<T extends java.util.Collection<E>, E> {
    public final Bar<T, E> bar;

    @java.lang.SuppressWarnings("all")
    private Foo(final Bar<T, E> bar) {
        this.bar = bar;
    }

    @java.lang.SuppressWarnings("all")
    public static <T extends java.util.Collection<E>, E> Foo<T, E> create(final Bar<T, E> bar) {
        return new Foo<T, E>(bar);
    }
}

What version of the product are you using? On what operating system?

lombok 1.16.0
JDK 1.8.0.25
Android Studio 1.0.2
Lombok Plugin 0.8.8

Please provide any additional information below.

I do not know, from where the error comes from. But since the generated code is 
correct, the error should not occur. It prevents AndroidStudio from building 
the project, which is bad.

Original issue reported on code.google.com by goo...@korelstar.de on 29 Jan 2015 at 11:10

GoogleCodeExporter commented 9 years ago
I too have encountered this issue, with this class: 
https://github.com/SleepyTrousers/EnderCore/blob/ed514c78cc0e72bad68373316e47b0c
fdfd39471/src/main/java/com/enderio/core/common/util/Bound.java

It compiles the correct code (javap output): http://puu.sh/hCiIo.txt

But gives these errors when calling the method: http://puu.sh/hBIHu.txt

Oddly it runs fine in eclipse luna, but I am using jdk6 for that.

JDK/javac 1.8.0.40 used to compile

Original comment by tterrag1...@gmail.com on 5 May 2015 at 2:39