Przeglądaj źródła

[display] do not generate property accessor calls if we are displaying the property (closes #6422)

Simon Krajewski 8 lat temu
rodzic
commit
253598b07a
2 zmienionych plików z 20 dodań i 0 usunięć
  1. 2 0
      src/typing/typer.ml
  2. 18 0
      tests/display/src/cases/Issue6422.hx

+ 2 - 0
src/typing/typer.ml

@@ -1047,6 +1047,8 @@ let field_access ctx mode f fmode t e p =
 				AKExpr (mk (TField (e,FClosure (None,f))) t p)
 				AKExpr (mk (TField (e,FClosure (None,f))) t p)
 			else
 			else
 				normal()
 				normal()
+		| AccCall when ctx.in_display ->
+			normal()
 		| AccCall ->
 		| AccCall ->
 			let m = (match mode with MSet -> "set_" | _ -> "get_") ^ f.cf_name in
 			let m = (match mode with MSet -> "set_" | _ -> "get_") ^ f.cf_name in
 			let is_abstract_this_access () = match e.eexpr,ctx.curfun with
 			let is_abstract_this_access () = match e.eexpr,ctx.curfun with

+ 18 - 0
tests/display/src/cases/Issue6422.hx

@@ -0,0 +1,18 @@
+package cases;
+
+class Issue6422 extends DisplayTestCase {
+	/**
+	class Main {
+		static function main() {
+			pro{-1-}perty;
+		}
+
+		static {-2-}var property(get, set):Int;{-3-}
+		static function get_property() return 0;
+		static function set_property(i) return 0;
+	}
+	**/
+	function test() {
+		eq(range(2, 3), position(pos(1)));
+	}
+}