瀏覽代碼

fixed generic constraint (fixed issue #314)

Nicolas Cannasse 12 年之前
父節點
當前提交
a32b32c230
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      typeload.ml

+ 7 - 4
typeload.ml

@@ -226,11 +226,14 @@ let check_param_constraints ctx types t pl c p =
 	| _ ->
 	| _ ->
 		let ctl = (match c.cl_kind with KTypeParameter l -> l | _ -> []) in
 		let ctl = (match c.cl_kind with KTypeParameter l -> l | _ -> []) in
 		List.iter (fun ti ->
 		List.iter (fun ti ->
-			(*
-				what was that used for ?
-				let ti = try snd (List.find (fun (_,t) -> match follow t with TInst(i2,[]) -> i == i2 | _ -> false) types) with Not_found -> TInst (i,tl) in
-			*)
 			let ti = apply_params types pl ti in
 			let ti = apply_params types pl ti in
+			let ti = (match follow ti with
+				| TInst ({ cl_kind = KGeneric }as c,pl) ->
+					(* if we solve a generic contraint, let's substitute with the actual generic instance before unifying *)
+					let _,_, f = ctx.g.do_build_instance ctx (TClassDecl c) p in
+					f pl
+				| _ -> ti
+			) in
 			unify ctx t ti p
 			unify ctx t ti p
 		) ctl
 		) ctl