فهرست منبع

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)
 	as3 : fixed Date.toString issue in flash.Boot (now use .toStringHX instead)
 		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
 	js : added js.Scroll

+ 5 - 1
typer.ml

@@ -378,6 +378,7 @@ let using_field ctx mode e i p =
 				(match follow t with
 				| TFun ((_,_,t0) :: args,r) ->
 					(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						
 					AccUsing (mk (TField (et,i)) t p,e)
 				| _ -> raise Not_found)
@@ -1500,7 +1501,10 @@ and type_expr ctx ?(need_val=true) (e,p) =
 						match follow (field_type f) with
 						| 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
-							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
 				| _ -> ());