소스 검색

delayed type param contraint checking

Nicolas Cannasse 17 년 전
부모
커밋
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
 	check that local variables get correctly initialized before usage
 	haxe.Stack support for flash9
 	haxe.Stack support for flash9
 	fixed current package bug in inherited constructor type
 	fixed current package bug in inherited constructor type
+	delayed type-parameter constraints check (allow mutual rec extends for SPOD)
 
 
 2008-04-05: 1.19
 2008-04-05: 1.19
 	fixed flash9 Array.toString
 	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 params = List.map2 (fun t (name,t2) ->
 				let isconst = (match t with TInst ({ cl_kind = KConstant _ },_) -> true | _ -> false) in
 				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;
 				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,[]) ->
 				| 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
 			) tparams types in
 			f params
 			f params
 		end
 		end