Forráskód Böngészése

allow "using" on typedefs

Nicolas Cannasse 15 éve
szülő
commit
d8e06d5cfe
2 módosított fájl, 12 hozzáadás és 2 törlés
  1. 1 0
      doc/CHANGES.txt
  2. 11 2
      typeload.ml

+ 1 - 0
doc/CHANGES.txt

@@ -3,6 +3,7 @@
 	js : add Document.createTextNode
 	all : bugfix with inline when modifying var with same name as one of current local
 	flash9 : classes implementing ArrayAccess<T> are now dynamic (including TypedDictionary)
+	all : allow "using" on typedefs
 
 2010-01-09: 2.05
 	js : added js.Scroll

+ 11 - 2
typeload.ml

@@ -824,6 +824,15 @@ let init_class ctx c p herits fields =
 	if not c.cl_extern then ignore(define_constructor ctx c);
 	fl
 
+let resolve_typedef ctx t =
+	match t with
+	| TClassDecl _ | TEnumDecl _ -> t
+	| TTypeDecl td ->
+		match follow td.t_type with
+		| TEnum (e,_) -> TEnumDecl e
+		| TInst (c,_) -> TClassDecl c
+		| _ -> t
+
 let type_module ctx m tdecls loadp =
 	(* PASS 1 : build module structure - does not load any module or type - should be atomic ! *)
 	let decls = ref [] in
@@ -960,10 +969,10 @@ let type_module ctx m tdecls loadp =
 			| None ->
 				let md = ctx.api.load_module (t.tpackage,t.tname) p in
 				let types = List.filter (fun t -> not (t_private t)) md.mtypes in
-				ctx.local_using <- ctx.local_using @ types;
+				ctx.local_using <- ctx.local_using @ (List.map (resolve_typedef ctx) types);
 			| Some _ ->
 				let t = load_type_def ctx p t in
-				ctx.local_using<- ctx.local_using @ [t])
+				ctx.local_using<- ctx.local_using @ [resolve_typedef ctx t])
 		| EClass d ->
 			let c = get_class d.d_name in
 			delays := !delays @ check_overriding ctx c p :: check_interfaces ctx c p :: init_class ctx c p d.d_flags d.d_data