Skip to content

Commit

Permalink
GROOVY-9903
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jan 20, 2021
1 parent 5f81782 commit 9c2f026
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2020 the original author or authors.
* Copyright 2009-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -632,4 +632,29 @@ public void testTypeChecked9873() {

runConformTest(sources, "123", options);
}

@Test
public void testTypeChecked9903() {
//@formatter:off
String[] sources = {
"Main.groovy",
"def m(@DelegatesTo(strategy=Closure.TO_SELF) Closure<Object> c) {\n" +
"}\n" +
"@groovy.transform.TypeChecked\n" +
"def x() {\n" +
" m {" +
" }\n" +
"}\n",
};
//@formatter:on

runNegativeTest(sources,
"----------\n" +
"1. ERROR in Main.groovy (at line 1)\n" +
"\tdef m(@DelegatesTo(strategy=Closure.TO_SELF) Closure<Object> c) {\n" +
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Groovy: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\n" +
"----------\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver,
}
}
if (expression.getNodeMetaData(StaticTypesMarker.DELEGATION_METADATA) == null) {
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);
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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver, final MethodN
}
}
if (expression.getNodeMetaData(DELEGATION_METADATA) == null) {
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);
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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3234,7 +3234,7 @@ private void checkClosureWithDelegatesTo(final ClassNode receiver, final MethodN
}
}
if (expression.getNodeMetaData(DELEGATION_METADATA) == null) {
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);
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);
}
}
}
Expand Down

0 comments on commit 9c2f026

Please sign in to comment.