Przeglądaj źródła

[display] fix "go to definition" on MyClass.new (closes #9084)

Aleksandr Kuzmenko 5 lat temu
rodzic
commit
8dee14ba60
2 zmienionych plików z 21 dodań i 2 usunięć
  1. 3 2
      src/typing/typerDisplay.ml
  2. 18 0
      tests/display/src/cases/Issue9084.hx

+ 3 - 2
src/typing/typerDisplay.ml

@@ -579,8 +579,9 @@ let handle_display ?resume_typing ctx e_ast dk with_type =
 		timer();
 		raise_fields l CRNew r.fsubject
 	in
-	let e = match e.eexpr with
-		| TField(e1,FDynamic "bind") when (match follow e1.etype with TFun _ -> true | _ -> false) -> e1
+	let e = match e_ast, e.eexpr with
+		| _, TField(e1,FDynamic "bind") when (match follow e1.etype with TFun _ -> true | _ -> false) -> e1
+		| (EField(_,"new"),_), TFunction { tf_expr = { eexpr = TReturn (Some ({ eexpr = TNew _ } as e1))} } -> e1
 		| _ -> e
 	in
 	let is_display_debug = Meta.has (Meta.Custom ":debug.display") ctx.curfield.cf_meta in

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

@@ -0,0 +1,18 @@
+package cases;
+
+class Issue9084 extends DisplayTestCase {
+	/**
+		class A {
+			public function {-2-}new{-3-}() {}
+		}
+
+	 	class Main {
+			static function main() {
+				A.n{-1-}ew;
+			}
+		}
+	**/
+	function test() {
+		eq(range(2, 3), position(pos(1)));
+	}
+}