@@ -1651,7 +1651,7 @@ private static Class toInvokerParamType(Class c) {
1651
1651
* If targetClass is FI and has an adaptable functional method
1652
1652
* Find fn invoker method matching adaptable method of FI
1653
1653
* Emit bytecode for (expr is emitted):
1654
- * if(expr instanceof IFn)
1654
+ * if(expr instanceof IFn && !(expr instanceof FI) )
1655
1655
* invokeDynamic(targetMethod, fnInvokerImplMethod)
1656
1656
* Else emit nothing
1657
1657
*/
@@ -1686,15 +1686,18 @@ static boolean maybeEmitFIAdapter(ObjExpr objx, GeneratorAdapter gen, Expr expr,
1686
1686
try {
1687
1687
java .lang .reflect .Method fnInvokerMethod = FnInvokers .class .getMethod (invokerMethodName , invokerParams );
1688
1688
1689
- // if(exp instanceof IFn) { emitInvokeDynamic(targetMethod, fnInvokerMethod) }
1689
+ // if not (expr instanceof IFn), go to end label
1690
1690
expr .emit (C .EXPRESSION , objx , gen );
1691
1691
gen .dup ();
1692
1692
gen .instanceOf (ifnType );
1693
-
1694
- // if not instanceof IFn, go to end
1695
1693
Label endLabel = gen .newLabel ();
1696
1694
gen .ifZCmp (Opcodes .IFEQ , endLabel );
1697
1695
1696
+ // if (expr instanceof FI), go to end label
1697
+ gen .dup ();
1698
+ gen .instanceOf (samType );
1699
+ gen .ifZCmp (Opcodes .IFNE , endLabel );
1700
+
1698
1701
// else adapt fn invoker method as impl for target method
1699
1702
emitInvokeDynamicAdapter (gen , targetClass , targetMethod , FnInvokers .class , fnInvokerMethod );
1700
1703
0 commit comments