File tree Expand file tree Collapse file tree
base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform
org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc
org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc
org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2867,4 +2867,27 @@ public void testTypeChecked10091() {
28672867 "Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<X> to: groovy.lang.Closure<A<java.lang.Number>>\n " +
28682868 "----------\n " );
28692869 }
2870+
2871+ @ Test
2872+ public void testTypeChecked10098 () {
2873+ //@formatter:off
2874+ String [] sources = {
2875+ "C.groovy" ,
2876+ "@groovy.transform.TupleConstructor(defaults=false)\n " +
2877+ "class C<T extends Number> {\n " +
2878+ " T p\n " +
2879+ " @groovy.transform.TypeChecked\n " +
2880+ " T test() {\n " +
2881+ " Closure<T> x = { -> p }\n " +
2882+ " x()\n " + // Cannot return value of type Object on method returning type T
2883+ " }\n " +
2884+ " static main(args) {\n " +
2885+ " print new C<>(42).test()\n " +
2886+ " }\n " +
2887+ "}\n " ,
2888+ };
2889+ //@formatter:on
2890+
2891+ runConformTest (sources , "42" );
2892+ }
28702893}
Original file line number Diff line number Diff line change @@ -3964,12 +3964,21 @@ public void visitMethodCallExpression(MethodCallExpression call) {
39643964 ClassNode type = getType (((ASTNode ) variable ));
39653965 if (type != null && type .equals (CLOSURE_TYPE )) {
39663966 GenericsType [] genericsTypes = type .getGenericsTypes ();
3967+ /* GRECLIPSE edit -- GROOVY-10098
39673968 type = OBJECT_TYPE;
39683969 if (genericsTypes != null) {
39693970 if (!genericsTypes[0].isPlaceholder()) {
39703971 type = genericsTypes[0].getType();
39713972 }
39723973 }
3974+ */
3975+ if (genericsTypes != null && genericsTypes .length == 1
3976+ && genericsTypes [0 ].getLowerBound () == null ) {
3977+ type = getCombinedBoundType (genericsTypes [0 ]);
3978+ } else {
3979+ type = OBJECT_TYPE ;
3980+ }
3981+ // GRECLIPSE end
39733982 }
39743983 if (type != null ) {
39753984 storeType (call , type );
Original file line number Diff line number Diff line change @@ -3674,12 +3674,21 @@ public void visitMethodCallExpression(final MethodCallExpression call) {
36743674 ClassNode type = getType (((ASTNode ) variable ));
36753675 if (type != null && type .equals (CLOSURE_TYPE )) {
36763676 GenericsType [] genericsTypes = type .getGenericsTypes ();
3677+ /* GRECLIPSE edit -- GROOVY-10098
36773678 type = OBJECT_TYPE;
36783679 if (genericsTypes != null) {
36793680 if (!genericsTypes[0].isPlaceholder()) {
36803681 type = genericsTypes[0].getType();
36813682 }
36823683 }
3684+ */
3685+ if (genericsTypes != null && genericsTypes .length == 1
3686+ && genericsTypes [0 ].getLowerBound () == null ) {
3687+ type = getCombinedBoundType (genericsTypes [0 ]);
3688+ } else {
3689+ type = OBJECT_TYPE ;
3690+ }
3691+ // GRECLIPSE end
36833692 }
36843693 if (type != null ) {
36853694 storeType (call , type );
Original file line number Diff line number Diff line change @@ -3587,10 +3587,19 @@ public void visitMethodCallExpression(final MethodCallExpression call) {
35873587 ClassNode type = getType (((ASTNode ) variable ));
35883588 if (CLOSURE_TYPE .equals (type )) {
35893589 GenericsType [] genericsTypes = type .getGenericsTypes ();
3590+ /* GRECLIPSE edit -- GROOVY-10098
35903591 type = OBJECT_TYPE;
35913592 if (genericsTypes != null && !genericsTypes[0].isPlaceholder()) {
35923593 type = genericsTypes[0].getType();
35933594 }
3595+ */
3596+ if (genericsTypes != null && genericsTypes .length == 1
3597+ && genericsTypes [0 ].getLowerBound () == null ) {
3598+ type = getCombinedBoundType (genericsTypes [0 ]);
3599+ } else {
3600+ type = OBJECT_TYPE ;
3601+ }
3602+ // GRECLIPSE end
35943603 }
35953604 if (type != null ) {
35963605 storeType (call , type );
You can’t perform that action at this time.
0 commit comments