Răsfoiți Sursa

[display] check field display on extern function fields (closes #6442)

Simon Krajewski 8 ani în urmă
părinte
comite
99ab0e61d5
2 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 2 1
      src/typing/typeload.ml
  2. 13 0
      tests/display/src/cases/Issue6442.hx

+ 2 - 1
src/typing/typeload.ml

@@ -2586,7 +2586,8 @@ module ClassInitializer = struct
 			end;
 			t
 		) "type_fun" in
-		if fctx.do_bind then bind_type (ctx,cctx,fctx) cf r (match fd.f_expr with Some e -> snd e | None -> f.cff_pos);
+		if fctx.do_bind then bind_type (ctx,cctx,fctx) cf r (match fd.f_expr with Some e -> snd e | None -> f.cff_pos)
+		else if fctx.is_display_field then Display.DisplayEmitter.maybe_display_field ctx (cf.cf_name_pos) cf;
 		cf
 
 	let create_property (ctx,cctx,fctx) c f (get,set,t,eo) p =

+ 13 - 0
tests/display/src/cases/Issue6442.hx

@@ -0,0 +1,13 @@
+package cases;
+
+class Issue6442 extends DisplayTestCase {
+	/**
+	extern class Foo {
+		{-1-}function b{-2-}ar():Void;{-3-}
+	}
+	**/
+	function test() {
+		eq(range(1, 3), position(pos(2)));
+		eq("Void -> Void", type(pos(2)));
+	}
+}