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/ast
org.codehaus.groovy30/src/org/codehaus/groovy/ast
org.codehaus.groovy40/src/org/codehaus/groovy/ast Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5560,4 +5560,24 @@ public void testTypeChecked10525() {
55605560
55615561 runConformTest (sources );
55625562 }
5563+
5564+ @ Test
5565+ public void testTypeChecked10556 () {
5566+ for (String self : new String [] {"(B) this" , "this as B" }) {
5567+ //@formatter:off
5568+ String [] sources = {
5569+ "Main.groovy" ,
5570+ "@groovy.transform.TypeChecked\n " +
5571+ "abstract class A<B extends A<B,X>,X> {\n " +
5572+ " B m() {\n " +
5573+ " " + self + "\n " +
5574+ " }\n " +
5575+ "}\n " +
5576+ "(new A(){}).m()\n " ,
5577+ };
5578+ //@formatter:on
5579+
5580+ runConformTest (sources );
5581+ }
5582+ }
55635583}
Original file line number Diff line number Diff line change @@ -337,6 +337,9 @@ private boolean checkGenerics(final ClassNode classNode) {
337337 */
338338 private boolean compareGenericsWithBound (final ClassNode classNode , final ClassNode bound ) {
339339 if (classNode ==null ) return false ;
340+ // GRECLIPSE add -- GROOVY-10556: "T" vs "C<T extends C<?>>" bound
341+ if (classNode .isGenericsPlaceHolder ()) return true ;
342+ // GRECLIPSE end
340343 if (bound .getGenericsTypes () == null || (classNode .getGenericsTypes ()==null && classNode .redirect ().getGenericsTypes ()!=null )) {
341344 // if the bound is not using generics, there's nothing to compare with
342345 return true ;
Original file line number Diff line number Diff line change @@ -323,13 +323,13 @@ private boolean checkGenerics(final ClassNode classNode) {
323323 * @return true if generics are compatible
324324 */
325325 private static boolean compareGenericsWithBound (final ClassNode classNode , final ClassNode bound ) {
326- if (classNode == null ) {
327- return false ;
328- }
329- if ( bound . getGenericsTypes () == null || (classNode .getGenericsTypes () == null && classNode .redirect ().getGenericsTypes () != null )) {
330- // if the bound is not using generics or the class node is a raw type, there's nothing to compare with
326+ if (classNode == null ) return false ;
327+ if ( bound . getGenericsTypes () == null
328+ || classNode . isGenericsPlaceHolder () // GROOVY-10556: "T" vs "C<T extends C<?>>" bound
329+ || (classNode .getGenericsTypes () == null && classNode .redirect ().getGenericsTypes () != null ))
330+ // if the bound is not using generics or the class node is a raw type, there's nothing to compare
331331 return true ;
332- }
332+
333333 if (!classNode .equals (bound )) {
334334 // the class nodes are on different types
335335 // in this situation, we must choose the correct execution path : either the bound
Original file line number Diff line number Diff line change @@ -324,13 +324,13 @@ private boolean checkGenerics(final ClassNode classNode) {
324324 * @return true if generics are compatible
325325 */
326326 private static boolean compareGenericsWithBound (final ClassNode classNode , final ClassNode bound ) {
327- if (classNode == null ) {
328- return false ;
329- }
330- if ( bound . getGenericsTypes () == null || (classNode .getGenericsTypes () == null && classNode .redirect ().getGenericsTypes () != null )) {
331- // if the bound is not using generics or the class node is a raw type, there's nothing to compare with
327+ if (classNode == null ) return false ;
328+ if ( bound . getGenericsTypes () == null
329+ || classNode . isGenericsPlaceHolder () // GROOVY-10556: "T" vs "C<T extends C<?>>" bound
330+ || (classNode .getGenericsTypes () == null && classNode .redirect ().getGenericsTypes () != null ))
331+ // if the bound is not using generics or the class node is a raw type, there's nothing to compare
332332 return true ;
333- }
333+
334334 if (!classNode .equals (bound )) {
335335 // the class nodes are on different types
336336 // in this situation, we must choose the correct execution path : either the bound
You can’t perform that action at this time.
0 commit comments