分析以下功能时,我在透析器中收到错误消息。
-spec do_request(Method, Type, Url, Expect, Headers, Body, Client) -> Response::client_response()
when
Method :: method(),
Type :: content_type(),
Url :: url(),
Expect :: status_codes(),
Headers :: headers(),
Body :: body(),
Client :: #client{}.
do_request(Method, Type, Url, Expect, Headers, Body, Client) ->
Client2 = check_expired(Client),
Headers2 = add_auth_header(Headers, Client2),
%% error occurs on this line
Response = restc:request(Method, Type, binary_to_list(Url), Expect, Headers2, Body),
%%
{Response, Client2}.
错误是:
The call restc:request(Method::any(),Type::any(),
[byte()],Expect::any(),Headers2::[{binary(),binary()},...],
Body::any()) breaks the contract (Method::method(), Type::content_type(),
Url::url(), Expect::status_codes(), Headers::headers(),
Body::body()) -> Response::response()
restc:request
具有以下类型规范:
-spec request(Method::method(), Type::content_type(), Url::url(),
Expect::status_codes(), Headers::headers(), Body::body()) -> Response::response().
调用使用的类型有:
-type method() :: head | get | put | post | trace | options | delete.
-type url() :: binary().
-type headers() :: [header()].
-type header() :: {binary(), binary()}.
-type status_codes() :: [status_code()].
-type status_code() :: integer().
-type reason() :: term().
-type content_type() :: json | xml | percent.
-type property() :: atom() | tuple().
-type proplist() :: [property()].
-type body() :: proplist().
-type response() :: {ok, Status::status_code(), Headers::headers(), Body::body()} |
{error, Status::status_code(), Headers::headers(), Body::body()} |
{error, Reason::reason()}.
-type client_response() :: {response(), #client{}}.
-type token_type() :: bearer | unsupported.
any()
当我指定了要传递的变量的类型时,为什么透析器会说我的调用正在传递具有类型的变量?我查看了调用链以验证类型规范是否一致(并且与其他模块一致)。