Ver código fonte

abstract field access is always static

Simon Krajewski 12 anos atrás
pai
commit
a8ffb364e1
2 arquivos alterados com 5 adições e 3 exclusões
  1. 2 2
      std/StdTypes.hx
  2. 3 1
      typer.ml

+ 2 - 2
std/StdTypes.hx

@@ -239,7 +239,7 @@ abstract UInt(Int) from Int {
 		return toFloat();
 		return toFloat();
 	}
 	}
 
 
-	@:to /*private*/ inline function toFloat():Float {
+	@:to private inline function toFloat():Float {
 		var int = toInt();
 		var int = toInt();
 		if (int < 0) {
 		if (int < 0) {
 			return 4294967296.0 + int;
 			return 4294967296.0 + int;
@@ -249,7 +249,7 @@ abstract UInt(Int) from Int {
 		}
 		}
 	}
 	}
 
 
-	@:to /*private*/ inline function toInt():Int {
+	@:to private inline function toInt():Int {
 		return this;
 		return this;
 	}
 	}
 
 

+ 3 - 1
typer.ml

@@ -226,6 +226,7 @@ let rec can_access ctx c cf stat =
 	if cf.cf_public then
 	if cf.cf_public then
 		true
 		true
 	else
 	else
+	(* TODO: should we add a c == ctx.curclass short check here? *)
 	(* has metadata path *)
 	(* has metadata path *)
 	let make_path c f = match c.cl_kind with
 	let make_path c f = match c.cl_kind with
 		| KAbstractImpl a -> fst a.a_path @ [snd a.a_path; f.cf_name]
 		| KAbstractImpl a -> fst a.a_path @ [snd a.a_path; f.cf_name]
@@ -284,6 +285,7 @@ let rec can_access ctx c cf stat =
 			List.exists (fun t -> match follow t with TInst(c,_) -> loop c | _ -> false) tl
 			List.exists (fun t -> match follow t with TInst(c,_) -> loop c | _ -> false) tl
 		| _ -> false)
 		| _ -> false)
 	|| (Meta.has Meta.PrivateAccess ctx.meta) in
 	|| (Meta.has Meta.PrivateAccess ctx.meta) in
+	(* TODO: find out what this does and move it to genas3 *)
 	if b && Common.defined ctx.com Common.Define.As3 && not (Meta.has Meta.Public cf.cf_meta) then cf.cf_meta <- (Meta.Public,[],cf.cf_pos) :: cf.cf_meta;
 	if b && Common.defined ctx.com Common.Define.As3 && not (Meta.has Meta.Public cf.cf_meta) then cf.cf_meta <- (Meta.Public,[],cf.cf_pos) :: cf.cf_meta;
 	b
 	b
 
 
@@ -1257,7 +1259,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;
+			if not (can_access ctx c f true) && 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