Browse Source

remove abstract inline closure restriction (closes #4165)

Simon Krajewski 10 years ago
parent
commit
f6cd97bed1
2 changed files with 24 additions and 4 deletions
  1. 24 0
      tests/unit/src/unit/issues/Issue2767.hx
  2. 0 4
      typer.ml

+ 24 - 0
tests/unit/src/unit/issues/Issue2767.hx

@@ -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());
+	}
+}

+ 0 - 4
typer.ml

@@ -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) *)