Last active
September 20, 2016 21:00
-
-
Save dwarszawski/89ab9f1f03304755728446d5e3cb7297 to your computer and use it in GitHub Desktop.
groovy compiler does not resolve generics properly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.transform.CompileStatic | |
@CompileStatic | |
public abstract class AbstractClass<A, B> { | |
private final Class<A> aClass | |
private final Class<B> bClass | |
AbstractClass(Class<A> aClass, Class<B> bClass) { | |
this.aClass = aClass | |
this.bClass = bClass | |
} | |
void print() { | |
println("class A {$aClass} and class B {$bClass}") | |
} | |
} | |
@CompileStatic | |
public class SomeImpl extends AbstractClass<String, Integer> { | |
SomeImpl() { | |
super(Integer, String) //this should not compile | |
} | |
} | |
AbstractClass object = new SomeImpl() | |
object.print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expect compilation error but actually the result is as follow
Result: class A {class java.lang.Integer} and class B {class java.lang.String}