Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix union logic between metaclasses of uninstantiated generic classes in same hierarchy #10832

Merged

Conversation

HertzDevil
Copy link
Contributor

#10527 introduced a reducible union that didn't previously exist:

class Foo(T)
end

class Bar(T) < Foo(T)
end

typeof(Foo || Bar) # => (Bar(T).class | Foo(T).class)
# before:          # => Foo(T).class

It happened because Foo and Bar were handled like normal classes instead of metaclasses (every Crystal::MetaclassType is a ClassType), and because Type#depth isn't really used for metaclasses yet; changing the overload order of the least common ancestor method fixes this.

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:semantic labels Jun 18, 2021
@asterite
Copy link
Member

Can we move the Type vs Type overload to the bottom? It feels weird to me that it's the first overload, I always put the least general one at the bottom, just in case.

@asterite asterite added this to the 1.1.0 milestone Jun 18, 2021
@asterite asterite merged commit b41976e into crystal-lang:master Jun 18, 2021
@HertzDevil HertzDevil deleted the bug/generic-metaclass-union branch June 18, 2021 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants