Skip to content

Commit 7ce9a4d

Browse files
committed
fix logic mistake
1 parent 4faf185 commit 7ce9a4d

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/main/java/soot/LambdaMetaFactory.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -773,28 +773,31 @@ private void invokeImplMethod(
773773
JimpleBody jb, PatchingChain<Unit> us, LocalGenerator lc, List<Local> args) {
774774
Value value = _invokeImplMethod(jb, us, lc, args);
775775

776-
if (soot.VoidType.v().equals(implMethod.getMethodRef().getReturnType())) {
776+
if (soot.VoidType.v().equals(implMethodType.getReturnType())) {
777777
// dispatch method is void
778778
if (value instanceof InvokeExpr) {
779779
us.add(Jimple.v().newInvokeStmt(value));
780780
}
781781

782+
us.add(Jimple.v().newReturnVoidStmt());
783+
784+
} else {
785+
782786
// Handle special case of a constructor method-ref. The dispatch method is void <init>(),
783787
// but the created object should still be returned.
784788
// See (src/systemTest/targets/soot/lambdaMetaFactory/Issue1367.java)
785-
if (!soot.VoidType.v().equals(implMethodType.getReturnType())) {
789+
if (soot.VoidType.v().equals(implMethod.getMethodRef().getReturnType())) {
786790
us.add(Jimple.v().newReturnStmt(value));
787791
} else {
788-
us.add(Jimple.v().newReturnVoidStmt());
789-
}
790-
} else {
791-
// neither is void, must pass through return value
792-
Local ret = lc.generateLocal(value.getType());
793-
us.add(Jimple.v().newAssignStmt(ret, value));
794792

795-
// adapt return value
796-
Local retAdapted = adapt(ret, implMethodType.getReturnType(), jb, us, lc);
797-
us.add(Jimple.v().newReturnStmt(retAdapted));
793+
// neither is void, must pass through return value
794+
Local ret = lc.generateLocal(value.getType());
795+
us.add(Jimple.v().newAssignStmt(ret, value));
796+
797+
// adapt return value
798+
Local retAdapted = adapt(ret, implMethodType.getReturnType(), jb, us, lc);
799+
us.add(Jimple.v().newReturnStmt(retAdapted));
800+
}
798801
}
799802
}
800803

0 commit comments

Comments
 (0)