Skip to content

Commit b1c815c

Browse files
author
anquetil
committed
fix issue #156 + added a test for it
1 parent d3cd524 commit b1c815c

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

app/src/main/java/fr/inria/verveine/extractor/java/visitors/refvisitors/VisitorInvocRef.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ public boolean visit(MethodInvocation node) {
272272
@SuppressWarnings("unchecked")
273273
public boolean visit(SuperMethodInvocation node) {
274274
//System.err.println("visit(SuperMethodInvocation) ");
275-
// ConstructorInvocation (i.e. 'this(...)' ) happen in constructor, so the name
276-
// is the same
277275
TNamedEntity receiver = this.dico.ensureFamixImplicitVariable(
278276
EntityDictionary.SUPER_NAME,
279277
this.context.topType(),
@@ -282,8 +280,7 @@ public boolean visit(SuperMethodInvocation node) {
282280
String calledName = node.getName().getFullyQualifiedName();
283281

284282
if (bnd == null) {
285-
TType superClass = (TType) ((TWithInheritances) this.context.topType()).getSuperInheritances().iterator()
286-
.next();
283+
TType superClass = (TType) ((TWithInheritances) this.context.topType()).getSuperInheritances().iterator().next().getSuperclass();
287284
methodInvocation(bnd, calledName, receiver, superClass, node.arguments());
288285
} else {
289286
methodInvocation(bnd, calledName, receiver, /* owner */null, node.arguments());

app/src/test/java/fr/inria/verveine/extractor/java/VerveineJTest_AdHoc.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public void testPublicStaticInnerClass() {
782782
@Test
783783
public void testSuperConstructorInvocation() {
784784
parse(new String[] {"src/test/resources/ad_hoc/StubSuperConstructor.java"});
785-
785+
786786
Collection<Method> meths = entitiesNamed( Method.class, "StubSuperConstructor");
787787

788788
assertEquals(2, meths.size());
@@ -802,6 +802,15 @@ public void testSuperConstructorInvocation() {
802802
}
803803
}
804804

805+
@Test
806+
public void testSuperConstructorInvocationOfStub() {
807+
parse(new String[] {"src/test/resources/ad_hoc/StubSuperConstructor.java"});
808+
809+
Collection<Method> meths = entitiesNamed( Method.class, "callingSuper");
810+
811+
assertEquals(2, meths.size());
812+
}
813+
805814
@Test
806815
public void testMethodModifiers(){
807816
parse(new String[] {"src/test/resources/ad_hoc/Modifiers.java"});

app/src/test/resources/ad_hoc/StubSuperConstructor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ public StubSuperConstructor(int sz) {
1212
super(sz);
1313
}
1414

15+
void callingSuper() {
16+
super.callingSuper();
17+
}
1518
}

0 commit comments

Comments
 (0)