From commits-return-7797-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Dec 17 03:05:21 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 13438180676 for ; Mon, 17 Dec 2018 03:05:20 +0100 (CET) Received: (qmail 18764 invoked by uid 500); 17 Dec 2018 02:05:20 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 18755 invoked by uid 99); 17 Dec 2018 02:05:20 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2018 02:05:20 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 59BD185289; Mon, 17 Dec 2018 02:05:19 +0000 (UTC) Date: Mon, 17 Dec 2018 02:05:19 +0000 To: "commits@groovy.apache.org" Subject: [groovy] branch master updated: GROOVY-8914: Error compiling static inner class that extends some other (static) inner class MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154501231922.31926.3026517406296040229@gitbox.apache.org> From: paulk@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 2d17694153d787f8a9c9712d94165e9891a7f29a X-Git-Newrev: 1feb8aff09f90a82d217b60cb8b555f67d2469b5 X-Git-Rev: 1feb8aff09f90a82d217b60cb8b555f67d2469b5 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. paulk 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 1feb8af GROOVY-8914: Error compiling static inner class that extends some other (static) inner class 1feb8af is described below commit 1feb8aff09f90a82d217b60cb8b555f67d2469b5 Author: Paul King AuthorDate: Mon Dec 17 12:04:54 2018 +1000 GROOVY-8914: Error compiling static inner class that extends some other (static) inner class --- .../classgen/InnerClassCompletionVisitor.java | 11 ++++++++++- src/test/gls/innerClass/InnerClassTest.groovy | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java index a8d84c8..4e07503 100644 --- a/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java +++ b/src/main/java/org/codehaus/groovy/classgen/InnerClassCompletionVisitor.java @@ -348,7 +348,7 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme private void addCompilationErrorOnCustomMethodNode(InnerClassNode node, String methodName, Parameter[] parameters) { MethodNode existingMethodNode = node.getMethod(methodName, parameters); // if there is a user-defined methodNode, add compiler error msg and continue - if (existingMethodNode != null && !existingMethodNode.isSynthetic()) { + if (existingMethodNode != null && !isSynthetic(existingMethodNode)) { addError("\"" +methodName + "\" implementations are not supported on static inner classes as " + "a synthetic version of \"" + methodName + "\" is added during compilation for the purpose " + "of outer class delegation.", @@ -356,6 +356,15 @@ public class InnerClassCompletionVisitor extends InnerClassVisitorHelper impleme } } + // GROOVY-8914: pre-compiled classes lose synthetic boolean - TODO fix earlier as per GROOVY-4346 then remove extra check here + private boolean isSynthetic(MethodNode existingMethodNode) { + return existingMethodNode.isSynthetic() || hasSyntheticModifier(existingMethodNode); + } + + private boolean hasSyntheticModifier(MethodNode existingMethodNode) { + return (existingMethodNode.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0; + } + private void addThisReference(ConstructorNode node) { if (!shouldHandleImplicitThisForInnerClass(classNode)) return; Statement code = node.getCode(); diff --git a/src/test/gls/innerClass/InnerClassTest.groovy b/src/test/gls/innerClass/InnerClassTest.groovy index 811f148..9a0d6ad 100644 --- a/src/test/gls/innerClass/InnerClassTest.groovy +++ b/src/test/gls/innerClass/InnerClassTest.groovy @@ -727,6 +727,27 @@ import org.codehaus.groovy.classgen.Verifier null ''' } + + //GROOVY-8914 + void testNestedClassInheritingFromNestedClass() { + // control + assert new Outer8914.Nested() + + assertScript ''' + class OuterReferencingPrecompiled { + static class Nested extends gls.innerClass.Parent8914.Nested {} + } + assert new OuterReferencingPrecompiled.Nested() + ''' + } +} + +class Parent8914 { + static class Nested {} +} + +class Outer8914 { + static class Nested extends Parent8914.Nested {} } class MyOuterClass4028 {