groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: Add `@Generated` to generated methods
Date Fri, 28 Jun 2019 19:38:28 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 536af2d  Add `@Generated` to generated methods
536af2d is described below

commit 536af2d2616e7549d46b0655142381195d7fa776
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sat Jun 29 03:37:41 2019 +0800

    Add `@Generated` to generated methods
---
 .../asm/sc/StaticTypesMethodReferenceExpressionWriter.java  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
index eb45281..9d727f1 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
@@ -20,6 +20,8 @@ package org.codehaus.groovy.classgen.asm.sc;
 
 import groovy.lang.Tuple;
 import groovy.lang.Tuple2;
+import groovy.transform.Generated;
+import org.codehaus.groovy.ast.AnnotationNode;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.MethodNode;
@@ -194,7 +196,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
         ArgumentListExpression args = args(parameters);
         args.getExpressions().add(0, ConstantExpression.NULL);
 
-        return controller.getClassNode().addSyntheticMethod(
+        MethodNode syntheticMethodNode = controller.getClassNode().addSyntheticMethod(
                 "dgsm$$" + mn.getParameters()[0].getType().getName().replace(".", "$") +
"$$" + mn.getName(),
                 Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC,
                 mn.getReturnType(),
@@ -206,12 +208,16 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
                         )
                 )
         );
+
+        syntheticMethodNode.addAnnotation(new AnnotationNode(ClassHelper.make(Generated.class)));
+
+        return syntheticMethodNode;
     }
 
     private MethodNode addSyntheticMethodForConstructorReference(String syntheticMethodName,
ClassNode returnType, Parameter[] parametersWithExactType) {
         ArgumentListExpression ctorArgs = args(parametersWithExactType);
 
-        return controller.getClassNode().addSyntheticMethod(
+        MethodNode syntheticMethodNode = controller.getClassNode().addSyntheticMethod(
                 syntheticMethodName,
                 Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC,
                 returnType,
@@ -232,6 +238,9 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
                 )
         );
 
+        syntheticMethodNode.addAnnotation(new AnnotationNode(ClassHelper.make(Generated.class)));
+
+        return syntheticMethodNode;
     }
 
     private String genSyntheticMethodNameForConstructorReference() {


Mime
View raw message