Relying on this inherited method means we only restore .new when user-defined self.inherited hooks call super. If an abstract class defines an inherited hook without super, concrete subclasses keep the abstract .new and can't be instantiated:
class Base
abstract!
def self.inherited(_subclass)
# no super
end
abstract def call; end
end
class Impl < Base
def call; end
end
Impl.new # raises CannotInstantiateAbstractClassError
I wonder if we should install this as a prepended singleton hook, or otherwise wrap/chain the existing hook, and add a regression test so subclass instantiation doesn't depend on user hooks calling super.
Originally posted by @Morriar in #3 (comment)
Relying on this
inheritedmethod means we only restore.newwhen user-definedself.inheritedhooks callsuper. If an abstract class defines an inherited hook withoutsuper, concrete subclasses keep the abstract.newand can't be instantiated:I wonder if we should install this as a prepended singleton hook, or otherwise wrap/chain the existing hook, and add a regression test so subclass instantiation doesn't depend on user hooks calling
super.Originally posted by @Morriar in #3 (comment)