groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/2] groovy git commit: GROOVY-8289: STC and default value in ctor is causing debugging error (closes #630)
Date Sun, 12 Nov 2017 22:29:55 GMT
Repository: groovy
Updated Branches:
  refs/heads/master ce5c639d5 -> a714e2025


GROOVY-8289: STC and default value in ctor is causing debugging error (closes #630)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b9e3552e
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b9e3552e
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b9e3552e

Branch: refs/heads/master
Commit: b9e3552e0255958aafce9467f1372362a212f1a4
Parents: ce5c639
Author: paulk <paulk@asert.com.au>
Authored: Tue Nov 7 17:37:16 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Mon Nov 13 08:26:36 2017 +1000

----------------------------------------------------------------------
 .../groovy/classgen/AsmClassGenerator.java      |  6 +--
 src/test/groovy/bugs/Groovy8289Bug.groovy       | 43 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/b9e3552e/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 0e18e08..d3f0939 100644
--- a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -434,6 +434,9 @@ public class AsmClassGenerator extends ClassGenerator {
     }
 
     private void visitStdMethod(MethodNode node, boolean isConstructor, Parameter[] parameters,
Statement code) {
+        controller.getCompileStack().init(node.getVariableScope(), parameters);
+        controller.getCallSiteWriter().makeSiteEntry();
+
         MethodVisitor mv = controller.getMethodVisitor();
         final ClassNode superClass = controller.getClassNode().getSuperClass();
         if (isConstructor && (code == null || !((ConstructorNode) node).firstStatementIsSpecialConstructorCall()))
{
@@ -463,9 +466,6 @@ public class AsmClassGenerator extends ClassGenerator {
             }
         }
 
-        controller.getCompileStack().init(node.getVariableScope(), parameters);
-        controller.getCallSiteWriter().makeSiteEntry();
-
         // handle body
         super.visitConstructorOrMethod(node, isConstructor);
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/b9e3552e/src/test/groovy/bugs/Groovy8289Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy8289Bug.groovy b/src/test/groovy/bugs/Groovy8289Bug.groovy
new file mode 100644
index 0000000..2091f66
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8289Bug.groovy
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase
+
+class Groovy8289Bug extends AbstractBytecodeTestCase {
+    void testConstructorLineIndex() {
+        def bytecode= compile(method:'<init>', '''
+            @groovy.transform.CompileStatic
+            class C {
+                String string
+                C(String s = null) { string = s }
+                static void main(args) {
+                    def c = new C('') // put breakpoint on this line, run as Java app, and
step
+                    println c
+                }
+            }
+        ''')
+
+        assert bytecode.hasStrictSequence([
+                'L0',
+                'ALOAD 0',
+                'INVOKESPECIAL java/lang/Object.<init> ()V'
+        ])
+    }
+}


Mime
View raw message