Browse Source

I need to stop OCDing about whitespaces

Simon Krajewski 11 years ago
parent
commit
be70f1a04a
12 changed files with 164 additions and 163 deletions
  1. 11 10
      ast.ml
  2. 1 1
      codegen.ml
  3. 4 4
      genas3.ml
  4. 1 1
      gencs.ml
  5. 1 1
      genjava.ml
  6. 10 10
      genswf.ml
  7. 22 22
      interp.ml
  8. 29 29
      main.ml
  9. 32 32
      matcher.ml
  10. 2 2
      parser.ml
  11. 39 39
      typeload.ml
  12. 12 12
      typer.ml

+ 11 - 10
ast.ml

@@ -625,16 +625,17 @@ let unescape s =
 					inext := !inext + 2;
 				| 'u' ->
 					let (u, a) =
-					  (try
-					      (int_of_string ("0x" ^ String.sub s (i+1) 4), 4)
-					    with
-					      _ -> try
-						assert (s.[i+1] = '{');
-						let l = String.index_from s (i+3) '}' - (i+2) in
-						let u = int_of_string ("0x" ^ String.sub s (i+2) l) in
-						assert (u <= 0x10FFFF);
-						(u, l+2)
-					      with _ -> raise Exit) in
+						try
+							(int_of_string ("0x" ^ String.sub s (i+1) 4), 4)
+						with _ -> try
+							assert (s.[i+1] = '{');
+							let l = String.index_from s (i+3) '}' - (i+2) in
+							let u = int_of_string ("0x" ^ String.sub s (i+2) l) in
+							assert (u <= 0x10FFFF);
+							(u, l+2)
+						with _ ->
+							raise Exit
+					in
 					let ub = UTF8.Buf.create 0 in
 					UTF8.Buf.add_char ub (UChar.uchar_of_int u);
 					Buffer.add_string b (UTF8.Buf.contents ub);

+ 1 - 1
codegen.ml

@@ -1576,7 +1576,7 @@ struct
 			List.iter (function
 				| (elist,TFun(args,ret)) -> (try
 					rated := ( (elist,TFun(args,ret)), mk_rate [] elist args ) :: !rated
-					with | Not_found ->  ())
+					with | Not_found -> ())
 				| _ -> assert false
 			) compatible;
 

+ 4 - 4
genas3.ml

@@ -607,7 +607,7 @@ and gen_expr ctx e =
 		gen_value ctx e;
 		print ctx ".params[%i]" i;
 	| TField (e,s) ->
-   		gen_value ctx e;
+		gen_value ctx e;
 		gen_field_access ctx e.etype (field_name s)
 	| TTypeExpr t ->
 		spr ctx (s_path ctx true (t_path t) e.epos)
@@ -652,7 +652,7 @@ and gen_expr ctx e =
 		end else begin
 			ctx.constructor_block <- false;
 			print ctx " if( !%s.skip_constructor ) {" (s_path ctx true (["flash"],"Boot") e.epos);
-            (fun() -> print ctx "}")
+			(fun() -> print ctx "}")
 		end) in
 		(match ctx.block_inits with None -> () | Some i -> i());
 		List.iter (fun e -> block_newline ctx; gen_expr ctx e) el;
@@ -959,8 +959,8 @@ let generate_field ctx static f =
 		| _ -> ()
 	) f.cf_meta;
 	let public = f.cf_public || Hashtbl.mem ctx.get_sets (f.cf_name,static) || (f.cf_name = "main" && static)
-	    || f.cf_name = "resolve" || Ast.Meta.has Ast.Meta.Public f.cf_meta
-	    (* consider all abstract methods public to avoid issues with inlined private access *)
+		|| f.cf_name = "resolve" || Ast.Meta.has Ast.Meta.Public f.cf_meta
+		(* consider all abstract methods public to avoid issues with inlined private access *)
 	    || (match ctx.curclass.cl_kind with KAbstractImpl _ -> true | _ -> false)
 	in
 	let rights = (if static then "static " else "") ^ (if public then "public" else "protected") in

+ 1 - 1
gencs.ml

@@ -2056,7 +2056,7 @@ let configure gen =
 
 		let rec loop meta =
 			match meta with
-				| [] ->  ()
+				| [] -> ()
 				| (Meta.ClassCode, [Ast.EConst (Ast.String contents),_],_) :: tl ->
 					write w contents
 				| _ :: tl -> loop tl

+ 1 - 1
genjava.ml

@@ -1746,7 +1746,7 @@ let configure gen =
 
 		let rec loop meta =
 			match meta with
-				| [] ->  ()
+				| [] -> ()
 				| (Meta.ClassCode, [Ast.EConst (Ast.String contents),_],_) :: tl ->
 					write w contents
 				| _ :: tl -> loop tl

+ 10 - 10
genswf.ml

@@ -134,7 +134,7 @@ let build_class com c file =
 		} in
 		(path.tpackage, [(ETypedef inf,pos)])
 	| _ ->
-  (* make flags *)
+	(* make flags *)
 	let flags = [HExtern] in
 	let flags = if c.hlc_interface then HInterface :: flags else flags in
 	let flags = (match c.hlc_super with
@@ -157,7 +157,7 @@ let build_class com c file =
 		if c.hlc_interface then HExtends (make_tpath i) else HImplements (make_tpath i)
 	) (Array.to_list c.hlc_implements) @ flags in
 	let flags = if c.hlc_sealed || Common.defined com Define.FlashStrict then flags else HImplements (make_tpath (HMPath ([],"Dynamic"))) :: flags in
-  (* make fields *)
+	(* make fields *)
 	let getters = Hashtbl.create 0 in
 	let setters = Hashtbl.create 0 in
 	let override = Hashtbl.create 0 in
@@ -1033,10 +1033,10 @@ let build_swf9 com file swc =
 	res @ bmp @ code @ clips
 
 let merge com file priority (h1,tags1) (h2,tags2) =
-  (* prioritize header+bgcolor for first swf *)
+	(* prioritize header+bgcolor for first swf *)
 	let header = if priority then { h2 with h_version = max h2.h_version (Common.flash_version_tag com.flash_version) } else h1 in
 	let tags1 = if priority then List.filter (function { tdata = TSetBgColor _ } -> false | _ -> true) tags1 else tags1 in
-  (* remove unused tags *)
+	(* remove unused tags *)
 	let use_stage = priority && Common.defined com Define.FlashUseStage in
 	let classes = ref [] in
 	let nframe = ref 0 in
@@ -1067,7 +1067,7 @@ let merge com file priority (h1,tags1) (h2,tags2) =
 			false
 		| _ -> true
 	) tags2 in
-  (* rebuild character ids *)
+(* rebuild character ids *)
 	let max_id = ref (-1) in
 	List.iter (SwfParser.scan (fun id -> if id > !max_id then max_id := id; id) (fun id -> id)) tags1;
 	incr max_id;
@@ -1079,7 +1079,7 @@ let merge com file priority (h1,tags1) (h2,tags2) =
 	in
 	List.iter loop tags2;
 	let classes = List.map (fun e -> match e.f9_cid with None -> e | Some id -> { e with f9_cid = Some (id + !max_id) }) !classes in
-  (* merge timelines *)
+	(* merge timelines *)
 	let rec loop l1 l2 =
 		match l1, l2 with
 		| ({ tdata = TSetBgColor _ } as t) :: l1, _
@@ -1112,7 +1112,7 @@ let generate com swf_header =
 	let swc = if Common.defined com Define.Swc then Some (ref "") else None in
 	if swc <> None && not isf9 then failwith "SWC support is only available for Flash9+";
 	let file , codeclip = (try let f , c = ExtString.String.split com.file "@" in f, Some c with _ -> com.file , None) in
-  (* list exports *)
+	(* list exports *)
 	let exports = Hashtbl.create 0 in
 	let toremove = ref [] in
 	List.iter (fun (file,lib,_) ->
@@ -1143,7 +1143,7 @@ let generate com swf_header =
 			| _ -> ()
 		) tags;
 	) com.swf_libs;
-  (* build haxe swf *)
+	(* build haxe swf *)
 	let tags = if isf9 then build_swf9 com file swc else build_swf8 com codeclip exports in
 	let header, bg = (match swf_header with None -> default_header com | Some h -> convert_header com h) in
 	let bg = tag (TSetBgColor { cr = bg lsr 16; cg = (bg lsr 8) land 0xFF; cb = bg land 0xFF }) in
@@ -1185,7 +1185,7 @@ let generate com swf_header =
 		[]
 	in
 	let swf = header, fattr @ meta_data @ bg :: debug @ swf_script_limits @ preframe @ tags @ [tag TShowFrame] in
-  (* merge swf libraries *)
+	(* merge swf libraries *)
 	let priority = ref (swf_header = None) in
 	let swf = List.fold_left (fun swf (file,lib,cl) ->
 		let swf = merge com file !priority swf (remove_classes toremove lib cl) in
@@ -1193,7 +1193,7 @@ let generate com swf_header =
 		swf
 	) swf com.swf_libs in
 	t();
-  (* write swf/swc *)
+	(* write swf/swc *)
 	let t = Common.timer "write swf" in
 	let level = (try int_of_string (Common.defined_value com Define.SwfCompressLevel) with Not_found -> 9) in
 	SwfParser.init Extc.input_zip (Extc.output_zip ~level);

+ 22 - 22
interp.ml

@@ -261,7 +261,7 @@ let constants =
 	let h = Hashtbl.create 0 in
 	List.iter (fun f -> Hashtbl.add h (hash f) f)
 	["done";"read";"write";"min";"max";"file";"args";"loadprim";"loadmodule";"__a";"__s";"h";
-    "tag";"index";"length";"message";"pack";"name";"params";"sub";"doc";"kind";"meta";"access";
+	"tag";"index";"length";"message";"pack";"name";"params";"sub";"doc";"kind";"meta";"access";
 	"constraints";"opt";"type";"value";"ret";"expr";"field";"values";"get";"__string";"toString";
 	"$";"add";"remove";"has";"__t";"module";"isPrivate";"isPublic";"isExtern";"isInterface";"exclude";
 	"constructs";"names";"superClass";"interfaces";"fields";"statics";"constructor";"init";"t";
@@ -1008,17 +1008,17 @@ let builtins =
 			| CInf -> VInt (-1)
 		);
 		"pcompare", Fun2 (fun a b ->
-	 		assert false
-	 	);
-	 	"excstack", Fun0 (fun() ->
+			assert false
+		);
+		"excstack", Fun0 (fun() ->
 			build_stack (get_ctx()).exc
-	 	);
-	 	"callstack", Fun0 (fun() ->
-	 		build_stack (List.map (fun s -> s.cpos) (get_ctx()).callstack)
-	 	);
-	 	"version", Fun0 (fun() ->
-	 		VInt 200
-	 	);
+		);
+		"callstack", Fun0 (fun() ->
+			build_stack (List.map (fun s -> s.cpos) (get_ctx()).callstack)
+		);
+		"version", Fun0 (fun() ->
+			VInt 200
+		);
 	(* extra *)
 		"use_neko_dll", Fun0 (fun() ->
 			VBool (neko <> None)
@@ -2070,16 +2070,16 @@ let z_lib =
 
 (* convert float value to haxe expression, handling inf/-inf/nan *)
 let haxe_float f p =
-    let std = (Ast.EConst (Ast.Ident "std"), p) in
-    let math = (Ast.EField (std, "Math"), p) in
-    if (f = infinity) then
-        (Ast.EField (math, "POSITIVE_INFINITY"), p)
-    else if (f = neg_infinity) then
-        (Ast.EField (math, "NEGATIVE_INFINITY"), p)
-    else if (f <> f) then
-        (Ast.EField (math, "NaN"), p)
-    else
-        (Ast.EConst (Ast.Float (float_repres f)), p)
+	let std = (Ast.EConst (Ast.Ident "std"), p) in
+	let math = (Ast.EField (std, "Math"), p) in
+	if (f = infinity) then
+		(Ast.EField (math, "POSITIVE_INFINITY"), p)
+	else if (f = neg_infinity) then
+		(Ast.EField (math, "NEGATIVE_INFINITY"), p)
+	else if (f <> f) then
+		(Ast.EField (math, "NaN"), p)
+	else
+		(Ast.EConst (Ast.Float (float_repres f)), p)
 
 let macro_lib =
 	let error() =
@@ -2418,7 +2418,7 @@ let macro_lib =
 				VNull
 			| _ -> error()
 		);
-        "get_resources", Fun0 (fun() ->
+		"get_resources", Fun0 (fun() ->
 			let res = (ccom()).resources in
 			let h = Hashtbl.create 0 in
 			Hashtbl.iter (fun n v -> Hashtbl.replace h (VString n) (VString v)) res;

+ 29 - 29
main.ml

@@ -173,7 +173,7 @@ let make_path f =
 		| ["hx";path] -> ExtString.String.nsplit path "/"
 		| _ -> cl
 	) in
- 	let error msg =
+	let error msg =
 		let msg = "Could not process argument " ^ f ^ "\n" ^ msg in
 		failwith msg
 	in
@@ -265,30 +265,30 @@ let rec read_type_path com p =
 			loop path p
 		) (extract());
 	) com.swf_libs;
-  List.iter (fun (path,std,close,all_files,lookup) ->
-    List.iter (fun (path, name) ->
-      if path = p then classes := name :: !classes else
-      let rec loop p1 p2 =
-        match p1, p2 with
-        | [], _ -> ()
-        | x :: _, [] -> packages := x :: !packages
-        | a :: p1, b :: p2 -> if a = b then loop p1 p2
-      in
-      loop path p
-    ) (all_files())
-  ) com.java_libs;
-  List.iter (fun (path,std,all_files,lookup) ->
-    List.iter (fun (path, name) ->
-      if path = p then classes := name :: !classes else
-      let rec loop p1 p2 =
-        match p1, p2 with
-        | [], _ -> ()
-        | x :: _, [] -> packages := x :: !packages
-        | a :: p1, b :: p2 -> if a = b then loop p1 p2
-      in
-      loop path p
-    ) (all_files())
-  ) com.net_libs;
+	List.iter (fun (path,std,close,all_files,lookup) ->
+		List.iter (fun (path, name) ->
+			if path = p then classes := name :: !classes else
+			let rec loop p1 p2 =
+				match p1, p2 with
+				| [], _ -> ()
+				| x :: _, [] -> packages := x :: !packages
+				| a :: p1, b :: p2 -> if a = b then loop p1 p2
+			in
+			loop path p
+		) (all_files())
+	) com.java_libs;
+	List.iter (fun (path,std,all_files,lookup) ->
+		List.iter (fun (path, name) ->
+			if path = p then classes := name :: !classes else
+			let rec loop p1 p2 =
+				match p1, p2 with
+				| [], _ -> ()
+				| x :: _, [] -> packages := x :: !packages
+				| a :: p1, b :: p2 -> if a = b then loop p1 p2
+			in
+		loop path p
+		) (all_files())
+	) com.net_libs;
 	unique !packages, unique !classes
 
 let delete_file f = try Sys.remove f with _ -> ()
@@ -999,7 +999,7 @@ try
 		("-cpp",Arg.String (fun dir ->
 			set_platform Cpp dir;
 		),"<directory> : generate C++ code into target directory");
- 		("-cs",Arg.String (fun dir ->
+		("-cs",Arg.String (fun dir ->
 			cp_libs := "hxcs" :: !cp_libs;
 			set_platform Cs dir;
 		),"<directory> : generate C# code into target directory");
@@ -1183,9 +1183,9 @@ try
 			com.php_front <- Some f;
 		),"<filename> : select the name for the php front file");
 		("--php-lib",Arg.String (fun f ->
- 			if com.php_lib <> None then raise (Arg.Bad "Multiple --php-lib");
- 			com.php_lib <- Some f;
- 		),"<filename> : select the name for the php lib folder");
+			if com.php_lib <> None then raise (Arg.Bad "Multiple --php-lib");
+			com.php_lib <- Some f;
+		),"<filename> : select the name for the php lib folder");
 		("--php-prefix", Arg.String (fun f ->
 			if com.php_prefix <> None then raise (Arg.Bad "Multiple --php-prefix");
 			com.php_prefix <- Some f;

+ 32 - 32
matcher.ml

@@ -141,8 +141,8 @@ let mk_out mctx id e eg is_catch_all p =
 	out
 
 let clone_out mctx out p =
- 	let out = {out with o_pos = p; } in
- 	mctx.outcomes <- out :: mctx.outcomes;
+	let out = {out with o_pos = p; } in
+	mctx.outcomes <- out :: mctx.outcomes;
 	out
 
 let get_guard mctx id =
@@ -458,7 +458,7 @@ let to_pattern ctx e t =
 					| TConst c | TCast({eexpr = TConst c},None) ->
 						begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end;
 						unify ctx ec.etype t p;
-                        mk_con_pat (CConst c) [] t p
+						mk_con_pat (CConst c) [] t p
 					| TTypeExpr mt ->
 						mk_type_pat ctx mt t p
 					| _ ->
@@ -634,7 +634,7 @@ let spec mctx con pmat =
 			loop2 (Array.append [|pat|] (array_tl pv)) out
 		| PTuple tl ->
 			loop2 tl out
- 		| POr _ ->
+		| POr _ ->
 			assert false
 	in
 	let rec loop pmat = match pmat with
@@ -661,10 +661,10 @@ let default mctx pmat =
 			loop2 (Array.append [|pat|] (array_tl pv)) out
 		| PTuple tl ->
 			loop2 tl out
- 		| POr _ ->
+		| POr _ ->
 			assert false
 	in
- 	let rec loop pmat = match pmat with
+	let rec loop pmat = match pmat with
 		| (pv,out) :: pl ->
 			loop2 pv out;
 			loop pl;
@@ -1280,9 +1280,9 @@ let match_expr ctx e cases def with_type p =
 	let check_unused () =
 		let unused p =
 			display_error ctx "This pattern is unused" p;
- 			let old_error = ctx.on_error in
+			let old_error = ctx.on_error in
 			ctx.on_error <- (fun ctx s p -> ctx.on_error <- old_error; raise Exit);
-	 		let check_expr e p =
+			let check_expr e p =
 				try begin match fst e with
 						| EConst(Ident ("null" | "true" | "false")) -> ()
 						| EConst(Ident _) ->
@@ -1302,10 +1302,10 @@ let match_expr ctx e cases def with_type p =
 			ctx.on_error <- old_error;
 		in
 		let had_catch_all = ref false in
- 		List.iter (fun out ->
- 			if out.o_catch_all && not !had_catch_all then
- 				had_catch_all := true
- 			else if out.o_num_paths = 0 then begin
+		List.iter (fun out ->
+			if out.o_catch_all && not !had_catch_all then
+				had_catch_all := true
+			else if out.o_num_paths = 0 then begin
 				unused out.o_pos;
 				if mctx.toplevel_or then begin match evals with
 					| [{etype = t}] when (match follow t with TAbstract({a_path=[],"Int"},[]) -> true | _ -> false) ->
@@ -1319,25 +1319,25 @@ let match_expr ctx e cases def with_type p =
 		(* compile decision tree *)
 		compile mctx stl pl true
 	with Not_exhaustive(pat,st) ->
- 		let rec s_st_r top pre st v = match st.st_def with
- 			| SVar v1 ->
- 				if not pre then v else begin try
- 					let e = match List.assoc v1 !var_inits with Some e -> e | None -> assert false in
- 					(Type.s_expr_pretty "" (Type.s_type (print_context())) e) ^ v
- 				with Not_found ->
- 					v1.v_name ^ v
- 				end
- 			| STuple(st,i,a) ->
- 				let r = a - i - 1 in
- 				Printf.sprintf "[%s]" (st_args i r (s_st_r top false st v))
- 			| SArray(st,i) ->
- 				s_st_r false true st (Printf.sprintf "[%i]%s" i (if top then " = " ^ v else v))
- 			| SField({st_def = SVar v1},f) when v1.v_name.[0] = '`' ->
- 				f ^ (if top then " = " ^ v else v)
-  			| SField(st,f) ->
- 				s_st_r false true st (Printf.sprintf ".%s%s" f (if top then " = " ^ v else v))
- 			| SEnum(st,ef,i) ->
- 				let len = match follow ef.ef_type with TFun(args,_) -> List.length args | _ -> 0 in
+		let rec s_st_r top pre st v = match st.st_def with
+			| SVar v1 ->
+				if not pre then v else begin try
+					let e = match List.assoc v1 !var_inits with Some e -> e | None -> assert false in
+					(Type.s_expr_pretty "" (Type.s_type (print_context())) e) ^ v
+				with Not_found ->
+					v1.v_name ^ v
+				end
+			| STuple(st,i,a) ->
+				let r = a - i - 1 in
+				Printf.sprintf "[%s]" (st_args i r (s_st_r top false st v))
+			| SArray(st,i) ->
+				s_st_r false true st (Printf.sprintf "[%i]%s" i (if top then " = " ^ v else v))
+			| SField({st_def = SVar v1},f) when v1.v_name.[0] = '`' ->
+				f ^ (if top then " = " ^ v else v)
+			| SField(st,f) ->
+				s_st_r false true st (Printf.sprintf ".%s%s" f (if top then " = " ^ v else v))
+			| SEnum(st,ef,i) ->
+				let len = match follow ef.ef_type with TFun(args,_) -> List.length args | _ -> 0 in
 				s_st_r false false st (Printf.sprintf "%s(%s)" ef.ef_name (st_args i (len - 1 - i) v))
 		in
 		let pat = match follow st.st_type with
@@ -1407,7 +1407,7 @@ let match_expr ctx e cases def with_type p =
 				i + 1
 			end else i in
 			Array.set map c i;
-		 	loop i' (c + 1)
+			loop i' (c + 1)
 		end
 	in
 	loop 0 0;

+ 2 - 2
parser.ml

@@ -1067,7 +1067,7 @@ and block acc s =
 			let tk , pos = (match Stream.peek s with None -> last_token s | Some t -> t) in
 			(!display_error) (Unexpected tk) pos;
 			block acc s
-        | Error (e,p) ->
+		| Error (e,p) ->
 			(!display_error) e p;
 			block acc s
 
@@ -1222,7 +1222,7 @@ and expr = parser
 	| [< '(Dollar v,p); s >] -> expr_next (EConst (Ident ("$"^v)),p) s
 
 and expr_next e1 = parser
- 	| [< '(BrOpen,p1) when is_dollar_ident e1; eparam = expr; '(BrClose,p2); s >] ->
+	| [< '(BrOpen,p1) when is_dollar_ident e1; eparam = expr; '(BrClose,p2); s >] ->
 		(match fst e1 with
 		| EConst(Ident n) -> expr_next (EMeta((Common.MetaInfo.from_string n,[],snd e1),eparam), punion p1 p2) s
 		| _ -> assert false)

+ 39 - 39
typeload.ml

@@ -727,40 +727,40 @@ let copy_meta meta_src meta_target sl =
 	!meta
 
 let same_overload_args t1 t2 f1 f2 =
-  if List.length f1.cf_params <> List.length f2.cf_params then
-    false
-  else
-    let rec follow_skip_null t = match t with
-    | TMono r ->
-      (match !r with
-      | Some t -> follow_skip_null t
-      | _ -> t)
-    | TLazy f ->
-      follow_skip_null (!f())
-    | TType ({ t_path = [],"Null" } as t, [p]) ->
-      TType(t,[follow p])
-    | TType (t,tl) ->
-      follow_skip_null (apply_params t.t_types tl t.t_type)
-    | _ -> t
-    in
-    let same_arg t1 t2 =
-      let t1 = follow_skip_null t1 in
-      let t2 = follow_skip_null t2 in
-      match follow_skip_null t1, follow_skip_null t2 with
-      | TType _, TType _ -> type_iseq t1 t2
-      | TType _, _
-      | _, TType _ -> false
-      | _ -> type_iseq t1 t2
-    in
-
-    match follow (apply_params f1.cf_params (List.map (fun (_,t) -> t) f2.cf_params) t1), follow t2 with
-    | TFun(a1,_), TFun(a2,_) ->
-      (try
-        List.for_all2 (fun (_,_,t1) (_,_,t2) ->
-          same_arg t1 t2) a1 a2
-      with | Invalid_argument("List.for_all2") ->
-        false)
-    | _ -> assert false
+	if List.length f1.cf_params <> List.length f2.cf_params then
+		false
+	else
+	let rec follow_skip_null t = match t with
+		| TMono r ->
+			(match !r with
+			| Some t -> follow_skip_null t
+			| _ -> t)
+		| TLazy f ->
+			follow_skip_null (!f())
+		| TType ({ t_path = [],"Null" } as t, [p]) ->
+			TType(t,[follow p])
+		| TType (t,tl) ->
+			follow_skip_null (apply_params t.t_types tl t.t_type)
+		| _ -> t
+	in
+	let same_arg t1 t2 =
+	let t1 = follow_skip_null t1 in
+	let t2 = follow_skip_null t2 in
+	match follow_skip_null t1, follow_skip_null t2 with
+		| TType _, TType _ -> type_iseq t1 t2
+		| TType _, _
+		| _, TType _ -> false
+		| _ -> type_iseq t1 t2
+	in
+
+	match follow (apply_params f1.cf_params (List.map (fun (_,t) -> t) f2.cf_params) t1), follow t2 with
+		| TFun(a1,_), TFun(a2,_) ->
+			(try
+				List.for_all2 (fun (_,_,t1) (_,_,t2) ->
+				same_arg t1 t2) a1 a2
+			with | Invalid_argument("List.for_all2") ->
+				false)
+		| _ -> assert false
 
 (** retrieves all overloads from class c and field i, as (Type.t * tclass_field) list *)
 let rec get_overloads c i =
@@ -859,7 +859,7 @@ let check_overriding ctx c =
 						) overloads
 					) true
 				) f.cf_overloads
-      end else
+	  end else
 				check_field f (fun csup i ->
 					let _, t, f2 = raw_class_field (fun f -> f.cf_type) csup i in
 					t, f2) false
@@ -1530,7 +1530,7 @@ let build_enum_abstract ctx c a fields p =
 			end;
 			field.cff_access <- [AStatic;APublic;AInline];
 			field.cff_meta <- (Meta.Enum,[],field.cff_pos) :: (Meta.Impl,[],field.cff_pos) :: field.cff_meta;
- 			let e = match eo with
+			let e = match eo with
 				| None -> error "Value required" field.cff_pos
 				| Some e -> (ECast(e,None),field.cff_pos)
 			in
@@ -2195,9 +2195,9 @@ let init_class ctx c p context_init herits fields =
 					| None ->
 							c.cl_constructor <- Some f
 					| Some ctor when ctx.com.config.pf_overload ->
-              if Meta.has Meta.Overload f.cf_meta && Meta.has Meta.Overload ctor.cf_meta then
-  							ctor.cf_overloads <- f :: ctor.cf_overloads
-              else if Meta.has Meta.Overload f.cf_meta <> Meta.has Meta.Overload ctor.cf_meta then
+			  if Meta.has Meta.Overload f.cf_meta && Meta.has Meta.Overload ctor.cf_meta then
+							ctor.cf_overloads <- f :: ctor.cf_overloads
+			  else if Meta.has Meta.Overload f.cf_meta <> Meta.has Meta.Overload ctor.cf_meta then
 								display_error ctx ("If using overloaded constructors, all constructors must be declared with @:overload") (if Meta.has Meta.Overload f.cf_meta then ctor.cf_pos else f.cf_pos)
 					| Some ctor ->
 								display_error ctx "Duplicate constructor" p

+ 12 - 12
typer.ml

@@ -632,8 +632,8 @@ let is_forced_inline c cf =
 	| _ -> false
 
 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 *)
+	(* 'overloads' will carry a ( return_result ) list, called 'compatible' *)
+	(* it's used to correctly support an overload selection algorithm *)
 	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) ->
@@ -1142,7 +1142,7 @@ let rec using_field ctx mode e i p =
 					if is_dynamic && follow t0 != t_dynamic then raise Not_found;
 					Type.unify e.etype t0;
 					(* early constraints check is possible because e.etype has no monomorphs *)
-		 			List.iter2 (fun m (name,t) -> match follow t with
+					List.iter2 (fun m (name,t) -> match follow t with
 						| TInst ({ cl_kind = KTypeParameter constr },_) when constr <> [] && not (has_mono m) ->
 							List.iter (fun tc -> Type.unify m (map tc)) constr
 						| _ -> ()
@@ -1256,8 +1256,8 @@ let rec type_ident_raise ?(imported_enums=true) ctx i p mode =
 			| [] -> raise Not_found
 			| t :: l ->
 				match t with
- 				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
- 					begin try
+				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
+					begin try
 						let cf = PMap.find i c.cl_statics in
 						if not (Meta.has Meta.Enum cf.cf_meta) then
 							loop l
@@ -1451,7 +1451,7 @@ and type_field ?(resume=false) ctx e i p mode =
 		field_access ctx mode f (FAnon f) (Type.field_type f) e p
 	| TAbstract (a,pl) ->
 		(try
- 			let c = (match a.a_impl with None -> raise Not_found | Some c -> c) in
+			let c = (match a.a_impl with None -> raise Not_found | Some c -> c) in
 			let f = PMap.find i c.cl_statics in
 			if not (can_access ctx c f true) && not ctx.untyped then display_error ctx ("Cannot access private field " ^ i) p;
 			let field_type f =
@@ -1780,9 +1780,9 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
 				mk (TVar (v,Some e)) ctx.t.tvoid p;
 				make_call ctx (mk (TField (ev,quick_field_dynamic ev.etype ("set_" ^ cf.cf_name))) (tfun [t] t) p) [get] t p
 			]) t p
- 		| AKUsing(ef,c,cf,et) ->
- 			(* abstract setter + getter *)
- 			let ta = match c.cl_kind with KAbstractImpl a -> TAbstract(a, List.map (fun _ -> mk_mono()) a.a_types) | _ -> assert false in
+		| AKUsing(ef,c,cf,et) ->
+			(* abstract setter + getter *)
+			let ta = match c.cl_kind with KAbstractImpl a -> TAbstract(a, List.map (fun _ -> mk_mono()) a.a_types) | _ -> assert false in
 			let ret = match follow ef.etype with
 				| TFun([_;_],ret) -> ret
 				| _ ->  error "Invalid field type for abstract setter" p
@@ -2720,7 +2720,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 		type_expr ctx (format_string ctx s p) with_type
 	| EConst c ->
 		Codegen.type_constant ctx.com c p
-    | EBinop (op,e1,e2) ->
+	| EBinop (op,e1,e2) ->
 		type_binop ctx op e1 e2 false with_type p
 	| EBlock [] when with_type <> NoValue ->
 		type_expr ctx (EObjectDecl [],p) with_type
@@ -3881,7 +3881,7 @@ let generate ctx =
 			Hashtbl.replace states p Done;
 			types := t :: !types
 
-    and loop_class p c =
+	and loop_class p c =
 		if c.cl_path <> p then loop (TClassDecl c)
 
 	and loop_enum p e =
@@ -3932,7 +3932,7 @@ let generate ctx =
 		| _ ->
 			iter (walk_expr p) e
 
-    and walk_class p c =
+	and walk_class p c =
 		(match c.cl_super with None -> () | Some (c,_) -> loop_class p c);
 		List.iter (fun (c,_) -> loop_class p c) c.cl_implements;
 		(match c.cl_init with