diff --git a/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java b/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java index 68438c4236f..bad72384e00 100644 --- a/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java +++ b/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java @@ -236,11 +236,7 @@ public boolean isOverriding(CtExecutableReference executable) { if (!isSame) { return false; } - if (getDeclaringType().isAnonymous()) { - if (!getDeclaringType().getDeclaringType().isSubtypeOf(executable.getDeclaringType())) { - return false; - } - } else if (!getDeclaringType().isSubtypeOf(executable.getDeclaringType())) { + if (!getDeclaringType().isSubtypeOf(executable.getDeclaringType())) { return false; } return true; diff --git a/src/test/java/spoon/test/filters/FilterTest.java b/src/test/java/spoon/test/filters/FilterTest.java index b313f82265e..28c9f90b9fe 100644 --- a/src/test/java/spoon/test/filters/FilterTest.java +++ b/src/test/java/spoon/test/filters/FilterTest.java @@ -287,7 +287,8 @@ public void testOverridingMethodFromSubClassOfAbstractClass() throws Exception { final List> overridingMethods = Arrays.asList(ts.toArray(new CtMethod[0])); - assertEquals(2, overridingMethods.size()); + assertEquals(3, overridingMethods.size()); + assertEquals("spoon.test.filters.testclasses.AbstractTostada$1", overridingMethods.get(2).getParent(CtClass.class).getQualifiedName()); assertEquals(SubTostada.class, overridingMethods.get(1).getParent(CtClass.class).getActualClass()); assertEquals("spoon.test.filters.testclasses.Tostada$1", overridingMethods.get(0).getParent(CtClass.class).getQualifiedName()); @@ -328,13 +329,15 @@ public void testOverridingMethodFromSubClassOfInterface() throws Exception { final CtClass anAbstractTostada = launcher.getFactory().Class().get(AbstractTostada.class); - final List> overridingMethods = Query.getElements(launcher.getFactory(), new OverridingMethodFilter(anAbstractTostada.getMethodsByName("make").get(0))); + List> overridingMethods = Query.getElements(launcher.getFactory(), new OverridingMethodFilter(anAbstractTostada.getMethodsByName("make").get(0))); assertEquals(2, overridingMethods.size()); assertEquals("spoon.test.filters.testclasses.AbstractTostada$1", overridingMethods.get(0).getParent(CtClass.class).getQualifiedName()); assertEquals(Tostada.class, overridingMethods.get(1).getParent(CtClass.class).getActualClass()); final CtClass aTostada = launcher.getFactory().Class().get(Tostada.class); - assertEquals(0, Query.getElements(launcher.getFactory(), new OverridingMethodFilter(aTostada.getMethodsByName("make").get(0))).size()); + overridingMethods = Query.getElements(launcher.getFactory(), new OverridingMethodFilter(aTostada.getMethodsByName("make").get(0))); + assertEquals(1, overridingMethods.size()); + assertEquals("spoon.test.filters.testclasses.AbstractTostada$1", overridingMethods.get(0).getParent(CtClass.class).getQualifiedName()); } @Test