@@ -719,62 +719,24 @@ defmodule Module.Types.Expr do
719719 defp dynamic_unless_static ( { _ , _ } = output , % { mode: :static } ) , do: output
720720 defp dynamic_unless_static ( { type , context } , % { mode: _ } ) , do: { dynamic ( type ) , context }
721721
722- defp of_clauses ( clauses , domain , expected , clause_info , stack , context , acc ) do
722+ defp of_clauses ( clauses , domain , expected , base_info , stack , context , acc ) do
723723 fun = fn _args_types , result , _context , acc -> union ( result , acc ) end
724- of_clauses_fun ( clauses , domain , expected , clause_info , stack , context , acc , fun )
724+ of_clauses_fun ( clauses , domain , expected , base_info , stack , context , acc , fun )
725725 end
726726
727- defp of_clauses_fun ( clauses , domain , expected , clause_info , stack , original , acc , fun ) do
727+ defp of_clauses_fun ( clauses , domain , expected , base_info , stack , original , acc , fun ) do
728728 % { failed: failed? } = original
729729
730730 { result , _previous , context } =
731731 Enum . reduce ( clauses , { acc , [ ] , original } , fn
732- { :-> , meta , [ head , body ] } = clause , { acc , previous , context } ->
732+ { :-> , meta , [ head , body ] } , { acc , previous , context } ->
733733 { failed? , context } = reset_failed ( context , failed? )
734734 { patterns , guards } = extract_head ( head )
735- info = { clause_info , head , previous }
735+ info = { base_info , head }
736736
737- { trees , precise? , context } =
737+ { trees , previous , context } =
738738 Pattern . of_head ( patterns , guards , domain , previous , info , meta , stack , context )
739739
740- # It failed, let's try to detect if it was due a previous or current clause.
741- # The current clause will be easier to understand, so we prefer that
742- { trees , precise? , context } =
743- if context . failed and previous != [ ] do
744- info = { clause_info , head , [ ] }
745-
746- case Pattern . of_head ( patterns , guards , domain , info , meta , stack , context ) do
747- { _ , _ , % { failed: true } } = result -> result
748- _ -> { trees , precise? , context }
749- end
750- else
751- { trees , precise? , context }
752- end
753-
754- { previous , context } =
755- if context . failed do
756- { previous , context }
757- else
758- args_types =
759- Enum . map ( trees , fn { tree , _ , _ } ->
760- tree
761- |> Pattern . of_pattern_tree ( stack , context )
762- |> upper_bound ( )
763- end )
764-
765- cond do
766- stack . mode != :infer and previous != [ ] and
767- Pattern . args_subtype? ( args_types , previous ) ->
768- { previous , Pattern . redundant_warn ( clause , previous , stack , context ) }
769-
770- precise? ->
771- { [ args_types | previous ] , context }
772-
773- true ->
774- { previous , context }
775- end
776- end
777-
778740 { result , context } = of_expr ( body , expected , body , stack , context )
779741
780742 { fun . ( trees , result , context , acc ) , previous ,
0 commit comments