Remove symbol overloads of Colorize
color methods for symbol auto-casting
#11775
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Colorize
methods receiving a color (#fore
and#back
) have overloads receiving aSymbol
parameter which is manually mapped to values ofColorANSI
. This implementation predates the symbol auto-casting of enum values.This patch removes the overloads with
Symbol
typed parameters which leaves the overloads receiving aColor
parameter. This type is a union including the enumColorANSI
which enables symbol auto-casting for color values.The problem is: it's a breaking change. If the API is used with symbols that are not directly created from literals, there will be a compile time error. This is good and intended because it adds type safety (you can know at compile time whether a value is valid). But it's still a breaking change that destroys valid use cases which would require changes to user code (as demonstrated by the changes in
samples/2048.cr
andsrc/spec/dsl.cr
for example). So I believe we can't merge it just like that.The only option is to leave the removed overloads in with a deprecation notice. That's not ideal though because the deprecation warning even triggers for usages that are compatible with the auto-casting method. But the symbol overload takes precedence over auto-casting. The only way to deactivate deprecation warnings is using a named argument:
fore(fore: :green)
.Are there any other ideas? We could use a feature flag but I think would be silly for such a minor thing.
This patch has been extracted from #7690.