diff --git a/src/methods/is.js b/src/methods/is.js index 256733934..e34d781a3 100644 --- a/src/methods/is.js +++ b/src/methods/is.js @@ -108,6 +108,16 @@ export function IsCallable(realm: Realm, _func: Value): boolean { if (HasCompatibleType(func, FunctionValue)) return true; if (func.isSimpleObject()) return false; + if (func instanceof AbstractObjectValue && !func.values.isTop()) { + let result; + for (let element of func.values.getElements()) { + let isCallable = IsCallable(realm, element); + if (result === undefined) result = isCallable; + else if (result !== isCallable) func.throwIfNotConcreteObject(); + } + if (result !== undefined) return result; + } + // 2. If argument has a [[Call]] internal method, return true. func = func.throwIfNotConcreteObject(); if (func.$Call) return true; diff --git a/test/serializer/abstract/UseAbstractObjectValueTemplateInIsCall.js b/test/serializer/abstract/UseAbstractObjectValueTemplateInIsCall.js new file mode 100644 index 000000000..bf443b577 --- /dev/null +++ b/test/serializer/abstract/UseAbstractObjectValueTemplateInIsCall.js @@ -0,0 +1,6 @@ +let obj = global.__abstract ? __abstract({}, "obj") : {}; +let func = global.__abstract ? __abstract(function() {}, "func") : function() {}; +global.result = typeof obj + "/" + typeof func; +global.inspect = function() { + return global.result; +};