浏览代码

store @:overload into cf_overload : resolve types using current context, allow type params usage

Nicolas Cannasse 13 年之前
父节点
当前提交
19a62898c7
共有 8 个文件被更改,包括 59 次插入49 次删除
  1. 1 0
      codegen.ml
  2. 2 1
      gencommon.ml
  3. 1 1
      gencpp.ml
  4. 1 0
      genswf9.ml
  5. 1 0
      type.ml
  6. 1 0
      typecore.ml
  7. 25 9
      typeload.ml
  8. 27 38
      typer.ml

+ 1 - 0
codegen.ml

@@ -323,6 +323,7 @@ let extend_xml_proxy ctx c t file p =
 						cf_kind = Var { v_read = AccResolve; v_write = AccNo };
 						cf_kind = Var { v_read = AccResolve; v_write = AccNo };
 						cf_params = [];
 						cf_params = [];
 						cf_expr = None;
 						cf_expr = None;
+						cf_overloads = [];
 					} in
 					} in
 					c.cl_fields <- PMap.add id f c.cl_fields;
 					c.cl_fields <- PMap.add id f c.cl_fields;
 				with
 				with

+ 2 - 1
gencommon.ml

@@ -1006,6 +1006,7 @@ let mk_class_field name t public pos kind params =
     cf_kind = kind;
     cf_kind = kind;
     cf_params = params;
     cf_params = params;
     cf_expr = None;
     cf_expr = None;
+	cf_overloads = [];
   }
   }
 
 
 let mk_iterator_access gen t expr =
 let mk_iterator_access gen t expr =
@@ -4257,7 +4258,7 @@ struct
           | _ ->
           | _ ->
             let ecall = match e with | None -> trace f; trace cf.cf_name; gen.gcon.error "This field should be called immediately" ef.epos; assert false | Some ecall -> ecall in
             let ecall = match e with | None -> trace f; trace cf.cf_name; gen.gcon.error "This field should be called immediately" ef.epos; assert false | Some ecall -> ecall in
             match cf.cf_params with
             match cf.cf_params with
-              | _ when has_meta ":overload" cf.cf_meta ->
+              | _ when cf.cf_overloads <> [] ->
                 mk_cast ecall.etype { ecall with eexpr = TCall({ e1 with eexpr = TField(ef, f) }, elist ) }
                 mk_cast ecall.etype { ecall with eexpr = TCall({ e1 with eexpr = TField(ef, f) }, elist ) }
               | [] ->
               | [] ->
                 let args, ret = get_args actual_t in
                 let args, ret = get_args actual_t in

+ 1 - 1
gencpp.ml

@@ -3071,7 +3071,7 @@ let generate common_ctx =
 	(match common_ctx.main with
 	(match common_ctx.main with
 	| None -> generate_dummy_main common_ctx
 	| None -> generate_dummy_main common_ctx
 	| Some e ->
 	| Some e ->
-		let main_field = { cf_name = "__main__"; cf_type = t_dynamic; cf_expr = Some e; cf_pos = e.epos; cf_public = true; cf_meta = []; cf_doc = None; cf_kind = Var { v_read = AccNormal; v_write = AccNormal; }; cf_params = [] } in
+		let main_field = { cf_name = "__main__"; cf_type = t_dynamic; cf_expr = Some e; cf_pos = e.epos; cf_public = true; cf_meta = []; cf_overloads = []; cf_doc = None; cf_kind = Var { v_read = AccNormal; v_write = AccNormal; }; cf_params = [] } in
 		let class_def = { null_class with cl_path = ([],"@Main"); cl_ordered_statics = [main_field] } in
 		let class_def = { null_class with cl_path = ([],"@Main"); cl_ordered_statics = [main_field] } in
 		main_deps := find_referenced_types common_ctx (TClassDecl class_def) super_deps constructor_deps false;
 		main_deps := find_referenced_types common_ctx (TClassDecl class_def) super_deps constructor_deps false;
 		generate_main common_ctx member_types super_deps class_def
 		generate_main common_ctx member_types super_deps class_def

+ 1 - 0
genswf9.ml

@@ -2076,6 +2076,7 @@ let generate_class ctx c =
 				cf_params = [];
 				cf_params = [];
 				cf_expr = None;
 				cf_expr = None;
 				cf_kind = Method MethNormal;
 				cf_kind = Method MethNormal;
+				cf_overloads = [];
 			};
 			};
 			hlf_slot = 0;
 			hlf_slot = 0;
 			hlf_kind = (HFMethod {
 			hlf_kind = (HFMethod {

+ 1 - 0
type.ml

@@ -136,6 +136,7 @@ and tclass_field = {
 	mutable cf_kind : field_kind;
 	mutable cf_kind : field_kind;
 	cf_params : (string * t) list;
 	cf_params : (string * t) list;
 	mutable cf_expr : texpr option;
 	mutable cf_expr : texpr option;
+	mutable cf_overloads : tclass_field list;
 }
 }
 
 
 and tclass_kind =
 and tclass_kind =

+ 1 - 0
typecore.ml

@@ -218,6 +218,7 @@ let mk_field name t p = {
 	cf_kind = Var { v_read = AccNormal; v_write = AccNormal };
 	cf_kind = Var { v_read = AccNormal; v_write = AccNormal };
 	cf_expr = None;
 	cf_expr = None;
 	cf_params = [];
 	cf_params = [];
+	cf_overloads = [];
 }
 }
 
 
 let fake_modules = Hashtbl.create 0
 let fake_modules = Hashtbl.create 0

+ 25 - 9
typeload.ml

@@ -265,7 +265,7 @@ and load_complex_type ctx p t =
 					in
 					in
 					load_complex_type ctx p t, Var { v_read = access i1 true; v_write = access i2 false }
 					load_complex_type ctx p t, Var { v_read = access i1 true; v_write = access i2 false }
 			) in
 			) in
-			PMap.add n {
+			let cf = {
 				cf_name = n;
 				cf_name = n;
 				cf_type = t;
 				cf_type = t;
 				cf_pos = p;
 				cf_pos = p;
@@ -275,7 +275,10 @@ and load_complex_type ctx p t =
 				cf_expr = None;
 				cf_expr = None;
 				cf_doc = f.cff_doc;
 				cf_doc = f.cff_doc;
 				cf_meta = f.cff_meta;
 				cf_meta = f.cff_meta;
-			} acc
+				cf_overloads = [];
+			} in
+			init_meta_overloads ctx cf;
+			PMap.add n cf acc
 		in
 		in
 		mk_anon (List.fold_left loop PMap.empty l)
 		mk_anon (List.fold_left loop PMap.empty l)
 	| CTFunction (args,r) ->
 	| CTFunction (args,r) ->
@@ -288,6 +291,22 @@ and load_complex_type ctx p t =
 				"",opt,load_complex_type ctx p t
 				"",opt,load_complex_type ctx p t
 			) args,load_complex_type ctx p r)
 			) args,load_complex_type ctx p r)
 
 
+and init_meta_overloads ctx cf =
+	let overloads = ref [] in
+	cf.cf_meta <- List.filter (fun m ->
+		match m with
+		| (":overload",[(EFunction (fname,f),p)],_)  ->
+			if fname <> None then error "Function name must not be part of @:overload" p;
+			(match f.f_expr with Some (EBlock [], _) -> () | _ -> error "Overload must only declare an empty method body {}" p);
+			let topt = function None -> error "Explicit type required" p | Some t -> load_complex_type ctx p t in
+			let args = List.map (fun (a,opt,t,_) ->  a,opt,topt t) f.f_args in
+			overloads := (args,topt f.f_type) :: !overloads;
+			false
+		| _ ->
+			true
+	) cf.cf_meta;
+	cf.cf_overloads <- List.map (fun (args,ret) -> { cf with cf_type = TFun (args,ret) }) (List.rev !overloads)
+
 let hide_types ctx =
 let hide_types ctx =
 	let old_locals = ctx.local_types in
 	let old_locals = ctx.local_types in
 	let old_type_params = ctx.type_params in
 	let old_type_params = ctx.type_params in
@@ -905,6 +924,7 @@ let init_class ctx c p herits fields =
 				cf_expr = None;
 				cf_expr = None;
 				cf_public = is_public f.cff_access None;
 				cf_public = is_public f.cff_access None;
 				cf_params = [];
 				cf_params = [];
+				cf_overloads = [];
 			} in
 			} in
 			let delay = (match e with
 			let delay = (match e with
 				| None when ctx.com.dead_code_elimination && not ctx.com.display ->
 				| None when ctx.com.dead_code_elimination && not ctx.com.display ->
@@ -946,13 +966,6 @@ let init_class ctx c p herits fields =
 			) in
 			) in
 			f, false, cf, delay
 			f, false, cf, delay
 		| FFun fd ->
 		| FFun fd ->
-			(match c.cl_super with
-				| None -> ()
-				| Some (c,_) ->
-					try
-						let sf = PMap.find name c.cl_fields in
-						f.cff_meta <- copy_meta sf.cf_meta f.cff_meta [":overload"];
-					with Not_found -> ());
 			let params = ref [] in
 			let params = ref [] in
 			params := List.map (fun (n,flags) ->
 			params := List.map (fun (n,flags) ->
 				(match flags with
 				(match flags with
@@ -1046,7 +1059,9 @@ let init_class ctx c p herits fields =
 				cf_expr = None;
 				cf_expr = None;
 				cf_public = is_public f.cff_access parent;
 				cf_public = is_public f.cff_access parent;
 				cf_params = params;
 				cf_params = params;
+				cf_overloads = [];
 			} in
 			} in
+			init_meta_overloads ctx cf;
 			let r = exc_protect (fun r ->
 			let r = exc_protect (fun r ->
 				if not !return_partial_type then begin
 				if not !return_partial_type then begin
 					r := (fun() -> t);
 					r := (fun() -> t);
@@ -1125,6 +1140,7 @@ let init_class ctx c p herits fields =
 				cf_type = ret;
 				cf_type = ret;
 				cf_public = is_public f.cff_access None;
 				cf_public = is_public f.cff_access None;
 				cf_params = [];
 				cf_params = [];
+				cf_overloads = [];
 			} in
 			} in
 			if ctx.com.dead_code_elimination && not ctx.com.display then begin
 			if ctx.com.dead_code_elimination && not ctx.com.display then begin
 				let r = exc_protect (fun r ->
 				let r = exc_protect (fun r ->

+ 27 - 38
typer.ml

@@ -66,16 +66,6 @@ let check_assign ctx e =
 	| _ ->
 	| _ ->
 		error "Invalid assign" e.epos
 		error "Invalid assign" e.epos
 
 
-let rec get_overloads ctx p = function
-	| (":overload",[(EFunction (_,fu),p)],_) :: l ->
-		let topt = function None -> t_dynamic | Some t -> (try Typeload.load_complex_type ctx p t with | Error (Protect _,_) as e -> raise e | Error _ -> t_dynamic) in
-		let args = List.map (fun (a,opt,t,_) ->  a,opt,topt t) fu.f_args in
-		TFun (args,topt fu.f_type) :: get_overloads ctx p l
-	| _ :: l ->
-		get_overloads ctx p l
-	| [] ->
-		[]
-
 let rec mark_used_class ctx c =
 let rec mark_used_class ctx c =
 	if ctx.com.dead_code_elimination && not (has_meta ":?used" c.cl_meta) then begin
 	if ctx.com.dead_code_elimination && not (has_meta ":?used" c.cl_meta) then begin
 		c.cl_meta <- (":?used",[],c.cl_pos) :: c.cl_meta;
 		c.cl_meta <- (":?used",[],c.cl_pos) :: c.cl_meta;
@@ -195,29 +185,24 @@ let unify_min ctx el =
 		if not ctx.untyped then display_error ctx (error_msg (Unify l)) p;
 		if not ctx.untyped then display_error ctx (error_msg (Unify l)) p;
 		(List.hd el).etype
 		(List.hd el).etype
 
 
-let rec unify_call_params ctx name el args r p inline =
+let rec unify_call_params ctx cf el args r p inline =
 	let next() =
 	let next() =
-		match name with
-		| None -> None
-		| Some (n,meta) ->
-			let rec loop = function
-				| [] -> None
-				| (":overload",[(EFunction (fname,f),p)],_) :: l ->
-					if fname <> None then error "Function name must not be part of @:overload" p;
-					(match f.f_expr with Some (EBlock [], _) -> () | _ -> error "Overload must only declare an empty method body {}" p);
-					let topt = function None -> error "Explicit type required" p | Some t -> Typeload.load_complex_type ctx p t in
-					let args = List.map (fun (a,opt,t,_) ->  a,opt,topt t) f.f_args in
-					Some (unify_call_params ctx (Some (n,l)) el args (topt f.f_type) p inline)
-				| _ :: l -> loop l
-			in
-			loop meta
+		match cf with
+		| Some { cf_overloads = o :: l } ->
+			let args, ret = (match field_type o with
+				| TFun (tl,t) -> tl, t
+				| _ -> assert false
+			) in
+			Some (unify_call_params ctx (Some { o with cf_overloads = l }) el args ret p inline)
+		| _ ->
+			None
 	in
 	in
 	let error acc txt =
 	let error acc txt =
 		match next() with
 		match next() with
 		| Some l -> l
 		| Some l -> l
 		| None ->
 		| None ->
 		let format_arg = (fun (name,opt,_) -> (if opt then "?" else "") ^ name) in
 		let format_arg = (fun (name,opt,_) -> (if opt then "?" else "") ^ name) in
-		let argstr = "Function " ^ (match name with None -> "" | Some (n,_) -> "'" ^ n ^ "' ") ^ "requires " ^ (if args = [] then "no arguments" else "arguments : " ^ String.concat ", " (List.map format_arg args)) in
+		let argstr = "Function " ^ (match cf with None -> "" | Some f -> "'" ^ f.cf_name ^ "' ") ^ "requires " ^ (if args = [] then "no arguments" else "arguments : " ^ String.concat ", " (List.map format_arg args)) in
 		display_error ctx (txt ^ " arguments\n" ^ argstr) p;
 		display_error ctx (txt ^ " arguments\n" ^ argstr) p;
 		List.rev (List.map fst acc), (TFun(args,r))
 		List.rev (List.map fst acc), (TFun(args,r))
 	in
 	in
@@ -317,6 +302,7 @@ let rec type_module_type ctx t tparams p =
 				cf_meta = no_meta;
 				cf_meta = no_meta;
 				cf_expr = None;
 				cf_expr = None;
 				cf_params = [];
 				cf_params = [];
+				cf_overloads = [];
 			} acc
 			} acc
 		) e.e_constrs PMap.empty in
 		) e.e_constrs PMap.empty in
 		let t_tmp = {
 		let t_tmp = {
@@ -712,6 +698,7 @@ let rec type_field ctx e i p mode =
 				cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> AccNo) };
 				cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> AccNo) };
 				cf_expr = None;
 				cf_expr = None;
 				cf_params = [];
 				cf_params = [];
+				cf_overloads = [];
 			} in
 			} in
 			a.a_fields <- PMap.add i f a.a_fields;
 			a.a_fields <- PMap.add i f a.a_fields;
 			field_access ctx mode f (field_type f) e p
 			field_access ctx mode f (field_type f) e p
@@ -728,6 +715,7 @@ let rec type_field ctx e i p mode =
 			cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> AccNo) };
 			cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> AccNo) };
 			cf_expr = None;
 			cf_expr = None;
 			cf_params = [];
 			cf_params = [];
+			cf_overloads = [];
 		} in
 		} in
 		let x = ref Opened in
 		let x = ref Opened in
 		let t = TAnon { a_fields = PMap.add i f PMap.empty; a_status = x } in
 		let t = TAnon { a_fields = PMap.add i f PMap.empty; a_status = x } in
@@ -1789,7 +1777,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			| _ -> ());
 			| _ -> ());
 			let el, _ = (match follow ct with
 			let el, _ = (match follow ct with
 			| TFun (args,r) ->
 			| TFun (args,r) ->
-				unify_call_params ctx (Some ("new",f.cf_meta)) el args r p false
+				unify_call_params ctx (Some f) el args r p false
 			| _ ->
 			| _ ->
 				error "Constructor is not a function" p
 				error "Constructor is not a function" p
 			) in
 			) in
@@ -1966,7 +1954,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			| [] -> e.etype
 			| [] -> e.etype
 			| _ ->
 			| _ ->
 				let get_field acc f =
 				let get_field acc f =
-					if not f.cf_public then acc else (f.cf_name,f.cf_type,f.cf_doc) :: List.map (fun t -> f.cf_name,t,f.cf_doc) (get_overloads ctx p f.cf_meta) @ acc
+					List.fold_left (fun acc f -> if f.cf_public then (f.cf_name,f.cf_type,f.cf_doc) :: acc else acc) acc (f :: f.cf_overloads)
 				in
 				in
 				raise (DisplayFields (List.fold_left get_field [] fields))
 				raise (DisplayFields (List.fold_left get_field [] fields))
 		) in
 		) in
@@ -1978,7 +1966,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		(match follow t with
 		(match follow t with
 		| TInst (c,params) ->
 		| TInst (c,params) ->
 			let ct, f = get_constructor c params p in
 			let ct, f = get_constructor c params p in
-			raise (DisplayTypes (ct :: get_overloads ctx p f.cf_meta))
+			raise (DisplayTypes (ct :: List.map (fun f -> f.cf_type) f.cf_overloads))
 		| _ ->
 		| _ ->
 			error "Not a class" p)
 			error "Not a class" p)
 	| ECheckType (e,t) ->
 	| ECheckType (e,t) ->
@@ -2018,7 +2006,7 @@ and type_call ctx e el t p =
 			mark_used_field ctx f;
 			mark_used_field ctx f;
 			let el, _ = (match follow ct with
 			let el, _ = (match follow ct with
 			| TFun (args,r) ->
 			| TFun (args,r) ->
-				unify_call_params ctx (Some ("new",f.cf_meta)) el args r p false
+				unify_call_params ctx (Some f) el args r p false
 			| _ ->
 			| _ ->
 				error "Constructor is not a function" p
 				error "Constructor is not a function" p
 			) in
 			) in
@@ -2033,7 +2021,7 @@ and type_call ctx e el t p =
 			match acc with
 			match acc with
 			| AKInline (ethis,f,t) ->
 			| AKInline (ethis,f,t) ->
 				let params, tfunc = (match follow t with
 				let params, tfunc = (match follow t with
-					| TFun (args,r) -> unify_call_params ctx (Some (f.cf_name,f.cf_meta)) el args r p true
+					| TFun (args,r) -> unify_call_params ctx (Some f) el args r p true
 					| _ -> error (s_type (print_context()) t ^ " cannot be called") p
 					| _ -> error (s_type (print_context()) t ^ " cannot be called") p
 				) in
 				) in
 				make_call ctx (mk (TField (ethis,f.cf_name)) t p) params (match tfunc with TFun(_,r) -> r | _ -> assert false) p
 				make_call ctx (mk (TField (ethis,f.cf_name)) t p) params (match tfunc with TFun(_,r) -> r | _ -> assert false) p
@@ -2046,7 +2034,7 @@ and type_call ctx e el t p =
 						loop acc (Interp.make_ast eparam :: el)
 						loop acc (Interp.make_ast eparam :: el)
 					| AKExpr _ | AKField _ | AKInline _ ->
 					| AKExpr _ | AKField _ | AKInline _ ->
 						let params, tfunc = (match follow et.etype with
 						let params, tfunc = (match follow et.etype with
-							| TFun ( _ :: args,r) -> unify_call_params ctx (Some (ef.cf_name,ef.cf_meta)) el args r p (ef.cf_kind = Method MethInline)
+							| TFun ( _ :: args,r) -> unify_call_params ctx (Some ef) el args r p (ef.cf_kind = Method MethInline)
 							| _ -> assert false
 							| _ -> assert false
 						) in
 						) in
 						let args,r = match tfunc with TFun(args,r) -> args,r | _ -> assert false in
 						let args,r = match tfunc with TFun(args,r) -> args,r | _ -> assert false in
@@ -2082,7 +2070,7 @@ and type_call ctx e el t p =
 			| AKExpr e | AKField (e,_) as acc ->
 			| AKExpr e | AKField (e,_) as acc ->
 				let el , t, e = (match follow e.etype with
 				let el , t, e = (match follow e.etype with
 				| TFun (args,r) ->
 				| TFun (args,r) ->
-					let fopts = (match acc with AKField (_,f) -> Some (f.cf_name,f.cf_meta) | _ -> match e.eexpr with TField (e,f) -> Some (f,[]) | _ -> None) in
+					let fopts = (match acc with AKField (_,f) -> Some f | _ -> None) in
 					let el, tfunc = unify_call_params ctx fopts el args r p false in
 					let el, tfunc = unify_call_params ctx fopts el args r p false in
 					el,(match tfunc with TFun(_,r) -> r | _ -> assert false), {e with etype = tfunc}
 					el,(match tfunc with TFun(_,r) -> r | _ -> assert false), {e with etype = tfunc}
 				| TMono _ ->
 				| TMono _ ->
@@ -2646,7 +2634,7 @@ let load_macro ctx cpath f p =
 		| TInst (c,_) -> (try PMap.find f c.cl_statics with Not_found -> error ("Method " ^ f ^ " not found on class " ^ s_type_path cpath) p)
 		| TInst (c,_) -> (try PMap.find f c.cl_statics with Not_found -> error ("Method " ^ f ^ " not found on class " ^ s_type_path cpath) p)
 		| _ -> error "Macro should be called on a class" p
 		| _ -> error "Macro should be called on a class" p
 	) in
 	) in
-	let meth = (match follow meth.cf_type with TFun (args,ret) -> args,ret,meth.cf_pos | _ -> error "Macro call should be a method" p) in
+	let meth = (match follow meth.cf_type with TFun (args,ret) -> args,ret,meth | _ -> error "Macro call should be a method" p) in
 	let in_macro = ctx.in_macro in
 	let in_macro = ctx.in_macro in
 	if not in_macro then begin
 	if not in_macro then begin
 		finalize ctx2;
 		finalize ctx2;
@@ -2666,7 +2654,8 @@ let load_macro ctx cpath f p =
 	ctx2, meth, call
 	ctx2, meth, call
 
 
 let type_macro ctx mode cpath f (el:Ast.expr list) p =
 let type_macro ctx mode cpath f (el:Ast.expr list) p =
-	let ctx2, (margs,mret,mpos), call_macro = load_macro ctx cpath f p in
+	let ctx2, (margs,mret,mfield), call_macro = load_macro ctx cpath f p in
+	let mpos = mfield.cf_pos in
 	let ctexpr = { tpackage = ["haxe";"macro"]; tname = "Expr"; tparams = []; tsub = None } in
 	let ctexpr = { tpackage = ["haxe";"macro"]; tname = "Expr"; tparams = []; tsub = None } in
 	let expr = Typeload.load_instance ctx2 ctexpr p false in
 	let expr = Typeload.load_instance ctx2 ctexpr p false in
 	(match mode with
 	(match mode with
@@ -2727,7 +2716,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 			incr index;
 			incr index;
 			(EArray ((EArrayDecl [e],p),(EConst (Int (string_of_int (!index))),p)),p)
 			(EArray ((EArrayDecl [e],p),(EConst (Int (string_of_int (!index))),p)),p)
 		) el in
 		) el in
-		let elt, _ = unify_call_params ctx2 (Some (f,[])) constants (List.map fst eargs) t_dynamic p false in
+		let elt, _ = unify_call_params ctx2 (Some mfield) constants (List.map fst eargs) t_dynamic p false in
 		List.map2 (fun (_,ise) e ->
 		List.map2 (fun (_,ise) e ->
 			let e, et = (match e.eexpr with
 			let e, et = (match e.eexpr with
 				(* get back our index and real expression *)
 				(* get back our index and real expression *)
@@ -2798,8 +2787,8 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 	e
 	e
 
 
 let call_macro ctx path meth args p =
 let call_macro ctx path meth args p =
-	let ctx2, (margs,_,_), call = load_macro ctx path meth p in
-	let el, _ = unify_call_params ctx2 (Some (meth,[])) args margs t_dynamic p false in
+	let ctx2, (margs,_,mfield), call = load_macro ctx path meth p in
+	let el, _ = unify_call_params ctx2 (Some mfield) args margs t_dynamic p false in
 	call (List.map (fun e -> try Interp.make_const e with Exit -> error "Parameter should be a constant" e.epos) el)
 	call (List.map (fun e -> try Interp.make_const e with Exit -> error "Parameter should be a constant" e.epos) el)
 
 
 let call_init_macro ctx e =
 let call_init_macro ctx e =