You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Arnaud CAVAILHEZ (JIRA)" <ji...@apache.org> on 2016/05/22 19:01:12 UTC
[jira] [Created] (GROOVY-7843) Trait method calling closure cannot
be inherited while using CompileStatic
Arnaud CAVAILHEZ created GROOVY-7843:
----------------------------------------
Summary: Trait method calling closure cannot be inherited while using CompileStatic
Key: GROOVY-7843
URL: https://issues.apache.org/jira/browse/GROOVY-7843
Project: Groovy
Issue Type: Bug
Reporter: Arnaud CAVAILHEZ
Priority: Minor
A trait extending another and calling itself more than 3 times:
```@CompileStatic
trait UpperTrait {
void call(Closure body){
body()
}
}```
```@CompileStatic
trait LowerTrait extends UpperTrait {
void threeCalls() {
call {
call {
call {
}
}
}
}
}```
Will generate a `ClassCastException` when called:
```class ImplementsTrait implements LowerTrait {
}
new ImplementsTrait().threeCalls()
```
raises:
```Caught: java.lang.ClassCastException: LowerTrait$Trait$Helper$_threeCalls_closure1 cannot be cast to UpperTrait
java.lang.ClassCastException: LowerTrait$Trait$Helper$_threeCalls_closure1 cannot be cast to UpperTrait
at LowerTrait$Trait$Helper$_threeCalls_closure1$_closure2.doCall(LowerTrait.groovy:9)
etc..```
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)