Browse Source

ignore visibility for abstract OpAssignOp operations (closes #2810)

Simon Krajewski 11 years ago
parent
commit
72055597cd
2 changed files with 25 additions and 0 deletions
  1. 24 0
      tests/unit/issues/Issue2810.hx
  2. 1 0
      typer.ml

+ 24 - 0
tests/unit/issues/Issue2810.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+import unit.Test;
+
+private abstract A(Array<Int>) {
+    public inline function new(a) {
+        this = a;
+    }
+    @:arrayAccess inline function read(i) {
+        return this[i];
+    }
+    @:arrayAccess inline function write(i,v) {
+        return this[i] = v;
+    }
+}
+
+class Issue2810 extends Test {
+	function test() {
+        var a = new A([5]);
+        var x = a[0];
+        a[0] = 6;
+        a[0] += 3;
+		eq(9, a[0]);
+	}
+}

+ 1 - 0
typer.ml

@@ -1582,6 +1582,7 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 					e, fun () -> (save(); Some (mk (TVar (v,Some ekey)) ctx.t.tvoid p))
 			in
 			let ast_call = ECall((EField(Interp.make_ast ebase,cf_get.cf_name),p),[Interp.make_ast ekey]),p in
+			let ast_call = (EMeta((Meta.PrivateAccess,[],pos ast_call),ast_call),pos ast_call) in
 			let eget = type_binop ctx op ast_call e2 true p in
 			unify ctx eget.etype r_get p;
 			let cf_set,tf_set,r_set =