Skip to content

Instantly share code, notes, and snippets.

@mperry
Last active August 29, 2015 14:00
Show Gist options
  • Save mperry/11471693 to your computer and use it in GitHub Desktop.
Save mperry/11471693 to your computer and use it in GitHub Desktop.
Generic type checking defect for Groovy 2.3.0-rc-4
// bug with Groovy 2.3.0-rc-4, should type check, but does not
// http://jira.codehaus.org/browse/GROOVY-6748
import groovy.transform.TypeChecked
//import org.junit.Test
@TypeChecked
class Class1 {
static <A, B> void method1(A a, B b) {
method2(a, b)
}
static <A, B> void method2(A a, B b) {
}
static <A, B> void method3(List<A> list1, List<B> list2) {
method1(list1.get(0), list2.get(0))
}
}
/*
Error is:
D:\repositories\functionalgroovy\consume\scripts>groovy genericTypeCheck.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\repositories\functionalgroovy\consume\scripts\genericTypeCheck.groovy: 18: [St
atic type checking] - Cannot call <A,B> Class1#method1(A, B) with arguments [E, E
]
@ line 18, column 9.
method1(list1.get(0), list2.get(0))
^
1 error
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment