@@ -502,10 +502,7 @@ defmodule Module.Types.Expr do
502502
503503 # var
504504 def of_expr ( var , expected , expr , stack , context ) when is_var ( var ) do
505- case stack do
506- % { refine_vars: false } -> { Of . var ( var , context ) , context }
507- % { } -> Of . refine_body_var ( var , expected , expr , stack , context )
508- end
505+ Of . refine_body_var ( var , expected , expr , stack , context )
509506 end
510507
511508 ## Tuples
@@ -691,14 +688,14 @@ defmodule Module.Types.Expr do
691688 apply_one ( mod , fun , args , expected , expr , stack , context )
692689 end
693690
694- defp apply_many ( mods , fun , args , expected , { remote , meta , args } , stack , context ) do
695- { returns , context } =
696- Enum . map_reduce ( mods , context , fn mod , context ->
697- expr = { remote , [ type_check: { :invoked_as , mod , fun , length ( args ) } ] ++ meta , args }
698- apply_one ( mod , fun , args , expected , expr , % { stack | refine_vars: false } , context )
699- end )
691+ defp apply_many ( mods , fun , args , expected , call , stack , context ) do
692+ { remote , meta , _ } = call
700693
701- { Enum . reduce ( returns , & union / 2 ) , context }
694+ Of . with_conditional_vars ( mods , none ( ) , call , stack , context , fn mod , acc , context ->
695+ expr = { remote , [ type_check: { :invoked_as , mod , fun , length ( args ) } ] ++ meta , args }
696+ { type , context } = apply_one ( mod , fun , args , expected , expr , stack , context )
697+ { union ( acc , type ) , context }
698+ end )
702699 end
703700
704701 defp reduce_non_empty ( [ last ] , acc , fun ) ,
0 commit comments