diff --git a/src/main/java/spoon/support/reflect/declaration/CtMethodImpl.java b/src/main/java/spoon/support/reflect/declaration/CtMethodImpl.java index 4fccb2f7cc5..f67a5a48488 100644 --- a/src/main/java/spoon/support/reflect/declaration/CtMethodImpl.java +++ b/src/main/java/spoon/support/reflect/declaration/CtMethodImpl.java @@ -225,11 +225,11 @@ public Collection> getTopDefinitions() { // first collect potential declarations of this method in the type hierarchy ClassTypingContext context = new ClassTypingContext(this.getDeclaringType()); - for (Object m : getDeclaringType().map(new AllTypeMembersFunction(CtMethod.class)).list()) { - if (m != this && context.isOverriding(this, (CtMethod) m)) { - s.add((CtMethod) m); + getDeclaringType().map(new AllTypeMembersFunction(CtMethod.class)).forEach((CtMethod m) -> { + if (m != this && context.isOverriding(this, m)) { + s.add(m); } - } + }); // now removing the intermediate methods for which there exists a definition upper in the hierarchy List> finalMeths = new ArrayList<>(s);