diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java index cc9660879d..46725ad1b2 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java @@ -2936,7 +2936,7 @@ public void testTraitBasics() throws Exception { expectingNoProblems(); } - @Test + @Test // https://github.com/groovy/groovy-eclipse/issues/1267 public void testTraitBasics2() throws Exception { IPath[] paths = createSimpleProject("Project", true); @@ -2947,7 +2947,11 @@ public void testTraitBasics2() throws Exception { "}\n"); IPath d = env.addGroovyClass(paths[1], "p", "D", "package p\n" + + "@groovy.transform.TypeChecked\n" + "class D extends C {\n" + + " void test() {\n" + + " proc()\n" + + " }\n" + "}\n"); env.addGroovyClass(paths[1], "p", "T", "package p\n" + diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 6e2142c639..90855ff2d7 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -5371,7 +5371,9 @@ protected List findMethodsWithGenerated(ClassNode receiver, String n } else { List interfaceMethods = new ArrayList<>(); collectAllInterfaceMethodsByName(receiver, name, interfaceMethods); - interfaceMethods.stream().filter(MethodNode::isDefault).forEach(methods::add); + interfaceMethods.stream().filter(mn -> mn.isDefault() || (mn.isPublic() + && !mn.isStatic() && !mn.isAbstract() && Traits.isTrait(mn.getDeclaringClass())) + ).forEach(methods::add); } if (receiver.isInterface()) { methods.addAll(OBJECT_TYPE.getMethods(name)); diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index f535b047a2..74fc32a77c 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -5143,7 +5143,13 @@ protected List findMethodsWithGenerated(final ClassNode receiver, fi } else { // GROOVY-9890: always search for default methods List interfaceMethods = new ArrayList<>(); collectAllInterfaceMethodsByName(receiver, name, interfaceMethods); + /* GRECLIPSE edit interfaceMethods.stream().filter(MethodNode::isDefault).forEach(methods::add); + */ + interfaceMethods.stream().filter(mn -> mn.isDefault() || (mn.isPublic() + && !mn.isStatic() && !mn.isAbstract() && Traits.isTrait(mn.getDeclaringClass())) + ).forEach(methods::add); + // GRECLIPSE end } if (receiver.isInterface()) { methods.addAll(OBJECT_TYPE.getMethods(name)); diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 75539972a7..74d1921f32 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -4983,7 +4983,13 @@ protected List findMethodsWithGenerated(final ClassNode receiver, fi } else { // GROOVY-9890: always search for default methods List interfaceMethods = new ArrayList<>(); collectAllInterfaceMethodsByName(receiver, name, interfaceMethods); + /* GRECLIPSE edit interfaceMethods.stream().filter(MethodNode::isDefault).forEach(methods::add); + */ + interfaceMethods.stream().filter(mn -> mn.isDefault() || (mn.isPublic() + && !mn.isStatic() && !mn.isAbstract() && Traits.isTrait(mn.getDeclaringClass())) + ).forEach(methods::add); + // GRECLIPSE end } if (receiver.isInterface()) { methods.addAll(OBJECT_TYPE.getMethods(name));