浏览代码

remove second return from unify_call_args

We only checked for the return type in a single place, and the return type is just the argument that passed in
Simon Krajewski 4 年之前
父节点
当前提交
ead8640e66
共有 3 个文件被更改,包括 7 次插入8 次删除
  1. 3 4
      src/typing/callUnification.ml
  2. 2 2
      src/typing/macroContext.ml
  3. 2 2
      src/typing/typer.ml

+ 3 - 4
src/typing/callUnification.ml

@@ -203,7 +203,7 @@ let rec unify_call_args ctx el args r callp inline force_inline in_overload =
 	in
 	let el = try loop el args with exc -> restore(); raise exc; in
 	restore();
-	el,TFun(args,r,false (* corotodo *))
+	el
 
 type overload_kind =
 	| OverloadProper (* @:overload or overload *)
@@ -305,7 +305,7 @@ let unify_field_call ctx fa el_typed el p inline =
 						List.rev acc_el,List.rev acc_args,args
 				in
 				let el_typed,args_typed,args = loop [] [] tmap args el_typed in
-				let el,_ =
+				let el =
 					try
 						unify_call_args ctx el args ret p inline is_forced_inline in_overload
 					with DisplayException.DisplayException de ->
@@ -530,8 +530,7 @@ object(self)
 		let rec loop t = match follow t with
 		| TFun (args,r,coro) ->
 			if coro && not ctx.is_coroutine then error "Cannot directly call coroutine from a normal function, use start/create methods instead" p;
-			let el, tfunc = unify_call_args ctx el args r p false false false in
-			let r = match tfunc with TFun(_,r,_) -> r | _ -> die "" __LOC__ in
+			let el = unify_call_args ctx el args r p false false false in
 			mk (TCall (e,el)) r p
 		| TAbstract(a,tl) as t ->
 			let check_callable () =

+ 2 - 2
src/typing/macroContext.ml

@@ -698,7 +698,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 			incr index;
 			(EArray ((EArrayDecl [e],p),(EConst (Int (string_of_int (!index))),p)),p)
 		) el in
-		let elt = fst (CallUnification.unify_call_args mctx constants (List.map fst eargs) t_dynamic p false false false) in
+		let elt = CallUnification.unify_call_args mctx constants (List.map fst eargs) t_dynamic p false false false in
 		List.map2 (fun (_,mct) e ->
 			let e, et = (match e.eexpr with
 				(* get back our index and real expression *)
@@ -770,7 +770,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
 let call_macro ctx path meth args p =
 	let mctx, (margs,_,mclass,mfield), call = load_macro ctx false path meth p in
 	mctx.curclass <- null_class;
-	let el, _ = CallUnification.unify_call_args mctx args margs t_dynamic p false false false in
+	let el = CallUnification.unify_call_args mctx args margs t_dynamic p false false false in
 	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 =

+ 2 - 2
src/typing/typer.ml

@@ -1005,7 +1005,7 @@ and type_new ctx path el with_type force_inline p =
 		| None ->
 			raise_error (No_constructor (TClassDecl c)) p
 		| Some(tl,tr) ->
-			let el,_ = unify_call_args ctx el tl tr p false false false in
+			let el = unify_call_args ctx el tl tr p false false false in
 			mk (TNew (c,params,el)) t p
 		end
 	| TAbstract({a_impl = Some c} as a,tl) when not (Meta.has Meta.MultiType a.a_meta) ->
@@ -1587,7 +1587,7 @@ and type_call ?(mode=MGet) ctx e el (with_type:WithType.t) inline p =
 	let create_coroutine e args ret p =
 		let args = args @ [("_hx_continuation",false,(tfun [ret; t_dynamic] ctx.com.basic.tvoid))] in
 		let ret = ctx.com.basic.tvoid in
-		let el, _ = unify_call_args ctx el args ret p false false false in
+		let el = unify_call_args ctx el args ret p false false false in
 		mk (TCall (e, el)) (tfun [t_dynamic; t_dynamic] ctx.com.basic.tvoid) p
 	in
 	match e, el with