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

Compiler: fix is_a? for virtual metaclass types #11121

Merged
merged 2 commits into from
Aug 27, 2021

Conversation

asterite
Copy link
Member

Fixes #11120

There are comments around further improvements to the type system, but they can be done later and independent of this PR (it's a really small change here.)

@@ -82,7 +82,16 @@ module Crystal
return nil if type1.instance_type.module?

restricted = common_descendent(type1.instance_type, type2.instance_type.base_type)
restricted ? type1 : nil
restricted.try(&.virtual_type.metaclass)
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed this because restricting a type against a virtual type should always give a possibly virtual type: we don't know which of the actual subtypes it will be.

@asterite asterite added this to the 1.2.0 milestone Aug 27, 2021
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic labels Aug 27, 2021
@asterite asterite merged commit f18b38b into master Aug 27, 2021
@asterite asterite deleted the bug/interesct-metaclasses branch August 27, 2021 13:31
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:semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

is_a? doesn't work well with virtual metaclass type against metaclass type
2 participants