This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 607c270 GROOVY-9500: add test case
607c270 is described below
commit 607c27075e9e4a213204355ecca05441945aad48
Author: Eric Milles <[email protected]>
AuthorDate: Sun Oct 17 13:30:39 2021 -0500
GROOVY-9500: add test case
---
.../groovy/transform/stc/GenericsSTCTest.groovy | 38 +++++++++++++++++++---
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 0779304..9a5faa0 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -179,20 +179,20 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
- void testReturnTypeInferenceWithMethodGenerics() {
+ void testReturnTypeInferenceWithMethodGenerics1() {
assertScript '''
List<Long> list = Arrays.asList([0L,0L] as Long[])
'''
}
- void testReturnTypeInferenceWithMethodGenericsAndVarArg() {
+ void testReturnTypeInferenceWithMethodGenerics2() {
assertScript '''
List<Long> list = Arrays.asList(0L,0L)
'''
}
// GROOVY-8638
- void testReturnTypeInferenceWithMethodGenerics17() {
+ void testReturnTypeInferenceWithMethodGenerics3() {
assertScript '''
@Grab('com.google.guava:guava:30.1.1-jre')
import com.google.common.collect.*
@@ -209,7 +209,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
}
// GROOVY-10098
- void testReturnTypeInferenceWithMethodGenerics16() {
+ void testReturnTypeInferenceWithMethodGenerics4() {
assertScript '''
@groovy.transform.TupleConstructor(defaults=false)
class C<T extends Number> {
@@ -223,6 +223,35 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
'''
}
+ // GROOVY-9500
+ void testReturnTypeInferenceWithMethodGenerics5() {
+ assertScript '''
+ trait Entity<D> {
+ }
+ abstract class Path<F extends Entity, T extends Entity> implements
Iterable<Path.Segment<F,T>> {
+ interface Segment<F, T> {
+ F start()
+ T end()
+ }
+ abstract F start()
+ T end() {
+ end // Cannot return value of type Path$Segment<F,T> on
method returning type T
+ }
+ T end
+ @Override
+ void forEach(java.util.function.Consumer<? super Segment<F,
T>> action) {
+ }
+ @Override
+ Spliterator<Segment<F, T>> spliterator() {
+ }
+ @Override
+ Iterator<Segment<F, T>> iterator() {
+ }
+ }
+ null
+ '''
+ }
+
void testDiamondInferrenceFromConstructor1() {
assertScript '''
Set< Long > s2 = new HashSet<>()
@@ -246,6 +275,7 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
Set<Number> s4 = new HashSet<Number>(Arrays.asList(0L,0L))
'''
}
+
// GROOVY-9984
void testDiamondInferrenceFromConstructor5() {
assertScript '''