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

Partial revert "Compiler: refactor and slightly optimize merging two types (#12436)" #12709

Merged
merged 3 commits into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/compiler/crystal/semantic/type_merge.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ module Crystal
return second if first.no_return?
return first if second.no_return?

# Check if a non-union type is part of a union type
if !first.is_a?(UnionType) && second.is_a?(UnionType) && second.union_types.includes?(first)
if first.nil_type? && second.is_a?(UnionType) && second.union_types.includes?(first)
return second
end

if !second.is_a?(UnionType) && first.is_a?(UnionType) && first.union_types.includes?(second)
if second.nil_type? && first.is_a?(UnionType) && first.union_types.includes?(second)
return first
end

Expand Down