src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java
Print this page
@@ -25,10 +25,11 @@
package jdk.nashorn.internal.runtime.arrays;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptRuntime;
/**
@@ -94,16 +95,22 @@
/**
* Apply action main loop.
* @return result of apply
*/
public final T apply() {
- if (!(callbackfn instanceof ScriptFunction)) {
+ final boolean strict;
+ if (callbackfn instanceof ScriptFunction) {
+ strict = ((ScriptFunction)callbackfn).isStrict();
+ } else if (callbackfn instanceof ScriptObjectMirror &&
+ ((ScriptObjectMirror)callbackfn).isFunction()) {
+ strict = ((ScriptObjectMirror)callbackfn).isStrictFunction();
+ } else {
throw typeError("not.a.function", ScriptRuntime.safeToString(callbackfn));
}
- final ScriptFunction func = ((ScriptFunction)callbackfn);
+
// for non-strict callback, need to translate undefined thisArg to be global object
- thisArg = (thisArg == ScriptRuntime.UNDEFINED && !func.isStrict()) ? Context.getGlobal() : thisArg;
+ thisArg = (thisArg == ScriptRuntime.UNDEFINED && !strict)? Context.getGlobal() : thisArg;
applyLoopBegin(iter);
final boolean reverse = iter.isReverse();
while (iter.hasNext()) {