浏览代码

[neko] use `tf_args` instead of TFun to determine constructor argument names (closes #3008)

Simon Krajewski 11 年之前
父节点
当前提交
cbdafc5aba
共有 3 个文件被更改,包括 17 次插入3 次删除
  1. 3 3
      genneko.ml
  2. 8 0
      tests/unit/issues/Issue3008.hx
  3. 6 0
      tests/unit/issues/misc/Issue3008Class.hx

+ 3 - 3
genneko.ml

@@ -422,9 +422,9 @@ let gen_class ctx c =
 	let stpath = gen_type_path p c.cl_path in
 	let fnew = (match c.cl_constructor with
 	| Some f ->
-		(match follow f.cf_type with
-		| TFun (args,_) ->
-			let params = List.map (fun (n,_,_) -> n) args in
+		(match f.cf_expr with
+		| Some {eexpr = TFunction tf} ->
+			let params = List.map (fun (v,_) -> v.v_name) tf.tf_args in
 			gen_method ctx p f ["new",(EFunction (params,(EBlock [
 				(EVars ["@o",Some (call p (builtin p "new") [null p])],p);
 				(call p (builtin p "objsetproto") [ident p "@o"; clpath]);

+ 8 - 0
tests/unit/issues/Issue3008.hx

@@ -0,0 +1,8 @@
+package unit.issues;
+
+class Issue3008 extends Test {
+	function test() {
+		var t = new unit.issues.misc.Issue3008Class("foo");
+        t.call();
+	}
+}

+ 6 - 0
tests/unit/issues/misc/Issue3008Class.hx

@@ -0,0 +1,6 @@
+package unit.issues.misc;
+
+class Issue3008Class {
+    public function new(unit:String) { }
+    public function call() { }
+}