[removed] class.lua dependency on table.overlay - fixed #1

This commit is contained in:
Max Cahill 2020-03-24 14:57:42 +11:00
parent 3674846f11
commit 74a04423bb

View File

@ -19,8 +19,12 @@ local function class(inherits)
--performing a super construction if necessary and assigning the right metatable --performing a super construction if necessary and assigning the right metatable
function c:init(t, ...) function c:init(t, ...)
if inherits then if inherits then
--super ctor, then overlay args table --construct superclass instance, then overlay args table
t = table.overlay(inherits:new(...), t) local ct = inherits:new(...)
for k,v in pairs(t) do
ct[k] = v
end
t = ct
end end
--upgrade to this class and return --upgrade to this class and return
return setmetatable(t, self.__mt) return setmetatable(t, self.__mt)