Open sandstrom opened 2 years ago
Hey @sandstrom, this is an interesting one! Let's rename the methods to instance_for
, which is more in-line with the conventions used in the library. Since we're renaming, it doesn't make sense to include Singleton
anymore, since we'd have to mark the original instance
method as private and I'm not sure if Sorbet would take kindly to that (in any case, it's weird). AFAIK the Singleton
module only does a couple of other nice things like mark new
as private. It shouldn't be difficult to replicate the behavior.
@camertron Sounds like a good plan!
Yeah, you're right, doesn't do that much.
Would this be a breaking change, or is it only an internal refactoring?
I've tried out running sorbet on our code base.
I've run into the following problem stemming from Twitter CLDR.
Same error for
TwitterCldr::Segmentation::StateMachine.instance
,TwitterCldr::Segmentation::Suppressions.instance
,TwitterCldr::Shared::DayPeriods.instance
andTwitterCldr::Timezones::Timezone.instance
. This search will also bring up the relevant files: https://github.com/twitter/twitter-cldr-rb/search?q=instance+singletonI guess one solution could be to rename the instance method, so it doesn't collide with
instance
method defined viaSingleton
module:Another solution would be to not use the
Singleton
module, but that's likely more work.If you'd accept a PR I can try to make a change where
instance
is renamed tolocale_instance
(or maybecached_instance
).