[ https://issues.apache.org/jira/browse/GROOVY-10768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609682#comment-17609682 ]
Christopher Smith commented on GROOVY-10768: -------------------------------------------- I'll investigate. Following the (tantalizing but brief) main docs on macros, I'm creating my {{MacroClass}} inside a {{@CompileDynamic}} method; the problem results when I take the AST output by it and attach it to a being-compiled class that later gets statically checked. > Macro class should be able to resolve macro-method arguments > ------------------------------------------------------------ > > Key: GROOVY-10768 > URL: https://issues.apache.org/jira/browse/GROOVY-10768 > Project: Groovy > Issue Type: Improvement > Affects Versions: 4.0.5 > Reporter: Christopher Smith > Priority: Major > Attachments: MacroClassExample.png > > > I'm using > [{{MacroClass}}|https://docs.groovy-lang.org/latest/html/documentation/#_macroclass] > to create some boilerplate methods to attach to an annotated class. My > no-arg methods are working perfectly, but I'm having trouble with a static > builder method: > {code:java} > var jat = constX(jsonApiType) > ... in MacroClass ... > public static final com.example.JsonApiResourceId id(java.lang.String value) { > return new com.example.JsonApiResourceId( $v { jat }, value) > }{code} > This produces a (static) compiler error > {code:java} > Cannot find matching method > com.example.JsonApiResourceId#<init>(java.lang.String, java.lang.Object). > Please check if the declared type is correct and if the method exists. {code} > Somehow the method body can't resolve the locally-declared parameter, and > this is "local enough context" that it ought to. -- This message was sent by Atlassian Jira (v8.20.10#820010)