fix(class): use rawset during instantiation

If classes use a __newindex method it may lead to unexpected behaviour.
This commit is contained in:
Linden
2024-04-13 11:10:44 +10:00
parent 9d08560e91
commit 774da8f755

View File

@@ -63,17 +63,17 @@ function mixins.new(class, ...)
if constructor then if constructor then
local parent = class local parent = class
function obj:super(...) rawset(obj, 'super', function(self, ...)
parent = getmetatable(parent) parent = getmetatable(parent)
constructor = getConstructor(parent) constructor = getConstructor(parent)
if constructor then return constructor(self, ...) end if constructor then return constructor(self, ...) end
end end)
constructor(obj, ...) constructor(obj, ...)
end end
obj.super = nil rawset(obj, 'super', nil)
if next(obj.private) then if next(obj.private) then
local private = table.clone(obj.private) local private = table.clone(obj.private)