You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/03/06 18:35:40 UTC
[jira] [Commented] (GROOVY-7640) AST Builder should include
superclass properties
[ https://issues.apache.org/jira/browse/GROOVY-7640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15182244#comment-15182244 ]
ASF GitHub Bot commented on GROOVY-7640:
----------------------------------------
GitHub user PascalSchumacher opened a pull request:
https://github.com/apache/groovy/pull/284
GROOVY-7640:AST Builder should include superclass properties
The code is really ugly, but this is caused by a method with is in `BuilderASTTransformation` but should have been in `ExternalStrategy`. No it can not be moved/modified without breaking binary compatibility.
The pull request is still missing documentation. I will add that if it is accepted.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/PascalSchumacher/incubator-groovy 7640_superclass_prop
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/284.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #284
----
commit 18710b9b155646b9de00d821b12db933311503b7
Author: Marc Bogaerts <ma...@telenet.be>
Date: 2015-10-20T15:14:43Z
GROOVY-7640:AST Builder should include superclass properties
commit fee48bd65d8bf72b440dd66ee5c9735526f060ea
Author: PascalSchumacher <pa...@gmx.net>
Date: 2016-03-06T17:30:12Z
GROOVY-7640:AST Builder should include superclass properties (closes #152)
make it configurable and make it clear that SimpleStrategy does not support this
----
> AST Builder should include superclass properties
> ------------------------------------------------
>
> Key: GROOVY-7640
> URL: https://issues.apache.org/jira/browse/GROOVY-7640
> Project: Groovy
> Issue Type: Bug
> Components: ast builder
> Affects Versions: 2.4.5
> Reporter: Marc Bogaerts
> Priority: Minor
>
> If one annotates a groovy class with @Builder and that class extends from another class, then the generated builder does not support setting the parent class properties.
> This is especially problematic when mixin groovy builders in java code.
> e.g. the following class shows what will and will not compile
> {code:java}
> // Animal.groovy
> import groovy.transform.builder.Builder
> import groovy.transform.builder.SimpleStrategy
> @Builder(builderStrategy = SimpleStrategy)
> class Animal {
> String color
> int legs
> }
> // Pet.groovy
> import groovy.transform.builder.Builder
> import groovy.transform.builder.SimpleStrategy
> @Builder(builderStrategy = SimpleStrategy)
> class Pet extends Animal {
> String name
> }
> // PetTest.java
> import org.junit.Test;
> import static org.junit.Assert.*;
> public class PetTest {
> @Test public void createPet() {
> // Pet pet = new Pet().setColor("white").setLegs(4).setName("Bobby"); does not compile
> Pet pet = (Pet) new Pet().setName("Bobby").setColor("white").setLegs(4);
> assertTrue(pet.getLegs() == 4);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)