[
https://issues.apache.org/jira/browse/GROOVY-10767?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-10767:
---------------------------------
Fix Version/s: 2.5.19
> Cannot find matching method when trait that implements another trait is
> compiled statically
> -------------------------------------------------------------------------------------------
>
> Key: GROOVY-10767
> URL: https://issues.apache.org/jira/browse/GROOVY-10767
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 3.0.12
> Reporter: Sergey Kachanovskiy
> Assignee: Eric Milles
> Priority: Major
> Labels: traits
> Fix For: 2.5.19, 3.0.14
>
> Attachments: GROOVY-10767.tar.gz
>
>
> I have a trait that implements another trait, and when i try to statically
> compile it with groovy 3.0.12, it throws the following error:
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> B.groovy: 12: [Static type checking] - Cannot find matching method
> <UnionType:test.T+test.B>#methodA(). Please check if the declared type is
> correct and if the method exists.
> @ line 12, column 3.
> methodA()
> ^
> 1 error
> {code}
> test case files attached. compilation:
> {code}
> JAVA_HOME=/groovy-test/jdk8u275-b01 /groovy-test/groovy-3.0.12/bin/groovyc
> -classpath /groovy-test/src B.groovy
> {code}
> all works good with 2.5.14
> when I add A into SelfType in B (so that it looks like @SelfType([T,A]), all
> compiles ok with 3.0.12 too.
> question: can adding A into SelfType be considered a safe workaround,
> provided that no class implementing B ever directly implements A?
> {code:groovy}
> @groovy.transform.TypeChecked
> class Groovy10767 {
> trait A {
> void methodA() {
> }
> }
> @groovy.transform.SelfType(T)
> trait B implements A {
> void methodB() {
> methodA() // Cannot find matching method <UnionType:T+B>#methodA()
> }
> }
> static class C implements B {
> void method() {
> methodA()
> methodB()
> }
> }
> static class T {
> void methodT() {
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)