You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/11/13 02:44:38 UTC
[3/5] groovy git commit: GROOVY-8289: STC and default value in ctor
is causing debugging error (closes #630)
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/8aac16a0
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8aac16a0
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8aac16a0
Branch: refs/heads/GROOVY_2_6_X
Commit: 8aac16a053bd3b5c8a6ac4be2a236feb4e113cfb
Parents: 45aa4b3
Author: paulk <pa...@asert.com.au>
Authored: Tue Nov 7 17:37:16 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Nov 13 12:44:07 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/8aac16a0/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/8aac16a0/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'
+ ])
+ }
+}