浏览代码

[display] build abstract class before checking its ctor

closes #7305
Simon Krajewski 6 年之前
父节点
当前提交
c6c4316c63
共有 2 个文件被更改,包括 23 次插入1 次删除
  1. 3 1
      src/typing/typerDisplay.ml
  2. 20 0
      tests/server/src/DisplayTests.hx

+ 3 - 1
src/typing/typerDisplay.ml

@@ -526,7 +526,9 @@ let handle_display ?resume_typing ctx e_ast dk with_type =
 						let mt = ctx.g.do_load_type_def ctx null_pos {tpackage=mt.pack;tname=mt.module_name;tsub=Some mt.name;tparams=[]} in
 						begin match resolve_typedef mt with
 						| TClassDecl c when has_constructor c -> true
-						| TAbstractDecl {a_impl = Some c} -> PMap.mem "_new" c.cl_statics
+						| TAbstractDecl {a_impl = Some c} ->
+							ignore(c.cl_build());
+							PMap.mem "_new" c.cl_statics
 						| _ -> false
 						end
 					with _ ->

+ 20 - 0
tests/server/src/DisplayTests.hx

@@ -5,6 +5,26 @@ import haxe.display.FsPath;
 @:timeout(5000)
 // TODO: somebody has to clean this up
 class DisplayTests extends HaxeServerTestCase {
+	function testIssue7305() {
+		var content = 'class Main {
+	static public function main() {
+		new Map{-1-}
+	}
+}';
+		var transform = Marker.extractMarkers(content);
+		vfs.putContent("Main.hx", transform.source);
+		runHaxeJson([], DisplayMethods.Completion, {
+			file: new FsPath("Main.hx"),
+			offset: transform.markers[1],
+			wasAutoTriggered: true
+		});
+		var result = parseCompletion();
+		assertHasCompletion(result, item -> switch (item.kind) {
+			case Type: item.args.path.pack.length == 0 && item.args.path.typeName == "Map";
+			case _: false;
+		});
+	}
+
 	function testIssue7317() {
 		var content = 'class Main {
 	public static function main() {