Permalink
Browse files

Merge branch 'GROOVY_2_0_X' of github.com:groovy/groovy-core into GRO…

…OVY_2_0_X
  • Loading branch information...
2 parents 91b9b2a + e7e789f commit 76d6a47c6e98f03eac762bdbedf596661639b597 @paulk-asert paulk-asert committed Sep 20, 2012
@@ -4,6 +4,8 @@ package org.codehaus.groovy.tools.stubgenerator
* GROOVY-5630:
* Java stub generator generates wrong cast for return value of generic method
*
+ * (also covers GROOVY-5439)
+ *
* @author Guillaume Laforge
*/
class WrongCastForGenericReturnValueOfMethodStubsTest extends StringSourcesStubTestCase {
@@ -14,18 +16,31 @@ class WrongCastForGenericReturnValueOfMethodStubsTest extends StringSourcesStubT
class HelperUtil {
final Map<String, String> test = new HashMap<String, String>()
static <T extends Task> T createTask(Class<T> type) { }
+ public <T extends List> T foo() { null }
}
''',
'Task.java': '''
public class Task {}
+ ''',
+ 'Schedule.groovy': '''
+ class Schedule<T extends ScheduleItem> extends HashSet<T> {
+ T getCurrentItem() { }
+ }
+ ''',
+ 'ScheduleItem.java': '''
+ public class ScheduleItem {}
'''
]
}
void verifyStubs() {
- def stubSource = stubJavaSourceFor('HelperUtil')
+ def stubSourceForHelper = stubJavaSourceFor('HelperUtil')
+ def stubSourceForSchedule = stubJavaSourceFor('Schedule')
+
+ assert stubSourceForHelper.contains("public static <T extends Task> T createTask(java.lang.Class<T> type) { return (T)null;}")
+ assert stubSourceForHelper.contains("public final java.util.Map<java.lang.String, java.lang.String> getTest() { return (java.util.Map<java.lang.String, java.lang.String>)null;}")
+ assert stubSourceForHelper.contains("public <T extends java.util.List> T foo() { return (T)null;}")
- assert stubSource.contains("public static <T extends Task> T createTask(java.lang.Class<T> type) { return (T)null;}")
- assert stubSource.contains("public final java.util.Map<java.lang.String, java.lang.String> getTest() { return (java.util.Map<java.lang.String, java.lang.String>)null;}")
+ assert stubSourceForSchedule.contains("public T getCurrentItem() { return (T)null;}")
}
}

0 comments on commit 76d6a47

Please sign in to comment.