@@ -46,8 +46,8 @@ defmodule Module.Types.Descr do
46
46
@ not_non_empty_list Map . delete ( @ term , :list )
47
47
@ not_list Map . replace! ( @ not_non_empty_list , :bitmap , @ bit_top - @ bit_empty_list )
48
48
49
- @ empty_intersection [ 0 , @ none , [ ] , :fun_bottom ]
50
- @ empty_difference [ 0 , [ ] , :fun_bottom ]
49
+ @ empty_intersection [ 0 , [ ] ]
50
+ @ empty_difference [ 0 , [ ] ]
51
51
52
52
defguard is_descr ( descr ) when is_map ( descr ) or descr == :term
53
53
@@ -398,12 +398,20 @@ defmodule Module.Types.Descr do
398
398
# Returning 0 from the callback is taken as none() for that subtype.
399
399
defp intersection ( :atom , v1 , v2 ) , do: atom_intersection ( v1 , v2 )
400
400
defp intersection ( :bitmap , v1 , v2 ) , do: v1 &&& v2
401
- defp intersection ( :dynamic , v1 , v2 ) , do: dynamic_intersection ( v1 , v2 )
402
401
defp intersection ( :list , v1 , v2 ) , do: list_intersection ( v1 , v2 )
403
402
defp intersection ( :map , v1 , v2 ) , do: map_intersection ( v1 , v2 )
404
403
defp intersection ( :optional , 1 , 1 ) , do: 1
405
404
defp intersection ( :tuple , v1 , v2 ) , do: tuple_intersection ( v1 , v2 )
406
- defp intersection ( :fun , v1 , v2 ) , do: fun_intersection ( v1 , v2 )
405
+
406
+ defp intersection ( :fun , v1 , v2 ) do
407
+ bdd = fun_intersection ( v1 , v2 )
408
+ if bdd == :fun_bottom , do: 0 , else: bdd
409
+ end
410
+
411
+ defp intersection ( :dynamic , v1 , v2 ) do
412
+ descr = dynamic_intersection ( v1 , v2 )
413
+ if descr == @ none , do: 0 , else: descr
414
+ end
407
415
408
416
@ doc """
409
417
Computes the difference between two types.
@@ -490,7 +498,11 @@ defmodule Module.Types.Descr do
490
498
defp difference ( :map , v1 , v2 ) , do: map_difference ( v1 , v2 )
491
499
defp difference ( :optional , 1 , 1 ) , do: 0
492
500
defp difference ( :tuple , v1 , v2 ) , do: tuple_difference ( v1 , v2 )
493
- defp difference ( :fun , v1 , v2 ) , do: fun_difference ( v1 , v2 )
501
+
502
+ defp difference ( :fun , v1 , v2 ) do
503
+ bdd = fun_difference ( v1 , v2 )
504
+ if bdd == :fun_bottom , do: 0 , else: bdd
505
+ end
494
506
495
507
@ doc """
496
508
Compute the negation of a type.
@@ -2391,10 +2403,6 @@ defmodule Module.Types.Descr do
2391
2403
:empty -> acc
2392
2404
end
2393
2405
end
2394
- |> case do
2395
- [ ] -> 0
2396
- acc -> acc
2397
- end
2398
2406
end
2399
2407
2400
2408
# Intersects two map literals; throws if their intersection is empty.
0 commit comments