Skip to content

Commit 8f647cc

Browse files
committed
spec for testing super scope when inside table/function
1 parent 4b26091 commit 8f647cc

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

spec/inputs/class.moon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,14 @@ class Something
176176
class X
177177
new: hi
178178

179+
180+
--
181+
182+
class Cool extends Thing
183+
dang: =>
184+
{
185+
hello: -> super!
186+
world: -> super.one
187+
}
188+
179189
nil

spec/outputs/class.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,4 +761,52 @@ do
761761
_base_0.__class = _class_0
762762
X = _class_0
763763
end
764+
do
765+
local _class_0
766+
local _parent_0 = Thing
767+
local _base_0 = {
768+
dang = function(self)
769+
return {
770+
hello = function()
771+
return _class_0.__parent.dang(self)
772+
end,
773+
world = function()
774+
return _class_0.__parent.one
775+
end
776+
}
777+
end
778+
}
779+
_base_0.__index = _base_0
780+
setmetatable(_base_0, _parent_0.__base)
781+
_class_0 = setmetatable({
782+
__init = function(self, ...)
783+
return _class_0.__parent.__init(self, ...)
784+
end,
785+
__base = _base_0,
786+
__name = "Cool",
787+
__parent = _parent_0
788+
}, {
789+
__index = function(cls, name)
790+
local val = rawget(_base_0, name)
791+
if val == nil then
792+
local parent = rawget(cls, "__parent")
793+
if parent then
794+
return parent[name]
795+
end
796+
else
797+
return val
798+
end
799+
end,
800+
__call = function(cls, ...)
801+
local _self_0 = setmetatable({}, _base_0)
802+
cls.__init(_self_0, ...)
803+
return _self_0
804+
end
805+
})
806+
_base_0.__class = _class_0
807+
if _parent_0.__inherited then
808+
_parent_0.__inherited(_parent_0, _class_0)
809+
end
810+
Cool = _class_0
811+
end
764812
return nil

0 commit comments

Comments
 (0)