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

Refactor some type restrictions in the compiler #11531

Conversation

straight-shoota
Copy link
Member

This patch applies a couple small refactorings that remove unintended type unions. In the case of Annotatable it restricts the interface to allow only meaningful types.

if type.is_a?(GenericInstanceType)
type.generic_type
type.generic_type.as(Type)
Copy link
Member Author

Choose a reason for hiding this comment

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

GenericInstanceType#generic_type returns GenericType hence the resulting type would be a union GenericType | Type. All including types of GenericType inherit from Type but the compiler doesn't merge this union.

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

👍

@beta-ziliani beta-ziliani added this to the 1.3.0 milestone Dec 9, 2021
@straight-shoota straight-shoota merged commit a9ee750 into crystal-lang:master Dec 10, 2021
@straight-shoota straight-shoota deleted the refactor/compiler-type-restrictions branch December 10, 2021 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants