Github user mgroovy commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/686#discussion_r182731442
  
    --- Diff: 
src/main/java/org/codehaus/groovy/transform/NewifyASTTransformation.java ---
    @@ -286,31 +372,106 @@ private static boolean 
isNewMethodStyle(MethodCallExpression mce) {
                     && ((ConstantExpression) meth).getValue().equals("new"));
         }
     
    -    private Expression transformMethodCall(MethodCallExpression mce, 
Expression args) {
    +    private Expression transformMethodCall(MethodCallExpression mce, 
Expression argsExp) {
             ClassNode classType;
    +
             if (isNewMethodStyle(mce)) {
                 classType = mce.getObjectExpression().getType();
    -        } else {
    +        }
    +        else {
                 classType = findMatchingCandidateClass(mce);
             }
    +        
             if (classType != null) {
    -            return new ConstructorCallExpression(classType, args);
    +            Expression argsToUse = argsExp;
    +            //if(classType.getOuterClass() != null && 
!classType.isStaticClass()) {
    +            if(classType.getOuterClass() != null && 
((classType.getModifiers() & org.objectweb.asm.Opcodes.ACC_STATIC) == 0)) {
    +                if(!(argsExp instanceof ArgumentListExpression)) {
    +                    addError("Non-static inner constructor arguments must 
be an argument list expression; pass 'this' pointer explicitely as first 
constructor argument otherwise.", mce);
    +                    return mce; // TODO: Expected behavior to return  the 
untransformed method call here ?
    --- End diff --
    
    This is the first Groovy extension I am doing on my own, and I took this 
code part from existing Groovy code, and wanted to make sure somebody more 
experienced had a look at this. If you say this code is fine, then the TODO can 
be removed (see above comment).


---

Reply via email to