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

Allow assignments from generic instance metaclasses to virtual metaclasses #11250

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Sep 26, 2021

Fixes part of #10394.

This appears to be simply oversight during the codegen phase.

Note that in the following example:

class Foo(T); end
class Bar(T) < Foo(T); end

x = Foo
x = Bar

x's type is Foo.class, which is not virtual, so the assignment will still break. Those remaining specs are marked as pending.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:generics topic:compiler:codegen labels Sep 26, 2021
end

def assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : VirtualMetaclassType, value)
def assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : MetaclassType | GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType | VirtualMetaclassType, value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify for following reviewers: The actual fix is the addition of GenericClassInstanceMetaclassType and GenericModuleInstanceMetaclassType as accepted types for value_type.
Most of the edits in this files are just refactoring and improvements to error messages.

I would have preferred two separate commits for that (maybe keep that in mind for next time 😄)

@beta-ziliani beta-ziliani added this to the 1.2.0 milestone Sep 28, 2021
@straight-shoota straight-shoota merged commit da710cf into crystal-lang:master Sep 29, 2021
@HertzDevil HertzDevil deleted the bug/generic-metaclass-assign branch September 30, 2021 02:12
straight-shoota added a commit to straight-shoota/crystal-website that referenced this pull request Oct 11, 2022
The original example as used in the PR
crystal-lang/crystal#11250 but it was stated
that this does not work yet with that change.
straight-shoota added a commit to straight-shoota/crystal-website that referenced this pull request Oct 11, 2022
The original example as used in the PR
crystal-lang/crystal#11250 but it was stated
that this does not work yet with that change.
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:codegen topic:compiler:generics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants