Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.17, 2.5.8, 3.0.0-beta-3
-
None
-
None
Description
The two "metaClass" methods of DefaultGroovyMethods accept a Closure but do not indicate delegate or parameter metadata.
public static MetaClass metaClass(Class self, Closure closure) ... public static MetaClass metaClass(Object self, Closure closure) ...
Both methods pass the closure to ExpandoMetaClass.define which also lacks metadata. Here is the proposed change to that method, which could be propagated to the DGMs:
public ExpandoMetaClass define(@ClosureParams(value=SimpleType.class, options="java.lang.Object") @DelegatesTo(value=DefiningClosure.class, strategy=Closure.DELEGATE_ONLY) Closure closure) { final DefiningClosure definer = new DefiningClosure(); Object delegate = closure.getDelegate(); closure.setDelegate(definer); closure.setResolveStrategy(Closure.DELEGATE_ONLY); closure.call((Object)null); closure.setDelegate(delegate); closure.setResolveStrategy(Closure.DELEGATE_FIRST); definer.definition = false; return this; }
Note: Not sure exactly how to indicate that the parameter is "null" or if that's important.
Attachments
Issue Links
- links to