[
https://issues.apache.org/jira/browse/GROOVY-11862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles resolved GROOVY-11862.
----------------------------------
Fix Version/s: 5.0.5
Resolution: Fixed
https://github.com/apache/groovy/commit/96cca630de57467d7af13e4b069ba4382062c40c
> trait field initializer results in setter call error
> ----------------------------------------------------
>
> Key: GROOVY-11862
> URL: https://issues.apache.org/jira/browse/GROOVY-11862
> Project: Groovy
> Issue Type: Bug
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
> Labels: traits
> Fix For: 5.0.5
>
>
> Consider the following:
> {code:groovy}
> trait T {
> final Number n = 42
> static Short s = 24
> }
> class C implements T {
> }
> new C()
> {code}
> The narrowing conversion in the "s" field initializer produces the following
> error at runtime:
> {code}
> Caught: java.lang.ExceptionInInitializerError
> java.lang.ExceptionInInitializerError
> at Scratch.run(Scratch.groovy:9)
> Caused by: groovy.lang.MissingMethodException: No signature of static method:
> T__s$set for class: C is applicable for argument types: (Integer) values: [24]
> Possible solutions: T__s$set(java.lang.Short), T__s$get(),
> T__n$set(java.lang.Number), T__n$get()
> at T$Trait$Helper.$static$init$(Scratch.groovy:3)
> at C.<clinit>(Scratch.groovy)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)