groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch GROOVY_2_5_X updated: GROOVY-9266: added closure annotations to DefaultGroovyMethods.metaClass
Date Tue, 12 Nov 2019 00:42:06 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new 8baecc3  GROOVY-9266: added closure annotations to DefaultGroovyMethods.metaClass
8baecc3 is described below

commit 8baecc36cc01c23f54b070f1a80888e824dca033
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Wed Oct 2 13:16:11 2019 -0500

    GROOVY-9266: added closure annotations to DefaultGroovyMethods.metaClass
    
    and ExpandoMetaClass.define
---
 src/main/groovy/groovy/lang/ExpandoMetaClass.java                   | 5 ++++-
 src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | 6 ++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/main/groovy/groovy/lang/ExpandoMetaClass.java b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
index a4482c2..93dc584 100644
--- a/src/main/groovy/groovy/lang/ExpandoMetaClass.java
+++ b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
@@ -18,6 +18,8 @@
  */
 package groovy.lang;
 
+import groovy.transform.stc.ClosureParams;
+import groovy.transform.stc.SimpleType;
 import org.codehaus.groovy.reflection.CachedClass;
 import org.codehaus.groovy.reflection.MixinInMetaClass;
 import org.codehaus.groovy.runtime.DefaultCachedMethodKey;
@@ -796,7 +798,8 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject
{
         }
     }
 
-    public ExpandoMetaClass define(Closure closure) {
+    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);
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index a86a819..bfa7d93 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -17325,7 +17325,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @throws GroovyRuntimeException if the metaclass can't be set for this class
      * @since 1.6.0
      */
-    public static MetaClass metaClass (Class self, Closure closure){
+    public static MetaClass metaClass(Class self, @ClosureParams(value=SimpleType.class,
options="java.lang.Object")
+            @DelegatesTo(type="groovy.lang.ExpandoMetaClass.DefiningClosure", strategy=Closure.DELEGATE_ONLY)
Closure closure) {
         MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
         MetaClass mc = metaClassRegistry.getMetaClass(self);
 
@@ -17372,7 +17373,8 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @throws GroovyRuntimeException if the metaclass can't be set for this object
      * @since 1.6.0
      */
-    public static MetaClass metaClass (Object self, Closure closure){
+    public static MetaClass metaClass(Object self, @ClosureParams(value=SimpleType.class,
options="java.lang.Object")
+            @DelegatesTo(type="groovy.lang.ExpandoMetaClass.DefiningClosure", strategy=Closure.DELEGATE_ONLY)
Closure closure) {
         MetaClass emc = hasPerInstanceMetaClass(self);
         if (emc == null) {
             final ExpandoMetaClass metaClass = new ExpandoMetaClass(self.getClass(), false,
true);


Mime
View raw message