|
@@ -458,18 +458,18 @@ let unify_min ctx el =
|
|
|
let rec unify_call_params ctx ?(overloads=None) cf el args r p inline =
|
|
|
(* 'overloads' will carry a ( return_result ) list, called 'compatible' *)
|
|
|
(* it's used to correctly support an overload selection algorithm *)
|
|
|
- let overloads, compatible = match cf, overloads with
|
|
|
+ let overloads, compatible, legacy = match cf, overloads with
|
|
|
| Some(TInst(c,pl),f), None when ctx.com.config.pf_overload && Meta.has Meta.Overload f.cf_meta ->
|
|
|
let overloads = List.filter (fun (_,f2) -> not (f == f2)) (Typeload.get_overloads c f.cf_name) in
|
|
|
if overloads = [] then (* is static function *)
|
|
|
- List.map (fun f -> f.cf_type, f) f.cf_overloads, []
|
|
|
+ List.map (fun f -> f.cf_type, f) f.cf_overloads, [], false
|
|
|
else
|
|
|
- overloads, []
|
|
|
+ overloads, [], false
|
|
|
| Some(_,f), None ->
|
|
|
- List.map (fun f -> f.cf_type, f) f.cf_overloads, []
|
|
|
+ List.map (fun f -> f.cf_type, f) f.cf_overloads, [], true
|
|
|
| _, Some s ->
|
|
|
s
|
|
|
- | _ -> [], []
|
|
|
+ | _ -> [], [], true
|
|
|
in
|
|
|
let next ?retval () =
|
|
|
let compatible = Option.map_default (fun r -> r :: compatible) compatible retval in
|
|
@@ -478,19 +478,16 @@ let rec unify_call_params ctx ?(overloads=None) cf el args r p inline =
|
|
|
let o = { o with cf_type = ft } in
|
|
|
let args, ret = (match follow (apply_params c.cl_types pl (field_type ctx c pl o p)) with (* I'm getting non-followed types here. Should it happen? *)
|
|
|
| TFun (tl,t) -> tl, t
|
|
|
- | _ ->
|
|
|
- print_endline (s_type (print_context()) o.cf_type);
|
|
|
- print_endline o.cf_pos.pfile;
|
|
|
- assert false
|
|
|
+ | _ -> assert false
|
|
|
) in
|
|
|
- Some (unify_call_params ctx ~overloads:(Some (l,compatible)) (Some (TInst(c,pl),o)) el args ret p inline)
|
|
|
+ Some (unify_call_params ctx ~overloads:(Some (l,compatible,legacy)) (Some (TInst(c,pl),o)) el args ret p inline)
|
|
|
| Some (t,_), (ft,o) :: l ->
|
|
|
let o = { o with cf_type = ft } in
|
|
|
let args, ret = (match Type.field_type o with
|
|
|
| TFun (tl,t) -> tl, t
|
|
|
| _ -> assert false
|
|
|
) in
|
|
|
- Some (unify_call_params ctx ~overloads:(Some (l,compatible)) (Some (t, o)) el args ret p inline)
|
|
|
+ Some (unify_call_params ctx ~overloads:(Some (l,compatible,legacy)) (Some (t, o)) el args ret p inline)
|
|
|
| _ ->
|
|
|
match compatible with
|
|
|
| [] -> None
|
|
@@ -544,7 +541,7 @@ let rec unify_call_params ctx ?(overloads=None) cf el args r p inline =
|
|
|
else
|
|
|
List.rev (acc), (TFun(args,r))
|
|
|
in
|
|
|
- if ctx.com.config.pf_overload then
|
|
|
+ if not legacy && ctx.com.config.pf_overload then
|
|
|
match next ~retval:(args,tf) () with
|
|
|
| Some l -> l
|
|
|
| None ->
|