|
@@ -49,7 +49,7 @@ let find_from ab pl a b =
|
|
|
|
|
|
let underlying_type_stack = new_rec_stack()
|
|
let underlying_type_stack = new_rec_stack()
|
|
|
|
|
|
-let rec get_underlying_type a pl =
|
|
|
|
|
|
+let rec get_underlying_type ?(return_first=false) a pl =
|
|
let maybe_recurse t =
|
|
let maybe_recurse t =
|
|
let rec loop t = match t with
|
|
let rec loop t = match t with
|
|
| TMono r ->
|
|
| TMono r ->
|
|
@@ -68,7 +68,13 @@ let rec get_underlying_type a pl =
|
|
let s = String.concat " -> " (List.map (fun t -> s_type pctx t) (List.rev (t :: underlying_type_stack.rec_stack))) in
|
|
let s = String.concat " -> " (List.map (fun t -> s_type pctx t) (List.rev (t :: underlying_type_stack.rec_stack))) in
|
|
error ("Abstract chain detected: " ^ s) a.a_pos
|
|
error ("Abstract chain detected: " ^ s) a.a_pos
|
|
end;
|
|
end;
|
|
- get_underlying_type a tl
|
|
|
|
|
|
+ (*
|
|
|
|
+ Even if only the first underlying type was requested
|
|
|
|
+ keep traversing to detect mutually recursive abstracts
|
|
|
|
+ *)
|
|
|
|
+ let result = get_underlying_type a tl in
|
|
|
|
+ if return_first then t
|
|
|
|
+ else result
|
|
| _ ->
|
|
| _ ->
|
|
t
|
|
t
|
|
in
|
|
in
|
|
@@ -76,6 +82,10 @@ let rec get_underlying_type a pl =
|
|
in
|
|
in
|
|
try
|
|
try
|
|
if not (Meta.has Meta.MultiType a.a_meta) then raise Not_found;
|
|
if not (Meta.has Meta.MultiType a.a_meta) then raise Not_found;
|
|
|
|
+ (* TODO:
|
|
|
|
+ Look into replacing `mk_mono` & `find_to` with `build_abstract a` & `TAbstract(a, pl)`.
|
|
|
|
+ `find_to` is probably needed for `@:multiType`
|
|
|
|
+ *)
|
|
let m = mk_mono() in
|
|
let m = mk_mono() in
|
|
let _ = find_to a pl m in
|
|
let _ = find_to a pl m in
|
|
maybe_recurse (follow m)
|
|
maybe_recurse (follow m)
|