瀏覽代碼

[display] private abstract ctor in completion inside the abstract
fixes #8789

Aleksandr Kuzmenko 5 年之前
父節點
當前提交
6ede8bb1be
共有 2 個文件被更改,包括 35 次插入10 次删除
  1. 16 10
      src/typing/typerDisplay.ml
  2. 19 0
      tests/display/src/cases/Issue8789.hx

+ 16 - 10
src/typing/typerDisplay.ml

@@ -541,16 +541,22 @@ let handle_display ?resume_typing ctx e_ast dk with_type =
 				| Yes -> true
 				| YesButPrivate ->
 					if (Meta.has Meta.PrivateAccess ctx.meta) then true
-					else begin
-						let path = (mt.pack,mt.name) in
-						let rec loop c =
-							if c.cl_path = path then true
-							else match c.cl_super with
-								| Some(c,_) -> loop c
-								| None -> false
-						in
-						loop ctx.curclass
-					end
+					else
+						begin
+							match ctx.curclass.cl_kind with
+							| KAbstractImpl { a_path = (pack, name) } -> pack = mt.pack && name = mt.name
+							| _ -> false
+						end
+						|| begin
+							let path = (mt.pack,mt.name) in
+							let rec loop c =
+								if c.cl_path = path then true
+								else match c.cl_super with
+									| Some(c,_) -> loop c
+									| None -> false
+							in
+							loop ctx.curclass
+						end
 				| No -> false
 				| Maybe ->
 					begin try

+ 19 - 0
tests/display/src/cases/Issue8789.hx

@@ -0,0 +1,19 @@
+package cases;
+
+class Issue8789 extends DisplayTestCase {
+	/**
+		abstract Int8(Int) {
+			inline function new(value:Int) {
+				this = value;
+			}
+
+			public function test() {
+				new Int8{-1-}(10);
+			}
+		}
+	**/
+	function test() {
+		var r = toplevel(pos(1));
+		eq(true, hasToplevel(r, "type", "Int8"));
+	}
+}