浏览代码

[display] better quick fix

closes #8420
Simon Krajewski 6 年之前
父节点
当前提交
c23faafd6f
共有 2 个文件被更改,包括 22 次插入9 次删除
  1. 6 9
      src/typing/typeloadFields.ml
  2. 16 0
      tests/display/src/cases/Issue8420.hx

+ 6 - 9
src/typing/typeloadFields.ml

@@ -1492,15 +1492,12 @@ let init_class ctx c p context_init herits fields =
 	let has_struct_init = Meta.has Meta.StructInit c.cl_meta in
 	if has_struct_init then
 		ensure_struct_init_constructor ctx c fields p;
-	begin
-		if ctx.com.display.dms_error_policy = EPShow then (
-			match cctx.uninitialized_final with
-			| Some pf when c.cl_constructor = None ->
-				display_error ctx "This class has uninitialized final vars, which requires a constructor" p;
-				error "Example of an uninitialized final var" pf
-			| _ ->
-				()
-		)
+	begin match cctx.uninitialized_final with
+		| Some pf when c.cl_constructor = None ->
+			display_error ctx "This class has uninitialized final vars, which requires a constructor" p;
+			display_error ctx "Example of an uninitialized final var" pf;
+		| _ ->
+			()
 	end;
 	if not has_struct_init then
 		(* add_constructor does not deal with overloads correctly *)

+ 16 - 0
tests/display/src/cases/Issue8420.hx

@@ -0,0 +1,16 @@
+package cases;
+
+class Issue8420 extends DisplayTestCase {
+	/**
+		class A {
+			final x:Int;
+
+			function f() {
+				this.{-1-}
+			}
+		}
+	**/
+	function test() {
+		eq(true, hasField(fields(pos(1)), "x", "Int"));
+	}
+}