|
@@ -35,7 +35,7 @@ open Globals
|
|
|
|
|
|
let build_count = ref 0
|
|
let build_count = ref 0
|
|
|
|
|
|
-let type_function_params_rec = ref (fun _ _ _ _ -> die "" __LOC__)
|
|
|
|
|
|
+let type_function_params_ref = ref (fun _ _ _ _ _ -> die "" __LOC__)
|
|
|
|
|
|
let check_field_access ctx cff =
|
|
let check_field_access ctx cff =
|
|
let display_access = ref None in
|
|
let display_access = ref None in
|
|
@@ -576,7 +576,7 @@ and load_complex_type' ctx allow_display (t,p) =
|
|
no_expr e;
|
|
no_expr e;
|
|
topt t, Var { v_read = AccNormal; v_write = AccNormal }
|
|
topt t, Var { v_read = AccNormal; v_write = AccNormal }
|
|
| FFun fd ->
|
|
| FFun fd ->
|
|
- params := (!type_function_params_rec) ctx fd (fst f.cff_name) p;
|
|
|
|
|
|
+ params := (!type_function_params_ref) ctx fd TPHAnonField (fst f.cff_name) p;
|
|
no_expr fd.f_expr;
|
|
no_expr fd.f_expr;
|
|
let old = ctx.type_params in
|
|
let old = ctx.type_params in
|
|
ctx.type_params <- !params @ old;
|
|
ctx.type_params <- !params @ old;
|
|
@@ -673,7 +673,7 @@ and init_meta_overloads ctx co cf =
|
|
not (List.mem t l) (* TODO: this still looks suspicious *)
|
|
not (List.mem t l) (* TODO: this still looks suspicious *)
|
|
) ctx.type_params
|
|
) ctx.type_params
|
|
end;
|
|
end;
|
|
- let params : type_params = (!type_function_params_rec) ctx f cf.cf_name p in
|
|
|
|
|
|
+ let params : type_params = (!type_function_params_ref) ctx f TPHMethod cf.cf_name p in
|
|
ctx.type_params <- params @ ctx.type_params;
|
|
ctx.type_params <- params @ ctx.type_params;
|
|
let topt = function None -> raise_typing_error "Explicit type required" p | Some t -> load_complex_type ctx true t in
|
|
let topt = function None -> raise_typing_error "Explicit type required" p | Some t -> load_complex_type ctx true t in
|
|
let args =
|
|
let args =
|
|
@@ -728,12 +728,6 @@ let load_type_hint ?(opt=false) ctx pcur t =
|
|
(* ---------------------------------------------------------------------- *)
|
|
(* ---------------------------------------------------------------------- *)
|
|
(* PASS 1 & 2 : Module and Class Structure *)
|
|
(* PASS 1 & 2 : Module and Class Structure *)
|
|
|
|
|
|
-type type_param_host =
|
|
|
|
- | TPHType
|
|
|
|
- | TPHConstructor
|
|
|
|
- | TPHMethod
|
|
|
|
- | TPHEnumConstructor
|
|
|
|
-
|
|
|
|
let rec type_type_param ctx host path get_params p tp =
|
|
let rec type_type_param ctx host path get_params p tp =
|
|
let n = fst tp.tp_name in
|
|
let n = fst tp.tp_name in
|
|
let c = mk_class ctx.m.curmod (fst path @ [snd path],n) (pos tp.tp_name) (pos tp.tp_name) in
|
|
let c = mk_class ctx.m.curmod (fst path @ [snd path],n) (pos tp.tp_name) (pos tp.tp_name) in
|
|
@@ -754,7 +748,9 @@ let rec type_type_param ctx host path get_params p tp =
|
|
()
|
|
()
|
|
| TPHConstructor
|
|
| TPHConstructor
|
|
| TPHMethod
|
|
| TPHMethod
|
|
- | TPHEnumConstructor ->
|
|
|
|
|
|
+ | TPHEnumConstructor
|
|
|
|
+ | TPHAnonField
|
|
|
|
+ | TPHLocal ->
|
|
display_error ctx.com "Default type parameters are only supported on types" (pos ct)
|
|
display_error ctx.com "Default type parameters are only supported on types" (pos ct)
|
|
end;
|
|
end;
|
|
t
|
|
t
|
|
@@ -763,7 +759,7 @@ let rec type_type_param ctx host path get_params p tp =
|
|
in
|
|
in
|
|
let ttp = match tp.tp_constraints with
|
|
let ttp = match tp.tp_constraints with
|
|
| None ->
|
|
| None ->
|
|
- mk_type_param c default None
|
|
|
|
|
|
+ mk_type_param c host default None
|
|
| Some th ->
|
|
| Some th ->
|
|
let constraints = lazy (
|
|
let constraints = lazy (
|
|
let ctx = { ctx with type_params = ctx.type_params @ get_params() } in
|
|
let ctx = { ctx with type_params = ctx.type_params @ get_params() } in
|
|
@@ -787,7 +783,7 @@ let rec type_type_param ctx host path get_params p tp =
|
|
constr
|
|
constr
|
|
) in
|
|
) in
|
|
delay ctx PConnectField (fun () -> ignore (Lazy.force constraints));
|
|
delay ctx PConnectField (fun () -> ignore (Lazy.force constraints));
|
|
- mk_type_param c default (Some constraints)
|
|
|
|
|
|
+ mk_type_param c host default (Some constraints)
|
|
in
|
|
in
|
|
c.cl_kind <- KTypeParameter ttp;
|
|
c.cl_kind <- KTypeParameter ttp;
|
|
ttp
|
|
ttp
|