Skip to content

Commit

Permalink
Partial revert "Compiler: refactor and slightly optimize merging two …
Browse files Browse the repository at this point in the history
…types (#12436)" (#12709)

This reverts part of commit bfc33db

The reverted part is 8d19346 (Generalize the case of a non-union type merged with a union type) from #12436
  • Loading branch information
caspiano authored and beta-ziliani committed Nov 3, 2022
1 parent d76cdee commit 1e6e235
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit 1e6e235

Please sign in to comment.