Browse Source

[typer] clean up a bit

Simon Krajewski 5 years ago
parent
commit
4e338b6767
1 changed files with 10 additions and 21 deletions
  1. 10 21
      src/core/tUnification.ml

+ 10 - 21
src/core/tUnification.ml

@@ -173,33 +173,22 @@ module Monomorph = struct
 	let unbind m =
 	let unbind m =
 		m.tm_type <- None
 		m.tm_type <- None
 
 
-	let check_constraints map params tl =
-		List.iter2 (fun (_,t) tm ->
+	let spawn_constrained_monos map params =
+		let checks = DynArray.create () in
+		let monos = List.map (fun (s,t) ->
+			let mono = create() in
 			begin match follow t with
 			begin match follow t with
-			| TInst ({ cl_kind = KTypeParameter constr; cl_path = path; cl_name_pos = p; },_) ->
-				if constr <> [] then begin match tm with
-				| TMono mono ->
-					List.iter (fun t -> constrain_to_type mono (Some (s_type_path path)) (map t)) constr
+				| TInst ({ cl_kind = KTypeParameter constr; cl_path = path },_) when constr <> [] ->
+					DynArray.add checks (mono,constr,s_type_path path)
 				| _ ->
 				| _ ->
-					let tm = map tm in
-					check_constraint (s_type_path path) (fun () ->
-						List.iter (fun t ->
-							!unify_ref default_unification_context tm (map t)
-						) constr
-					)
-				end
-			| _ ->
-				assert false
+					()
 			end;
 			end;
-		) params tl
-
-	let spawn_constrained_monos map params =
-		let monos = List.map (fun (s,_) ->
-			let mono = create() in
 			TMono mono
 			TMono mono
 		) params in
 		) params in
 		let map t = map (apply_params params monos t) in
 		let map t = map (apply_params params monos t) in
-		check_constraints map params monos;
+		DynArray.iter (fun (mono,constr,path) ->
+			List.iter (fun t -> constrain_to_type mono (Some path) (map t)) constr
+		) checks;
 		monos
 		monos
 
 
 end
 end