فهرست منبع

[cs/java] allow TMeta in InitFunction.ensure_simple_expr (closes #5507)

Dan Korostelev 9 سال پیش
والد
کامیت
801b89e23f
2فایلهای تغییر یافته به همراه16 افزوده شده و 1 حذف شده
  1. 1 1
      src/generators/gencommon.ml
  2. 15 0
      tests/unit/src/unit/issues/Issue5507.hx

+ 1 - 1
src/generators/gencommon.ml

@@ -1918,7 +1918,7 @@ struct
 	let ensure_simple_expr gen e =
 		let rec iter e = match e.eexpr with
 			| TConst _ | TLocal _ | TArray _ | TBinop _
-			| TField _ | TTypeExpr _ | TParenthesis _ | TCast _
+			| TField _ | TTypeExpr _ | TParenthesis _ | TCast _ | TMeta _
 			| TCall _ | TNew _ | TUnop _ ->
 				Type.iter iter e
 			| _ ->

+ 15 - 0
tests/unit/src/unit/issues/Issue5507.hx

@@ -0,0 +1,15 @@
+package unit.issues;
+
+private abstract S(String) to String {
+	@:from static inline function fromString(s:String):S return cast s.toUpperCase();
+}
+
+class Issue5507 extends unit.Test {
+	#if (cs || java)
+	@:readOnly static var a(default,never):S = "hello";
+
+	function test() {
+		eq("HELLO", a);
+	}
+	#end
+}