Переглянути джерело

[display] support signature display on func.bind(

closes #6997
Simon Krajewski 7 роки тому
батько
коміт
fa3e673c96
2 змінених файлів з 26 додано та 1 видалено
  1. 9 1
      src/typing/typerDisplay.ml
  2. 17 0
      tests/display/src/cases/Issue6997.hx

+ 9 - 1
src/typing/typerDisplay.ml

@@ -104,12 +104,20 @@ and handle_signature_display ctx e_ast with_type =
 	in
 	match fst e_ast with
 		| ECall(e1,el) ->
-			let e1 = try
+			let def () = try
 				type_expr ctx e1 Value
 			with Error (Unknown_ident "trace",_) ->
 				let e = expr_of_type_path (["haxe";"Log"],"trace") p in
 				type_expr ctx e Value
 			in
+			let e1 = match e1 with
+				| (EField (e,"bind"),p) ->
+					let e = type_expr ctx e Value in
+					(match follow e.etype with
+						| TFun signature -> e
+						| _ -> def ())
+				| _ ->	def()
+			in
 			let tl = match e1.eexpr with
 				| TField(_,fa) ->
 					begin match extract_field fa with

+ 17 - 0
tests/display/src/cases/Issue6997.hx

@@ -0,0 +1,17 @@
+package cases;
+
+class Issue6997 extends DisplayTestCase {
+	/**
+	"".lastIndexOf.bind({-1-}
+	**/
+	@:funcCode function test1() {
+		sigEq(0, [["str:String", "?startIndex:Null<Int>"]], signature(pos(1)));
+	}
+
+	/**
+	"".lastIndexOf.bind("foo", {-1-}
+	**/
+	@:funcCode function test2() {
+		sigEq(1, [["str:String", "?startIndex:Null<Int>"]], signature(pos(1)));
+	}
+}