@@ -385,7 +385,7 @@ defmodule Module.Types do
385385 _ ->
386386 inferred
387387 |> Enum . map ( fn { args , _ } -> args end )
388- |> Enum . zip_with ( fn types -> Enum . reduce ( types , & Descr . union / 2 ) end )
388+ |> Enum . zip_with ( fn types -> Enum . reduce ( types , & Descr . opt_union / 2 ) end )
389389 end
390390
391391 { { :infer , domain , Enum . reverse ( inferred ) } , mapping , restore_context ( body_context , context ) }
@@ -462,7 +462,7 @@ defmodule Module.Types do
462462 # the domain is computed by unioning their inferred types. However, their
463463 # inferred types often have the different of the previous clauses:
464464 #
465- # union (r3 ^ (c3 - c2 - c1), r2 ^ (c2 - c1), r1 ^ c1)
465+ # opt_union (r3 ^ (c3 - c2 - c1), r2 ^ (c2 - c1), r1 ^ c1)
466466 #
467467 # Where `rN` represents the refinement in every function body.
468468 #
@@ -493,9 +493,9 @@ defmodule Module.Types do
493493 # Furthermore, the signature used in type checking is not refined in any way,
494494 # so type checking is still sound.
495495 if arg == head_arg do
496- Descr . union ( Descr . upper_bound ( no_prev_arg ) , d )
496+ Descr . opt_union ( Descr . upper_bound ( no_prev_arg ) , d )
497497 else
498- Descr . union ( arg , d )
498+ Descr . opt_union ( arg , d )
499499 end
500500 | compute_domain ( args_types , head_args_types , no_prev_args_types , domain )
501501 ]
@@ -506,7 +506,7 @@ defmodule Module.Types do
506506 # We check for term equality of types as an optimization
507507 # to reduce the amount of check we do at runtime.
508508 defp add_inferred ( [ { args , existing_return } | tail ] , args , return , index , acc ) ,
509- do: { index , Enum . reverse ( acc , [ { args , Descr . union ( existing_return , return ) } | tail ] ) }
509+ do: { index , Enum . reverse ( acc , [ { args , Descr . opt_union ( existing_return , return ) } | tail ] ) }
510510
511511 defp add_inferred ( [ head | tail ] , args , return , index , acc ) ,
512512 do: add_inferred ( tail , args , return , index - 1 , [ head | acc ] )
@@ -558,7 +558,7 @@ defmodule Module.Types do
558558 # Allow exactly one differing argument. That one position is widened
559559 # with union/2. A second difference means the clauses must stay separate.
560560 defp union_args ( [ existing_arg | existing ] , [ arg | args ] , acc , false ) do
561- union_args ( existing , args , [ Descr . union ( existing_arg , arg ) | acc ] , true )
561+ union_args ( existing , args , [ Descr . opt_union ( existing_arg , arg ) | acc ] , true )
562562 end
563563
564564 defp union_args ( [ _ | _ ] , [ _ | _ ] , _acc , true ) , do: nil
0 commit comments