Skip to content

Commit

Permalink
remove abstract inline closure restriction (closes #4165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn authored and nadako committed May 13, 2015
1 parent 25cb28e commit f6cd97b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 24 additions & 0 deletions tests/unit/src/unit/issues/Issue2767.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package unit.issues;

private abstract A(Array<Int>) {
public function new() {
this = [];
}

public inline function add(i : Int) : Void {
this.push(i);
}

public function get() {
return this.pop();
}
}

class Issue2767 extends Test {
function test() {
var a = new A();
var f = a.add;
f(12);
eq(12, a.get());
}
}
4 changes: 0 additions & 4 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,6 @@ let rec acc_get ctx g p =
(* build a closure with first parameter applied *)
(match follow et.etype with
| TFun (_ :: args,ret) ->
begin match follow e.etype,cf.cf_kind with
| TAbstract _,Method MethInline -> error "Cannot create closure on abstract inline method" e.epos
| _ -> ()
end;
let tcallb = TFun (args,ret) in
let twrap = TFun ([("_e",false,e.etype)],tcallb) in
(* arguments might not have names in case of variable fields of function types, so we generate one (issue #2495) *)
Expand Down

0 comments on commit f6cd97b

Please sign in to comment.