2
0
Эх сурвалжийг харах

[display] show constructor signatures on `new` (closes #6275)

Simon Krajewski 8 жил өмнө
parent
commit
f80fb8b189

+ 3 - 1
src/typing/typer.ml

@@ -3748,7 +3748,9 @@ and display_expr ctx e_ast e with_type p =
 			| TVar(v,_) -> v.v_type,None
 			| TCall({eexpr = TConst TSuper; etype = t},_) -> t,None
 			| TNew({cl_kind = KAbstractImpl a},tl,_) -> TType(abstract_module_type a tl,[]),None
-			| TNew(c,tl,_) -> TInst(c,tl),None
+			| TNew(c,tl,_) ->
+				let t,_ = get_constructor ctx c tl p in
+				t,None
 			| TTypeExpr (TClassDecl {cl_kind = KAbstractImpl a}) -> TType(abstract_module_type a (List.map snd a.a_params),[]),None
 			| TField(e1,FDynamic "bind") when (match follow e1.etype with TFun _ -> true | _ -> false) -> e1.etype,None
 			| TReturn (Some e1) -> loop e1 (* No point in letting the internal Dynamic surface (issue #5655) *)

+ 20 - 0
tests/display/src/cases/Issue6275.hx

@@ -0,0 +1,20 @@
+package cases;
+
+class Issue6275 extends DisplayTestCase {
+	/**
+	import haxe.ds.Option;
+
+	class Main {
+		static function main() {
+			{-1-}n{-2-}ew Main("foo"){-3-};
+		}
+
+		{-4-}function new(s:String) {}{-5-}
+	}
+	**/
+	function test() {
+		eq("s : String -> Void", type(pos(2)));
+		eq(range(4, 5), position(pos(1)));
+		eq(range(1, 3), usage(pos(2))[0]);
+	}
+}