Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.12
Description
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:
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
test case files attached. compilation:
JAVA_HOME=/groovy-test/jdk8u275-b01 /groovy-test/groovy-3.0.12/bin/groovyc -classpath /groovy-test/src B.groovy
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?
@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() { } } }
Attachments
Attachments
Issue Links
- is fixed by
-
GROOVY-10700 STC cannot locate method specified by interface but supplied by AST transform
- Closed