Explorar o código

[display] go through normal typing for call targets in signature mode

closes #7326
Simon Krajewski %!s(int64=6) %!d(string=hai) anos
pai
achega
e32f3c3848

+ 20 - 17
src/typing/typer.ml

@@ -2298,25 +2298,27 @@ and type_meta ctx m e1 with_type p =
 	ctx.meta <- old;
 	e
 
+and type_call_target ctx e with_type inline p =
+	let e = maybe_type_against_enum ctx (fun () -> type_access ctx (fst e) (snd e) MCall) with_type true p in
+	if not inline then
+		e
+	else match e with
+		| AKExpr {eexpr = TField(e1,fa); etype = t} ->
+			begin match extract_field fa with
+			| Some cf -> AKInline(e1,cf,fa,t)
+			| None -> e
+			end;
+		| AKUsing(e,c,cf,ef,_) ->
+			AKUsing(e,c,cf,ef,true)
+		| AKExpr {eexpr = TLocal _} ->
+			display_error ctx "Cannot force inline on local functions" p;
+			e
+		| _ ->
+			e
+
 and type_call ctx e el (with_type:WithType.t) inline p =
 	let def () =
-		let e = maybe_type_against_enum ctx (fun () -> type_access ctx (fst e) (snd e) MCall) with_type true p in
-		let e = if not inline then
-			e
-		else match e with
-			| AKExpr {eexpr = TField(e1,fa); etype = t} ->
-				begin match extract_field fa with
-				| Some cf -> AKInline(e1,cf,fa,t)
-				| None -> e
-				end;
-			| AKUsing(e,c,cf,ef,_) ->
-				AKUsing(e,c,cf,ef,true)
-			| AKExpr {eexpr = TLocal _} ->
-				display_error ctx "Cannot force inline on local functions" p;
-				e
-			| _ ->
-				e
-		in
+		let e = type_call_target ctx e with_type inline p in
 		build_call ctx e el with_type p
 	in
 	match e, el with
@@ -2665,4 +2667,5 @@ let rec create com =
 unify_min_ref := unify_min;
 make_call_ref := make_call;
 build_call_ref := build_call;
+type_call_target_ref := type_call_target;
 type_block_ref := type_block

+ 1 - 0
src/typing/typerBase.ml

@@ -25,6 +25,7 @@ type object_decl_kind =
 	| ODKPlain
 
 let build_call_ref : (typer -> access_kind -> expr list -> WithType.t -> pos -> texpr) ref = ref (fun _ _ _ _ _ -> assert false)
+let type_call_target_ref : (typer -> expr -> WithType.t -> bool -> pos -> access_kind) ref = ref (fun _ _ _ _ _ -> assert false)
 
 let relative_path ctx file =
 	let slashes path = String.concat "/" (ExtString.String.nsplit path "\\") in

+ 1 - 1
src/typing/typerDisplay.ml

@@ -223,7 +223,7 @@ let rec handle_signature_display ctx e_ast with_type =
 		| ECall(e1,el) ->
 			let def () =
 				try
-					type_expr ctx e1 WithType.value
+					acc_get ctx (!type_call_target_ref ctx e1 with_type false (pos e1)) (pos e1)
 				with
 				| Error (Unknown_ident "trace",_) ->
 					let e = expr_of_type_path (["haxe";"Log"],"trace") p in

+ 1 - 1
tests/display/src/cases/Issue7326.hx

@@ -17,7 +17,7 @@ class Issue7326 extends DisplayTestCase {
 	**/
 	function test() {
 		// sigEq(0, [["v:Int"]], signature(pos(1)));
-		sigEq(0, [["v:Unknown<0>"]], signature(pos(1)));
+		sigEq(0, [["v:Int"]], signature(pos(1)));
 		sigEq(0, [["v:Unknown<0>"]], signature(pos(2)));
 	}
 }