[
https://issues.apache.org/jira/browse/GROOVY-7957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles closed GROOVY-7957.
-------------------------------
Resolution: Information Provided
Similar to GROOVY-7103, a type-checking extension could be used to mark a
property or method call as dynamic. Or a method call could have a method
target set for direct dispatch codegen. A builder could provide a
type-checking extension so the user need not. It could also provide an
annotation collector to add the extension in a possibly-nicer fashion.
If a builder implements {{get(String)}}, {{getProperty(String)}},
{{set(String,Object)}} or {{setProperty(String,Object)}} there is some
allowance in STC. However, {{propertyMissing}} and {{methodMissing}} include
an exception as a common case, so STC does not give a pass for those options.
> Allow static compilation of builders that implement methodMissing /
> propertyMissing
> -----------------------------------------------------------------------------------
>
> Key: GROOVY-7957
> URL: https://issues.apache.org/jira/browse/GROOVY-7957
> Project: Groovy
> Issue Type: New Feature
> Components: GEP
> Reporter: Graeme Rocher
> Priority: Major
>
> Similar to Scala's {{Dynamic}}
> http://www.scala-lang.org/api/current/index.html#scala.Dynamic
> We should be able to write builders that are usable from statically compiled
> code. To achieve this I recommend the following:
> {code}
> // if the object implements methodMissing dispatch to it
> foo.bar("blah") ~~> foo.methodMissing("bar", "blah")
> // if the object implements propertyMissing dispatch to it
> foo.var1 ~~> foo.propertyMissing("var1")
> // if the object implements propertyMissing dispatch to it
> foo.var1 = 10 ~~> foo.propertyMissing("var1", 10)
> {code}
> When combined with GROOVY-7956 it would then be possibly to fully implement
> builders that are compatible with {{@CompileStatic}} and certain existing
> builders could be enhanced to take advantage of this feature {{JsonBuilder}},
> {{MarkupBuilder}} etc.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)