Explorar o código

use generic base classes when resolving @:access checks (closes #3005)

Simon Krajewski %!s(int64=11) %!d(string=hai) anos
pai
achega
a8b81f24a9
Modificáronse 2 ficheiros con 29 adicións e 0 borrados
  1. 25 0
      tests/unit/issues/Issue3005.hx
  2. 4 0
      typer.ml

+ 25 - 0
tests/unit/issues/Issue3005.hx

@@ -0,0 +1,25 @@
+package unit.issues;
+
+@:generic
+private class A<T> {
+    public function new() {}
+    private function foo() {
+		var b = new B<String>();
+		b.foo();
+	}
+}
+
+@:generic
+private class B<T> {
+	public function new() {}
+	@:allow(unit.issues.A)
+	private function foo() {}
+}
+
+class Issue3005 extends Test {
+	@:access(unit.issues.A)
+	function test() {
+        var a = new A<String>();
+        a.foo();
+	}
+}

+ 4 - 0
typer.ml

@@ -237,6 +237,10 @@ let class_field ctx c pl name p =
 
 (* checks if we can access to a given class field using current context *)
 let rec can_access ctx ?(in_overload=false) c cf stat =
+	let c = match c.cl_kind with
+		| KGenericInstance(c,_) -> c
+		| _ -> c
+	in
 	if cf.cf_public then
 		true
 	else if not in_overload && ctx.com.config.pf_overload && Meta.has Meta.Overload cf.cf_meta then