ソースを参照

only allow "using" on Dynamic if first parameter is Dynamic

Nicolas Cannasse 15 年 前
コミット
e42564fed6
2 ファイル変更6 行追加1 行削除
  1. 1 0
      doc/CHANGES.txt
  2. 5 1
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -35,6 +35,7 @@
 	flash9 : added flash.desktop.Clipboard* classes (added in flash10)
 	flash9 : added flash.desktop.Clipboard* classes (added in flash10)
 	as3 : fixed Date.toString issue in flash.Boot (now use .toStringHX instead)
 	as3 : fixed Date.toString issue in flash.Boot (now use .toStringHX instead)
 		this will only work if .toString called explicitely on Date class
 		this will only work if .toString called explicitely on Date class
+	all : only allow "using" on Dynamic if first parameter is Dynamic
 	
 	
 2010-01-09: 2.05
 2010-01-09: 2.05
 	js : added js.Scroll
 	js : added js.Scroll

+ 5 - 1
typer.ml

@@ -378,6 +378,7 @@ let using_field ctx mode e i p =
 				(match follow t with
 				(match follow t with
 				| TFun ((_,_,t0) :: args,r) ->
 				| TFun ((_,_,t0) :: args,r) ->
 					(try unify_raise ctx e.etype t0 p with Error (Unify _,_) -> raise Not_found);
 					(try unify_raise ctx e.etype t0 p with Error (Unify _,_) -> raise Not_found);
+					if follow e.etype == t_dynamic && follow t0 != t_dynamic then raise Not_found;
 					let et = type_module_type ctx (TClassDecl c) None p in						
 					let et = type_module_type ctx (TClassDecl c) None p in						
 					AccUsing (mk (TField (et,i)) t p,e)
 					AccUsing (mk (TField (et,i)) t p,e)
 				| _ -> raise Not_found)
 				| _ -> raise Not_found)
@@ -1500,7 +1501,10 @@ and type_expr ctx ?(need_val=true) (e,p) =
 						match follow (field_type f) with
 						match follow (field_type f) with
 						| TFun ((_,_,t) :: args, ret) when (try unify_raise ctx (dup e.etype) t e.epos; true with _ -> false) ->
 						| TFun ((_,_,t) :: args, ret) when (try unify_raise ctx (dup e.etype) t e.epos; true with _ -> false) ->
 							let f = { f with cf_type = TFun (args,ret); cf_params = [] } in
 							let f = { f with cf_type = TFun (args,ret); cf_params = [] } in
-							acc := PMap.add f.cf_name f (!acc)
+							if follow e.etype == t_dynamic && follow t != t_dynamic then
+								()
+							else
+								acc := PMap.add f.cf_name f (!acc)
 						| _ -> ()
 						| _ -> ()
 					) c.cl_ordered_statics
 					) c.cl_ordered_statics
 				| _ -> ());
 				| _ -> ());