[ 
https://issues.apache.org/jira/browse/GROOVY-8219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17756543#comment-17756543
 ] 

Paul King edited comment on GROOVY-8219 at 8/20/23 1:46 PM:
------------------------------------------------------------

[~emilles] We don't cover this case?
{code}
import groovy.transform.TupleConstructor

trait T {
    Number n1
    Number n2 = 10
}
@TupleConstructor(allProperties=true, includes='s,n1,n2')
class C implements T {
    String s
}
def obj = new C('answer',42)
assert obj.s == 'answer'
assert obj.n1 == 42
assert obj.n2 == null // should be 10
{code}
Should I raise another issue?


was (Author: paulk):
We don't cover this case?
{code}
import groovy.transform.TupleConstructor

trait T {
    Number n1
    Number n2 = 10
}
@TupleConstructor(allProperties=true, includes='s,n1,n2')
class C implements T {
    String s
}
def obj = new C('answer',42)
assert obj.s == 'answer'
assert obj.n1 == 42
assert obj.n2 == null // should be 10
{code}
Should I raise another issue?

> Add @TupleConstructor(includeFields = true) to a class implements a trait 
> which contains properties will cause NPE
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8219
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8219
>             Project: Groovy
>          Issue Type: Bug
>          Components: xforms
>    Affects Versions: 2.4.11
>            Reporter: Huabin Zhang
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: breaking, trait, traits
>             Fix For: 5.0.0-alpha-1
>
>
> Hi, guys:
> I got NPE when I wrote the following codes:
> {code:java|title=Groovy Script|borderStyle=solid}
> trait T {
>     def x = 'abc'
> }
> import groovy.transform.TupleConstructor
> @TupleConstructor(includeFields = true)
> class A implements T {
>     def a
>     private b
> }
> assert 'ABC' == new A().x.toUpperCase()
> {code}
> I found that it will works well if I remove {{(includefields = true)}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to