-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 several compile-time operations on generic instance metaclasses #11101
Merged
straight-shoota
merged 7 commits into
crystal-lang:master
from
HertzDevil:bug/generic-instance-metaclass
Sep 29, 2021
Merged
Fix several compile-time operations on generic instance metaclasses #11101
straight-shoota
merged 7 commits into
crystal-lang:master
from
HertzDevil:bug/generic-instance-metaclass
Sep 29, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HertzDevil
added
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
topic:compiler:generics
labels
Aug 17, 2021
For #11110 this will fix the subtyping check, but the ancestors of generic module instance metaclasses will still include module Foo(T); end
{% Foo(Int32).class <= Object.class %} # => false
{% Foo(Int32).class.ancestors %} # => [Object.class, Class, Value, Object] |
This reverts commit 12cdcc6.
straight-shoota
approved these changes
Aug 23, 2021
asterite
approved these changes
Sep 9, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
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.
topic:compiler:generics
topic:lang:type-system
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.
An assortment of fixes that improve the correctness of generic instance metaclass types (e.g.
Array(Int32).class
,Enumerable(String).class
).T.class.class
as a distinct type whenT
is a generic instance. The same type expression will produceClass
just like other kinds of metaclasses.TypeNode#superclass
, where the same code would currently producenil
twice: (#ancestors
already worked correctly prior to this PR)Makes it so that
T.class <= U.class
if and only ifT <= U
. Previously this was not computed properly when either type is a generic instance;T.class
was regarded as a normal type inCrystal::Type#implements?
, so it completely ignored subtyping due to generics, causing the following lines to producefalse
:T.class < U.class
ifT
inherits fromU
(module inclusion does not count), or ifT
is a generic instance ofU
. Previously this was not computed properly when either type is a generic instance;T.class
was regarded as a normal type inCrystal::Type#implements?
, so it completely ignored subtyping due to generics, causing the following lines to producefalse
:Does not affect #11068. Also does not affect
Class#<=
(subtyping comparisons between runtime metaclasses).