From commits-return-7702-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Tue Nov 20 21:06:43 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 7770B18064E for ; Tue, 20 Nov 2018 21:06:42 +0100 (CET) Received: (qmail 16781 invoked by uid 500); 20 Nov 2018 20:06:41 -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 16769 invoked by uid 99); 20 Nov 2018 20:06:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Nov 2018 20:06:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 40156E12E6; Tue, 20 Nov 2018 20:06:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.apache.org Message-Id: <057183f4d311442f89c6590db45b1cee@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: groovy git commit: GROOVY-8895: Traits defining getter conflicts with generated getter Date: Tue, 20 Nov 2018 20:06:41 +0000 (UTC) Repository: groovy Updated Branches: refs/heads/master 1fc3b672d -> 650936ecd GROOVY-8895: Traits defining getter conflicts with generated getter Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/650936ec Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/650936ec Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/650936ec Branch: refs/heads/master Commit: 650936ecd10301f4b0cc37bbe4566a338ac29167 Parents: 1fc3b67 Author: Paul King Authored: Wed Nov 21 06:06:18 2018 +1000 Committer: Paul King Committed: Wed Nov 21 06:06:33 2018 +1000 ---------------------------------------------------------------------- .../groovy/tools/javac/JavaStubGenerator.java | 2 +- .../TraitAbstractGetterStubTest.groovy | 68 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/650936ec/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java index 0c1acbd..4b9efbb 100644 --- a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java +++ b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java @@ -337,7 +337,7 @@ public class JavaStubGenerator { } } } - if (method==null) { + if (method==null && !traitMethod.isAbstract()) { printMethod(out, classNode, traitMethod); } } http://git-wip-us.apache.org/repos/asf/groovy/blob/650936ec/src/test/org/codehaus/groovy/tools/stubgenerator/TraitAbstractGetterStubTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/org/codehaus/groovy/tools/stubgenerator/TraitAbstractGetterStubTest.groovy b/src/test/org/codehaus/groovy/tools/stubgenerator/TraitAbstractGetterStubTest.groovy new file mode 100644 index 0000000..d2df4c5 --- /dev/null +++ b/src/test/org/codehaus/groovy/tools/stubgenerator/TraitAbstractGetterStubTest.groovy @@ -0,0 +1,68 @@ +/* + * 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 org.codehaus.groovy.tools.stubgenerator + +/** + * GROOVY-8895: Checks that a trait with an abstract getter isn't included in stub by mistake + */ +class TraitAbstractGetterStubTest extends StringSourcesStubTestCase { + + @Override + Map provideSources() { + [ + 'Foo8895.java': ''' + public class Foo8895 { } + ''', + + 'GetFoo.groovy': ''' + trait GetFoo { + abstract Foo8895 getFoo() + } + ''', + + 'BaseFooSpec.groovy': ''' + class BaseFooSpec { + Foo8895 foo = new Foo8895() + } + ''', + + 'FooSpec.groovy': ''' + class FooSpec extends BaseFooSpec implements GetFoo { } + ''', + + 'Control.groovy': ''' + class Control implements GetFoo { } + ''', + ] + } + +// protected void init() { +// debug = true +// delete = false +// } + + @Override + void verifyStubs() { + String stubSource = stubJavaSourceFor('FooSpec') + assert !stubSource.contains('Foo8895 getFoo()') + stubSource = stubJavaSourceFor('Control') + assert !stubSource.contains('Foo8895 getFoo()') + } + +}