Skip to content

Commit 9c2f026

Browse files
committed
GROOVY-9903
1 parent 5f81782 commit 9c2f026

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2020 the original author or authors.
2+
* Copyright 2009-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -632,4 +632,29 @@ public void testTypeChecked9873() {
632632

633633
runConformTest(sources, "123", options);
634634
}
635+
636+
@Test
637+
public void testTypeChecked9903() {
638+
//@formatter:off
639+
String[] sources = {
640+
"Main.groovy",
641+
"def m(@DelegatesTo(strategy=Closure.TO_SELF) Closure<Object> c) {\n" +
642+
"}\n" +
643+
"@groovy.transform.TypeChecked\n" +
644+
"def x() {\n" +
645+
" m {" +
646+
" }\n" +
647+
"}\n",
648+
};
649+
//@formatter:on
650+
651+
runNegativeTest(sources,
652+
"----------\n" +
653+
"1. ERROR in Main.groovy (at line 1)\n" +
654+
"\tdef m(@DelegatesTo(strategy=Closure.TO_SELF) Closure<Object> c) {\n" +
655+
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
656+
"Groovy:Not enough arguments found for a @DelegatesTo method call. Please check " +
657+
"that you either use an explicit class or @DelegatesTo.Target with a correct id\n" +
658+
"----------\n");
659+
}
635660
}

base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3451,7 +3451,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver,
34513451
}
34523452
}
34533453
if (expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA) == null) {
3454-
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", arguments);
3454+
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", annotation);
34553455
}
34563456
}
34573457
}

base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3249,7 +3249,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver, final MethodN
32493249
}
32503250
}
32513251
if (expression.getNodeMetaData(DELEGATION_METADATA) == null) {
3252-
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", arguments);
3252+
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", annotation);
32533253
}
32543254
}
32553255
}

base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver, final MethodN
32343234
}
32353235
}
32363236
if (expression.getNodeMetaData(DELEGATION_METADATA) == null) {
3237-
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", arguments);
3237+
addError("Not enough arguments found for a @DelegatesTo method call. Please check that you either use an explicit class or @DelegatesTo.Target with a correct id", annotation);
32383238
}
32393239
}
32403240
}

0 commit comments

Comments
 (0)