jsweet
jsweet copied to clipboard
Zero and single argument FunctionalInterfaces are uncallable
public class ThingA {
static void m(Step step) {
step.apply();
}
@FunctionalInterface
public interface Step {
void apply();
}
}
produces the error expected 1-2 arguments, but got 0
with:
/* Generated from Java with JSweet 2.4.0-SNAPSHOT - http://www.jsweet.org */
namespace jsweettest.moda {
export class ThingA {
static m(step : ThingA.Step) {
((target => (target['apply'] === undefined)?target:target['apply'])(step))();
}
}
ThingA["__class"] = "jsweettest.moda.ThingA";
export namespace ThingA {
export interface Step {
();
}
}
}
public class ThingA {
static void m(Step step) {
step.apply(4);
}
@FunctionalInterface
public interface Step {
void apply(int o1);
}
}
produces error the 'this' context of type 'void' is not assignable to method's 'this' of type 'Function'
with output:
/* Generated from Java with JSweet 2.4.0-SNAPSHOT - http://www.jsweet.org */
namespace jsweettest.moda {
export class ThingA {
static m(step : ThingA.Step) {
((target => (target['apply'] === undefined)?target:target['apply'])(step))(4);
}
}
ThingA["__class"] = "jsweettest.moda.ThingA";
export namespace ThingA {
export interface Step {
(o1 : number);
}
}
}
I should clarify, this also happens with 2 arguments, and where the argument types are from generic arguments. I haven't tested further.
The workaround seems to be to use Runnable/Consumer/Supplier/Function/BiConsumer/BiFunction/etc whenever possible.
This one seems blocking to me. It should definitively work.
Thanks for reporting.
Oh, I notice you are using J4TS. Do you reproduce without J4TS please?