Browse Source

support comma-separated type paths in @:allow and @:access (closes #3390)

Dan Korostelev 11 years ago
parent
commit
19c9e90ef0
2 changed files with 25 additions and 3 deletions
  1. 19 0
      tests/unit/issues/Issue3390.hx
  2. 6 3
      typer.ml

+ 19 - 0
tests/unit/issues/Issue3390.hx

@@ -0,0 +1,19 @@
+package unit.issues;
+
+private class A {
+    static function a() Issue3390.privMethod;
+}
+
+private class B {
+    static function b() Issue3390.privMethod;
+}
+
+@:access(unit.issues.A, unit.issues.B)
+@:allow(unit.issues.A, unit.issues.B)
+class Issue3390 extends Test {
+    static function privMethod() {}
+    function test() {
+        A.a;
+        B.b;
+    }
+}

+ 6 - 3
typer.ml

@@ -271,9 +271,12 @@ let rec can_access ctx ?(in_overload=false) c cf stat =
 	in
 	in
 	let has m c f path =
 	let has m c f path =
 		let rec loop = function
 		let rec loop = function
-			| (m2,[e],_) :: l when m = m2 ->
-				let p = expr_path [] e in
-				(p <> [] && chk_path p path) || loop l
+			| (m2,el,_) :: l when m = m2 ->
+				List.exists (fun e ->
+					let p = expr_path [] e in
+					(p <> [] && chk_path p path)
+				) el
+				|| loop l
 			| _ :: l -> loop l
 			| _ :: l -> loop l
 			| [] -> false
 			| [] -> false
 		in
 		in