Browse Source

fixed recursive inline

Nicolas Cannasse 17 years ago
parent
commit
d803502369
2 changed files with 8 additions and 3 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 7 3
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -4,6 +4,7 @@
 	added haxe.rtti.Generic behavior
 	added haxe.FastList
 	bugfix to prevent recursive anonymous
+	fixed some incorrectly reported "recursive inline" errors
 	TODO haxe/f9 : inline code can give bad file in debug infos
 	TODO haxe/f9 var x = if( true ) Math.POSITIVE_INFINITY : 0.; VerifyError
 

+ 7 - 3
typer.ml

@@ -979,13 +979,12 @@ let type_type ctx tpath p =
 	let rec loop t tparams =
 	match t with
 	| TClassDecl c ->
-		let pub = is_parent c ctx.curclass in
 		let t_tmp = {
 			t_path = fst c.cl_path, "#" ^ snd c.cl_path;
 			t_doc = None;
 			t_pos = c.cl_pos;
 			t_type = TAnon {
-				a_fields = if pub then PMap.map (fun f -> { f with cf_public = true }) c.cl_statics else c.cl_statics;
+				a_fields = c.cl_statics;
 				a_status = ref (Statics c);
 			};
 			t_private = true;
@@ -1231,7 +1230,12 @@ let type_field ctx e i p get =
 	| TAnon a ->
 		(try
 			let f = PMap.find i a.a_fields in
-			if !(a.a_status) <> Closed && not f.cf_public && not ctx.untyped then display_error ctx ("Cannot access to private field " ^ i) p;
+			if not f.cf_public && not ctx.untyped then begin
+				match !(a.a_status) with
+				| Closed -> () (* always allow anon private fields access *)
+				| Statics c when is_parent c ctx.curclass -> ()
+				| _ -> display_error ctx ("Cannot access to private field " ^ i) p
+			end;
 			field_access ctx get f (field_type f) e p
 		with Not_found ->
 			if is_closed a then