diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSFunctor.java b/teavm-jso/src/main/java/org/teavm/jso/JSFunctor.java index 8cd7c904c..4ac09aa88 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSFunctor.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSFunctor.java @@ -15,10 +15,7 @@ */ package org.teavm.jso; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * @@ -26,5 +23,6 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) +@Inherited public @interface JSFunctor { } diff --git a/teavm-jso/src/main/java/org/teavm/jso/plugin/JSBodyGenerator.java b/teavm-jso/src/main/java/org/teavm/jso/plugin/JSBodyGenerator.java index d7abe2da4..0e496c4e7 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/plugin/JSBodyGenerator.java +++ b/teavm-jso/src/main/java/org/teavm/jso/plugin/JSBodyGenerator.java @@ -36,16 +36,15 @@ public class JSBodyGenerator implements Generator { List paramNames = annot.getValue("params").getList(); int bodyParamCount = isStatic ? method.parameterCount() : method.parameterCount() - 1; - int offset = isStatic ? 1 : 0; writer.append("if (!").appendMethodBody(methodRef).append(".$native)").ws().append('{').indent().newLine(); writer.appendMethodBody(methodRef).append(".$native").ws().append('=').ws().append("function("); - int count = method.parameterCount() + (isStatic ? 0 : 1); + int count = method.parameterCount(); for (int i = 0; i < count; ++i) { if (i > 0) { writer.append(',').ws(); } - writer.append('_').append(context.getParameterName(i + offset)); + writer.append('_').append(context.getParameterName(i + 1)); } writer.append(')').ws().append('{').softNewLine().indent(); @@ -68,7 +67,7 @@ public class JSBodyGenerator implements Generator { if (i > 0) { writer.append(',').ws(); } - writer.append('_').append(context.getParameterName(i + offset)); + writer.append('_').append(context.getParameterName(i + 1)); } writer.append(");").softNewLine(); writer.outdent().append("};").softNewLine(); @@ -81,7 +80,7 @@ public class JSBodyGenerator implements Generator { if (i > 0) { writer.append(',').ws(); } - writer.append(context.getParameterName(i + offset)); + writer.append(context.getParameterName(i + 1)); } writer.append(");").softNewLine(); }