@@ -203,4 +203,21 @@ abstract MyReflect({}) from {} {
Reflect.setField(this, key, value);
return value;
}
+}
+
+abstract MyAbstractClosure(String){
+ public function new(value:String) {
+ this = value;
+ }
+ public function test() {
+ var fn = function(){
+ return this;
+ return fn;
+ public inline function setVal(v) {
+ this = v;
@@ -842,4 +842,13 @@ class TestType extends Test {
mr["101"] = function n(x) return 9 + x;
eq(mr["101"](1), 10);
+ function testAbstractClosure() {
+ var s = new unit.MyAbstract.MyAbstractClosure("foo");
+ var func1 = s.test();
+ eq(func1(), "foo");
+ s.setVal("bar");
+ eq(s.test()(), "bar");
@@ -794,7 +794,8 @@ let get_this ctx p =
| FunMemberLocal ->
let v = (match ctx.vthis with
| None ->
- let v = gen_local ctx ctx.tthis in
+ (* we might be in a closure of an abstract member, so check for local "this" first *)
+ let v = try PMap.find "this" ctx.locals with Not_found -> gen_local ctx ctx.tthis in
ctx.vthis <- Some v;
v
| Some v ->