Ensure making a class abstract doesn't change the visibility of its `.new`

Open
#8 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
tooling

Research direction

Start by reading the abstract-class implementation introduced in issue #3 and trace how abstract! changes the class's singleton methods. Reproduce the visibility checks with PrivateNew, MyAbstractClass, and MySubclass from this issue; done means both checks remain false when inherited .new was private.

Written by the indexing model from the issue text.

Description

good first issue

The implementation in #3 will always make new public, regardless of the visibility it had previously.

Desired behaviour:

class PrivateNew
  private_class_method :new
end

class MyAbstractClass < PrivateNew
  abstract!
end

p MyAbstractClass.singleton_class.public_method_defined?(:new)
# is true, should be false

class MySubclass < MyAbstractClass; end

p MySubclass.singleton_class.public_method_defined?(:new)
# is true, should be false
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/type_toolkit

All issues in Shopify/type_toolkit

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.