Skip to content

Commit

Permalink
remove mostly unused position
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Dec 11, 2024
1 parent 5c65f03 commit 2d24fb1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/context/display/displayTexpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let check_display_class ctx decls c =
List.iter check_field c.cl_ordered_statics;
| _ ->
let sc = find_class_by_position decls c.cl_name_pos in
ignore(Typeload.type_type_params ctx TPHType c.cl_path null_pos sc.d_params);
ignore(Typeload.type_type_params ctx TPHType c.cl_path sc.d_params);
List.iter (function
| (HExtends ptp | HImplements ptp) when display_position#enclosed_in ptp.pos_full ->
ignore(Typeload.load_instance ~allow_display:true ctx ptp ParamNormal LoadNormal)
Expand All @@ -102,7 +102,7 @@ let check_display_class ctx decls c =

let check_display_enum ctx decls en =
let se = find_enum_by_position decls en.e_name_pos in
ignore(Typeload.type_type_params ctx TPHType en.e_path null_pos se.d_params);
ignore(Typeload.type_type_params ctx TPHType en.e_path se.d_params);
PMap.iter (fun _ ef ->
if display_position#enclosed_in ef.ef_pos then begin
let sef = find_enum_field_by_position se ef.ef_name_pos in
Expand All @@ -112,12 +112,12 @@ let check_display_enum ctx decls en =

let check_display_typedef ctx decls td =
let st = find_typedef_by_position decls td.t_name_pos in
ignore(Typeload.type_type_params ctx TPHType td.t_path null_pos st.d_params);
ignore(Typeload.type_type_params ctx TPHType td.t_path st.d_params);
ignore(Typeload.load_complex_type ctx true LoadNormal st.d_data)

let check_display_abstract ctx decls a =
let sa = find_abstract_by_position decls a.a_name_pos in
ignore(Typeload.type_type_params ctx TPHType a.a_path null_pos sa.d_params);
ignore(Typeload.type_type_params ctx TPHType a.a_path sa.d_params);
List.iter (function
| (AbOver(ct,p) | AbFrom(ct,p) | AbTo(ct,p)) when display_position#enclosed_in p ->
ignore(Typeload.load_complex_type ctx true LoadNormal (ct,p))
Expand Down
16 changes: 8 additions & 8 deletions src/typing/typeload.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open Typecore
open Error
open Globals

let type_function_params_ref = ref (fun _ _ _ _ _ -> die "" __LOC__)
let type_function_params_ref = ref (fun _ _ _ _ -> die "" __LOC__)

let check_field_access ctx cff =
let display_access = ref None in
Expand Down Expand Up @@ -557,7 +557,7 @@ and load_complex_type' ctx allow_display mode (t,p) =
no_expr e;
topt LoadNormal t, Var { v_read = AccNormal; v_write = AccNormal }
| FFun fd ->
params := (!type_function_params_ref) ctx fd TPHAnonField (fst f.cff_name) p;
params := (!type_function_params_ref) ctx fd TPHAnonField (fst f.cff_name);
no_expr fd.f_expr;
let old = ctx.type_params in
ctx.type_params <- !params @ old;
Expand Down Expand Up @@ -652,7 +652,7 @@ and init_meta_overloads ctx co cf =
ttp.ttp_host <> TPHMethod
) ctx.type_params
end;
let params : type_params = (!type_function_params_ref) ctx f TPHMethod cf.cf_name p in
let params : type_params = (!type_function_params_ref) ctx f TPHMethod cf.cf_name in
ctx.type_params <- params @ ctx.type_params;
let topt mode = function None -> raise_typing_error "Explicit type required" p | Some t -> load_complex_type ctx true mode t in
let args =
Expand Down Expand Up @@ -707,22 +707,22 @@ let load_type_hint ?(opt=false) ctx pcur mode t =
(* ---------------------------------------------------------------------- *)
(* PASS 1 & 2 : Module and Class Structure *)

let rec type_type_param ctx host path p tp =
let rec type_type_param ctx host path tp =
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
c.cl_params <- type_type_params ctx host c.cl_path p tp.tp_params;
c.cl_params <- type_type_params ctx host c.cl_path tp.tp_params;
c.cl_meta <- tp.Ast.tp_meta;
let ttp = mk_type_param c host None None in
if ctx.m.is_display_file && DisplayPosition.display_position#enclosed_in (pos tp.tp_name) then
DisplayEmitter.display_type ctx ttp.ttp_type (pos tp.tp_name);
ttp

and type_type_params ctx host path p tpl =
and type_type_params ctx host path tpl =
let names = ref [] in
let param_pairs = List.map (fun tp ->
if List.exists (fun name -> name = fst tp.tp_name) !names then display_error ctx.com ("Duplicate type parameter name: " ^ fst tp.tp_name) (pos tp.tp_name);
names := (fst tp.tp_name) :: !names;
tp,type_type_param ctx host path p tp
tp,type_type_param ctx host path tp
) tpl in
let params = List.map snd param_pairs in
let ctx = TyperManager.clone_for_type_params ctx (params @ ctx.type_params) in
Expand Down Expand Up @@ -764,7 +764,7 @@ and type_type_params ctx host path p tpl =
let rec loop t =
match follow t with
| TInst (c2,_) when ttp.ttp_class == c2 ->
raise_typing_error "Recursive constraint parameter is not allowed" p
raise_typing_error "Recursive constraint parameter is not allowed" (pos th)
| TInst ({ cl_kind = KTypeParameter ttp },_) ->
delay ctx.g PConnectField (fun () -> List.iter loop (get_constraints ttp))
| _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typeloadFields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ let setup_args_ret ctx cctx fctx name fd p =

let create_method (ctx,cctx,fctx) c f cf fd p =
let name = fst f.cff_name in
let params = TypeloadFunction.type_function_params ctx fd TPHMethod name p in
let params = TypeloadFunction.type_function_params ctx fd TPHMethod name in
if fctx.is_generic then begin
if params = [] then raise_typing_error "Generic functions must have type parameters" p;
end;
Expand Down
4 changes: 2 additions & 2 deletions src/typing/typeloadFunction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ let save_field_state ctx =
ctx.f.locals <- locals;
)

let type_function_params ctx fd host fname p =
Typeload.type_type_params ctx host ([],fname) p fd.f_params
let type_function_params ctx fd host fname =
Typeload.type_type_params ctx host ([],fname) fd.f_params

let type_function ctx (args : function_arguments) ret e do_display p =
ctx.e.ret <- ret;
Expand Down
10 changes: 5 additions & 5 deletions src/typing/typeloadModule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module ModuleLevel = struct
List.iter (fun d ->
match d with
| ((EClass d, p),TClassDecl c) ->
c.cl_params <- type_type_params ctx_m TPHType c.cl_path p d.d_params;
c.cl_params <- type_type_params ctx_m TPHType c.cl_path d.d_params;
if Meta.has Meta.Generic c.cl_meta && c.cl_params <> [] then c.cl_kind <- KGeneric;
if Meta.has Meta.FunctionalInterface c.cl_meta then begin
if not (has_class_flag c CInterface) then
Expand All @@ -331,11 +331,11 @@ module ModuleLevel = struct
end;
if c.cl_path = (["haxe";"macro"],"MacroType") then c.cl_kind <- KMacroType;
| ((EEnum d, p),TEnumDecl e) ->
e.e_params <- type_type_params ctx_m TPHType e.e_path p d.d_params;
e.e_params <- type_type_params ctx_m TPHType e.e_path d.d_params;
| ((ETypedef d, p),TTypeDecl t) ->
t.t_params <- type_type_params ctx_m TPHType t.t_path p d.d_params;
t.t_params <- type_type_params ctx_m TPHType t.t_path d.d_params;
| ((EAbstract d, p),TAbstractDecl a) ->
a.a_params <- type_type_params ctx_m TPHType a.a_path p d.d_params;
a.a_params <- type_type_params ctx_m TPHType a.a_path d.d_params;
| _ ->
die "" __LOC__
) decls
Expand All @@ -344,7 +344,7 @@ end
module TypeLevel = struct
let load_enum_field ctx_en e et is_flat index c =
let p = c.ec_pos in
let params = type_type_params ctx_en TPHEnumConstructor ([],fst c.ec_name) c.ec_pos c.ec_params in
let params = type_type_params ctx_en TPHEnumConstructor ([],fst c.ec_name) c.ec_params in
let ctx_ef = TyperManager.clone_for_enum_field ctx_en (params @ ctx_en.type_params) in
let rt = (match c.ec_type with
| None -> et
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ and type_map_declaration ctx e1 el with_type p =

and type_local_function ctx_from kind f with_type p =
let name,inline = match kind with FKNamed (name,inline) -> Some name,inline | _ -> None,false in
let params = TypeloadFunction.type_function_params ctx_from f TPHLocal (match name with None -> "localfun" | Some (n,_) -> n) p in
let params = TypeloadFunction.type_function_params ctx_from f TPHLocal (match name with None -> "localfun" | Some (n,_) -> n) in
let curfun = match ctx_from.e.curfun with
| FunStatic -> FunStatic
| FunMemberAbstract
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue11870/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:1: characters 1-34 : Recursive constraint parameter is not allowed
Main.hx:1: characters 27-28 : Recursive constraint parameter is not allowed

0 comments on commit 2d24fb1

Please sign in to comment.