Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reported on subclass of a class implementing trait #673

Closed
mauromol opened this issue Aug 13, 2018 · 3 comments
Closed

Error reported on subclass of a class implementing trait #673

mauromol opened this issue Aug 13, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@mauromol
Copy link

Consider the following:

package test30

import groovy.transform.CompileStatic

@CompileStatic
trait T {
	String getFoo() { 'foo' }
}
package test30

import groovy.transform.CompileStatic

@CompileStatic
class A implements T {
}
package test30

import groovy.transform.CompileStatic

@CompileStatic
class B extends A {
}

And:

package test30

import groovy.transform.CompileStatic

@CompileStatic
class Test30 {

	static void main(args) {
		println new B().foo
	}

}

Greclipse is reporting an error on B:

Groovy:Can't have an abstract method in a non-abstract class. The class 'test30.B' must be declared abstract or the method 'java.lang.String getFoo()' must be implemented.

I don't expect this error. Also, the Groovy compiler seems to compile this code and if I run Test30 I get the expected result.

@eric-milles eric-milles self-assigned this Aug 13, 2018
@eric-milles
Copy link
Member

This method in JDTClassNode is mixing in the abstract modifier for interfaces (aka traits). Looks like it needs a check for traits.

    private MethodNode methodBindingToMethodNode(MethodBinding methodBinding) {
        try {
            int modifiers = methodBinding.modifiers;
            if (jdtBinding.isInterface() && !Flags.isStatic(modifiers) && !Flags.isSynthetic(modifiers) && !Flags.isDefaultMethod(modifiers)) {
                modifiers |= Flags.AccAbstract;
            }

@eric-milles
Copy link
Member

Ready to test

@mauromol
Copy link
Author

Tested with 3.1.0.xx-201808132239-e48, works both on this test case and on my real project, thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants