File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 272272-- @param object element to inspect on being callable or not
273273-- @return boolean, true if the object is callable
274274function util .callable (object )
275- return type (object ) == " function" or type ((debug.getmetatable (object ) or {}).__call ) == " function"
275+ if type (object ) == ' function' then
276+ return true
277+ end
278+ local mt = debug.getmetatable (object )
279+ if not mt then
280+ return false
281+ end
282+ return type (rawget (mt , " __call" )) == " function"
276283end
277284
278285---- -------------------------------------------
282289-- @param object element to inspect on having tostring or not
283290-- @return boolean, true if the object has tostring
284291function util .hastostring (object )
285- return type (object ) == " string" or type ((debug.getmetatable (object ) or {}). __tostring ) == " function"
292+ return type (object ) == " string" or type (rawget (debug.getmetatable (object ) or {}, " __tostring" ) ) == " function"
286293end
287294
288295---- -------------------------------------------
You can’t perform that action at this time.
0 commit comments