Protect against misbehaved `inherited` hooks that don't call `super`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by locating the implementation of the abstract! behavior and its self.inherited hook. Reproduce the Base and Impl example from the issue, then investigate how the hook can be protected when user-defined inherited methods omit super. Add the requested regression test and verify that the concrete subclass can be instantiated.
Written by the indexing model from the issue text.
Description
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 https://github.com/Shopify/type_toolkit/pull/3#discussion_r3826337769
- Dominant language
- Ruby
- Stars
- 3
- Forks
- 5
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 8
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/type_toolkit
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Shopify/type_toolkit#4 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Shopify/type_toolkit#20 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Shopify/type_toolkit#14 ·
-
good first issue
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Shopify/type_toolkit#11 · 3 comments ·
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
Shopify/type_toolkit#10 ·
All issues in Shopify/type_toolkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TheOdinProject/curriculum#31417 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
glossarist/glossarist-ruby#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·