Skip to content

Commit

Permalink
Move type variable expansion before Union/Intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Sep 9, 2024
1 parent 1f6156d commit b132550
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/steep/subtyping/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ def check_type0(relation)
constraints.add(relation.sub_type.name, super_type: relation.super_type)
Success(relation)

when relation.sub_type.is_a?(AST::Types::Var)
Expand(relation) do
ub = variable_upper_bound(relation.sub_type.name) || Interface::TypeParam::IMPLICIT_UPPER_BOUND
check_type(Relation.new(sub_type: ub, super_type: relation.super_type))
end

when relation.super_type.is_a?(AST::Types::Var) || relation.sub_type.is_a?(AST::Types::Var)
Failure(relation, Result::Failure::UnknownPairError.new(relation: relation))

when relation.sub_type.is_a?(AST::Types::Union)
All(relation) do |result|
relation.sub_type.types.each do |sub_type|
Expand Down Expand Up @@ -387,15 +396,6 @@ def check_type0(relation)
end
end

when relation.sub_type.is_a?(AST::Types::Var)
Expand(relation) do
ub = variable_upper_bound(relation.sub_type.name) || Interface::TypeParam::IMPLICIT_UPPER_BOUND
check_type(Relation.new(sub_type: ub, super_type: relation.super_type))
end

when relation.super_type.is_a?(AST::Types::Var) || relation.sub_type.is_a?(AST::Types::Var)
Failure(relation, Result::Failure::UnknownPairError.new(relation: relation))

when relation.super_type.is_a?(AST::Types::Name::Interface)
Expand(relation) do
check_interface(
Expand Down

0 comments on commit b132550

Please sign in to comment.