You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2018/06/01 17:57:00 UTC
[jira] [Created] (GROOVY-8627) Compile error using NamedParam with
value
Eric Milles created GROOVY-8627:
-----------------------------------
Summary: Compile error using NamedParam with value
Key: GROOVY-8627
URL: https://issues.apache.org/jira/browse/GROOVY-8627
Project: Groovy
Issue Type: Bug
Affects Versions: 2.5.0
Reporter: Eric Milles
{{NamedVariantASTTransformation}} has bug checking for presence of {{value}} member.
{code:java}
for (Parameter fromParam : fromParams) {
if (AnnotatedNodeUtils.hasAnnotation(fromParam, NAMED_PARAM_TYPE)) {
AnnotationNode namedParam = fromParam.getAnnotations(NAMED_PARAM_TYPE).get(0);
boolean required = memberHasValue(namedParam, "required", true);
if (getMemberValue(namedParam, "name") == null) {
namedParam.addMember("value", constX(fromParam.getName()));
}
String name = getMemberStringValue(namedParam, "value");
{code}
Check here is for {{name}} and if not found, fill in {{value}} from name of annotated param. There are 2 problems with this:
1. {{NamedParam}} has no {{name}} member
2. {{NamedParam}} indicates {{value}} as required (no default value provided in declaration)
Example that produces error:
{code:groovy}
import groovy.transform.*
@ToString(includeNames=true)
class Color {
Integer r, g, b
}
@NamedVariant\n" +
String m(@NamedDelegate Color color, @NamedParam(value='a', required=true) int alpha) {
return [color, alpha].join(' ')
}
print m(r:1, g:2, b:3, a: 0)
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)