Eric Milles created GROOVY-11862:
------------------------------------
Summary: 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
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)