Skip to content

Update singleton - #3152

Open
ksss wants to merge 1 commit into
ruby:masterfrom
ksss:singleton
Open

ksss wants to merge 1 commit into
ruby:masterfrom
ksss:singleton

Conversation

@ksss

@ksss ksss commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Update the singleton module's type definitions to reflect actual usage.

In the current definitions, even the #instance method in standard use cases with include Singleton does not work correctly.

This is a breaking change for calls to Singleton.instance, but this method does not exist in the first place and type checks should not pass for it.

To provide correct type definitions, extend Singleton::SingletonClassMethods is required alongside include Singleton in each case, which is also the correct behavior.

assert_send_type '() -> SingletonSingletonTest::TestClass',
TestClass, :instance
end

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will fail, but making it pass requires breaking changes to the test harness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant