diff --git a/src/typing/operators.ml b/src/typing/operators.ml index ce9f3cf5f2e..29a8c4f5c5b 100644 --- a/src/typing/operators.ml +++ b/src/typing/operators.ml @@ -599,7 +599,13 @@ let type_assign ctx e1 e2 with_type p = assign_to e1 | AKAccessor fa -> let c,stat = match fa.fa_host with - | FHInstance(c,tl) -> Some c,false + | FHInstance(c,tl) -> + (* c refers to the host of the field, let's find the class we're actually accessing on *) + let c = match follow fa.fa_on.etype with + | TInst(c,_) -> c + | _ -> c + in + Some c,false | FHStatic c -> Some c,true | FHAbstract(a,tl,c) -> Some c,true | _ -> None,false diff --git a/tests/unit/src/unit/issues/Issue12259.hx b/tests/unit/src/unit/issues/Issue12259.hx index ba53df8d130..d221d0a5b66 100644 --- a/tests/unit/src/unit/issues/Issue12259.hx +++ b/tests/unit/src/unit/issues/Issue12259.hx @@ -5,6 +5,8 @@ import unit.issues.misc.issue12259.Element; @:access(unit.issues.misc.issue12259.Element) class Issue12259 extends unit.Test { public function test() { - eq(true, new Element().foo); + var elt = new Element(); + eq(true, elt.foo); + eq(true, elt.foo = false); } } diff --git a/tests/unit/src/unit/issues/misc/issue12259/Entity.hx b/tests/unit/src/unit/issues/misc/issue12259/Entity.hx index 17a232f291a..80d2d985d87 100644 --- a/tests/unit/src/unit/issues/misc/issue12259/Entity.hx +++ b/tests/unit/src/unit/issues/misc/issue12259/Entity.hx @@ -3,8 +3,11 @@ package unit.issues.misc.issue12259; class Entity { function new() {} - var foo(get, never):Bool; + var foo(get, set):Bool; function get_foo():Bool return true; + + function set_foo(b : Bool):Bool + return true; }