diff --git a/lua/pl/types.lua b/lua/pl/types.lua index 35b0ccb5..37c54817 100644 --- a/lua/pl/types.lua +++ b/lua/pl/types.lua @@ -11,7 +11,14 @@ local types = {} --- is the object either a function or a callable object?. -- @param obj Object to check. function types.is_callable (obj) - return type(obj) == 'function' or getmetatable(obj) and getmetatable(obj).__call and true + if type(obj) == 'function' then + return true + end + local mt = getmetatable(obj) + if not mt then + return false + end + return type(rawget(mt, "__call")) == "function" end --- is the object of the specified type?.