瀏覽代碼

[lua] fix another func to field issue for #6298

Justin Donaldson 8 年之前
父節點
當前提交
824c0f543e
共有 2 個文件被更改,包括 35 次插入0 次删除
  1. 7 0
      src/generators/genlua.ml
  2. 28 0
      tests/unit/src/unit/issues/Issue6298.hx

+ 7 - 0
src/generators/genlua.ml

@@ -1190,6 +1190,13 @@ and gen_tbinop ctx op e1 e2 =
 		gen_value ctx e1;
 		spr ctx " = ";
 		gen_value ctx e3;
+	    | TField(e3, FInstance _ ), TField(e4, FStatic _ )  ->
+		gen_value ctx e1;
+		print ctx " %s " (Ast.s_binop op);
+		add_feature ctx "use._hx_funcToField";
+		spr ctx "_hx_funcToField(";
+		gen_value ctx e2;
+		spr ctx ")";
 	    | TField(e3, FInstance _ ), TField(e4, FClosure _ )  ->
 		gen_value ctx e1;
 		print ctx " %s " (Ast.s_binop op);

+ 28 - 0
tests/unit/src/unit/issues/Issue6298.hx

@@ -0,0 +1,28 @@
+package unit.issues;
+class Issue6298 extends unit.Test {
+	public function test(){
+		var tst = new Some ();
+		var ddd = "SOME";
+		eq (tst.testCall (ddd), ddd);
+	}
+}
+
+class Test {
+	public static function good (s : String) : String {
+		trace (s);
+		return s;
+	}
+}
+
+class Some {
+	var call : String -> String;
+
+	public function new () {
+		call = Test.good;
+	}
+
+	public function testCall (s : String) : String {
+		return call (s);
+	}
+}
+