I don’t think this test should be done. t should have a field called super, and if it doesn’t, you should get an error. Right now, it would just do nothing.
And isn’t it a bit overly verbose? I think this should work as well:
function Base.getproperty(o::Object, s::Symbol)
if hasfield(typeof(o), s)
return getfield(o, s)
end
return o.super.s
end
function Base.setproperty!(o::Object, s::Symbol, x)
if hasfield(typeof(o), s)
setfield!(o, s, x)
else
o.super.s = x
end
end