Browse Source

respect visibility of abstract fields, but default to public

Simon Krajewski 12 years ago
parent
commit
8b4da2b742
2 changed files with 2 additions and 1 deletions
  1. 1 1
      typeload.ml
  2. 1 0
      typer.ml

+ 1 - 1
typeload.ml

@@ -1419,7 +1419,7 @@ let init_class ctx c p context_init herits fields =
 			true
 			true
 		else match parent with
 		else match parent with
 			| Some { cf_public = p } -> p
 			| Some { cf_public = p } -> p
-			| _ -> c.cl_extern || c.cl_interface || extends_public
+			| _ -> c.cl_extern || c.cl_interface || extends_public || (match c.cl_kind with KAbstractImpl _ -> true | _ -> false)
 	in
 	in
 	let rec get_parent c name =
 	let rec get_parent c name =
 		match c.cl_super with
 		match c.cl_super with

+ 1 - 0
typer.ml

@@ -1257,6 +1257,7 @@ and type_field ctx e i p mode =
 		(try
 		(try
  			let c = (match a.a_impl with None -> raise Not_found | Some c -> c) in
  			let c = (match a.a_impl with None -> raise Not_found | Some c -> c) in
 			let f = PMap.find i c.cl_statics in
 			let f = PMap.find i c.cl_statics in
+			if not (can_access ctx c f false) && not ctx.untyped then display_error ctx ("Cannot access private field " ^ i) p;
 			let field_type f =
 			let field_type f =
 				let t = field_type ctx c [] f p in
 				let t = field_type ctx c [] f p in
 				apply_params a.a_types pl t
 				apply_params a.a_types pl t