Correctly enforcing abstract!
#3388
Labels
enhancement
New feature or surprising current feature
good first issue
Good for newcomers
runtime
Related to the sorbet-runtime gem
It seems that
sorbet
enforces abstract classes not being instantiated by defining aninitialize
that raises an errorThis
initialize
apparently does not check what is the class being instantiated, is there a good reason for this?Moreover, why not define a class method
new
that raises instead (only if the receiver is the current abstract class)?The reasons to go this way are:
There are valid reasons to have an abstract class that need initialization and/or initial parameters.
sorbet
shouldn't mess withinitialize
There are valid cases of an abstract class that does not require special initialization and/or additional parameters.
sorbet
shouldn't force having a trivialinitialize
methodCalling
super
frominitialize
is considered by many a good practice.sorbet
should not break this.Example:
The text was updated successfully, but these errors were encountered: