File tree 4 files changed +50
-0
lines changed
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
base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform
4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -2867,4 +2867,27 @@ public void testTypeChecked10091() {
2867
2867
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<X> to: groovy.lang.Closure<A<java.lang.Number>>\n " +
2868
2868
"----------\n " );
2869
2869
}
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
+ }
2870
2893
}
Original file line number Diff line number Diff line change @@ -3964,12 +3964,21 @@ public void visitMethodCallExpression(MethodCallExpression call) {
3964
3964
ClassNode type = getType (((ASTNode ) variable ));
3965
3965
if (type != null && type .equals (CLOSURE_TYPE )) {
3966
3966
GenericsType [] genericsTypes = type .getGenericsTypes ();
3967
+ /* GRECLIPSE edit -- GROOVY-10098
3967
3968
type = OBJECT_TYPE;
3968
3969
if (genericsTypes != null) {
3969
3970
if (!genericsTypes[0].isPlaceholder()) {
3970
3971
type = genericsTypes[0].getType();
3971
3972
}
3972
3973
}
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
3973
3982
}
3974
3983
if (type != null ) {
3975
3984
storeType (call , type );
Original file line number Diff line number Diff line change @@ -3674,12 +3674,21 @@ public void visitMethodCallExpression(final MethodCallExpression call) {
3674
3674
ClassNode type = getType (((ASTNode ) variable ));
3675
3675
if (type != null && type .equals (CLOSURE_TYPE )) {
3676
3676
GenericsType [] genericsTypes = type .getGenericsTypes ();
3677
+ /* GRECLIPSE edit -- GROOVY-10098
3677
3678
type = OBJECT_TYPE;
3678
3679
if (genericsTypes != null) {
3679
3680
if (!genericsTypes[0].isPlaceholder()) {
3680
3681
type = genericsTypes[0].getType();
3681
3682
}
3682
3683
}
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
3683
3692
}
3684
3693
if (type != null ) {
3685
3694
storeType (call , type );
Original file line number Diff line number Diff line change @@ -3587,10 +3587,19 @@ public void visitMethodCallExpression(final MethodCallExpression call) {
3587
3587
ClassNode type = getType (((ASTNode ) variable ));
3588
3588
if (CLOSURE_TYPE .equals (type )) {
3589
3589
GenericsType [] genericsTypes = type .getGenericsTypes ();
3590
+ /* GRECLIPSE edit -- GROOVY-10098
3590
3591
type = OBJECT_TYPE;
3591
3592
if (genericsTypes != null && !genericsTypes[0].isPlaceholder()) {
3592
3593
type = genericsTypes[0].getType();
3593
3594
}
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
3594
3603
}
3595
3604
if (type != null ) {
3596
3605
storeType (call , type );
You can’t perform that action at this time.
0 commit comments