|
@@ -1357,7 +1357,21 @@ and type_local_function ctx kind f with_type p =
|
|
|
| [t2] ->
|
|
|
if not (List.exists (shallow_eq t) stack) then loop (t :: stack) t2
|
|
|
| l ->
|
|
|
- handle_abstract_matrix l
|
|
|
+ (* For cases like nested EitherType, we want a flat list of all possible candidates.
|
|
|
+ This might be controversial because those could be considered transitive casts,
|
|
|
+ but it's unclear if that's a bad thing for this kind of inference (issue #10982). *)
|
|
|
+ let rec loop acc l = match l with
|
|
|
+ | t :: l ->
|
|
|
+ begin match follow t with
|
|
|
+ | TAbstract(a,tl) ->
|
|
|
+ loop acc (l @ get_abstract_froms ctx a tl)
|
|
|
+ | _ ->
|
|
|
+ loop (t :: acc) l
|
|
|
+ end
|
|
|
+ | [] ->
|
|
|
+ List.rev acc
|
|
|
+ in
|
|
|
+ handle_abstract_matrix (loop [] l)
|
|
|
end
|
|
|
| _ -> ())
|
|
|
in
|