Skip to content

Commit

Permalink
Fix for #1267: find trait methods during reconcile type-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jun 15, 2021
1 parent 36cbc7a commit b400f3d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5371,7 +5371,9 @@ protected List<MethodNode> findMethodsWithGenerated(ClassNode receiver, String n
} else {
List<MethodNode> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5143,7 +5143,13 @@ protected List<MethodNode> findMethodsWithGenerated(final ClassNode receiver, fi
} else { // GROOVY-9890: always search for default methods
List<MethodNode> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4983,7 +4983,13 @@ protected List<MethodNode> findMethodsWithGenerated(final ClassNode receiver, fi
} else { // GROOVY-9890: always search for default methods
List<MethodNode> 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));
Expand Down

0 comments on commit b400f3d

Please sign in to comment.