Przeglądaj źródła

always return actual function type for the signature completion (closes #5141)

Dan Korostelev 9 lat temu
rodzic
commit
c4c852a69a
2 zmienionych plików z 37 dodań i 1 usunięć
  1. 1 1
      src/main.ml
  2. 36 0
      tests/display/src/cases/Issue5141.hx

+ 1 - 1
src/main.ml

@@ -1725,7 +1725,7 @@ with
 		let b = Buffer.create 0 in
 		List.iter (fun (t,doc) ->
 			Buffer.add_string b "<type>\n";
-			Buffer.add_string b (htmlescape (s_type ctx t));
+			Buffer.add_string b (htmlescape (s_type ctx (follow t)));
 			Buffer.add_string b "\n</type>\n";
 		) tl;
 		raise (Completion (Buffer.contents b))

+ 36 - 0
tests/display/src/cases/Issue5141.hx

@@ -0,0 +1,36 @@
+package cases;
+
+class Issue5141 extends DisplayTestCase {
+	/**
+	typedef MyHandler = Int->String->Void
+
+	class Some {
+		function main() {
+			var a:MyHandler;
+			a{-1-};
+			a({-2-}
+		}
+	}
+	**/
+	function testTypedef() {
+		eq("cases.MyHandler", type(pos(1)));
+		arrayEq(["Int -> String -> Void"], signatures(pos(2)));
+	}
+
+	/**
+	@:callable
+	abstract MyCallable(Int->String->Void) {}
+
+	class Some {
+		function main() {
+			var a:MyCallable;
+			a{-1-};
+			a({-2-}
+		}
+	}
+	**/
+	function testAbstract() {
+		eq("cases.MyCallable", type(pos(1)));
+		arrayEq(["Int -> String -> Void"], signatures(pos(2)));
+	}
+}