2
0
Эх сурвалжийг харах

delayed type param contraint checking

Nicolas Cannasse 17 жил өмнө
parent
commit
fa68345e38
2 өөрчлөгдсөн 14 нэмэгдсэн , 6 устгасан
  1. 1 0
      doc/CHANGES.txt
  2. 13 6
      typeload.ml

+ 1 - 0
doc/CHANGES.txt

@@ -53,6 +53,7 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	check that local variables get correctly initialized before usage
 	haxe.Stack support for flash9
 	fixed current package bug in inherited constructor type
+	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
 
 2008-04-05: 1.19
 	fixed flash9 Array.toString

+ 13 - 6
typeload.ml

@@ -135,13 +135,20 @@ let rec load_normal_type ctx t p allow_no_params =
 			let params = List.map2 (fun t (name,t2) ->
 				let isconst = (match t with TInst ({ cl_kind = KConstant _ },_) -> true | _ -> false) in
 				if isconst <> (name = "Const") && t != t_dynamic then error (if isconst then "Constant value unexpected here" else "Constant value excepted as type parameter") p;
-				(match follow t2 with
+				match follow t2 with
+				| TInst ({ cl_implements = [] }, []) ->
+					t
 				| TInst (c,[]) ->
-					List.iter (fun (i,params) ->
-						unify ctx t (apply_params types tparams (TInst (i,params))) p
-					) c.cl_implements
-				| _ -> assert false);
-				t
+					let r = exc_protect (fun r ->
+						r := (fun() -> t);
+						List.iter (fun (i,params) ->
+							unify ctx t (apply_params types tparams (TInst (i,params))) p
+						) c.cl_implements;
+						t
+					) in
+					ctx.delays := [(fun () -> ignore(!r()))] :: !(ctx.delays);
+					TLazy r
+				| _ -> assert false				
 			) tparams types in
 			f params
 		end