-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No ambiguity exists when a type has an implicit conversion to RequestContent #3587
Comments
I understand the backend logic that could resolve the ambiguity call, but just wondering whether this is obvious from end users' prospective. To avoid the misuse of cc @m-nash |
I think we should be clear about the principles of when to make a protocol method overload. Should we keep
Of course, we change the signature.
Why would Get(null) a misuse? I think it totally makes sense. |
From our guideline: Approachable
|
The only scenarios we need to consider the ambiguity is: all required parameters are set and all the optional parameters are not pass in. For each pair of protocol and convenience, we will try to call with only required parameters provided. If the compilation passes, then we keep the |
Background:
We will make protocol method an overload (make the
RequestContext
required) if the input body is optional to avoid ambiguous call. For example:We will generate
The
RequestContext
is required otherwise there will be ambiguous callGet(null)
.Problem:
We are introducing such kind of implicit conversion from
Model
toRequestContent
:After this change, below code has no ambiguity (attention:
RequestContext
is back to optional). We could callGet(null)
and it goes to convenience method.From this document,
and this document,
It seems to be expected. Try code here.
Pay attention to that we already have implicit conversion from
string/BinaryData/DynamicData
toRequestContent
. So same logic applies to these types.Action:
We might revert the previous logic because we don't need to generate overload for an optional body after that change.
The text was updated successfully, but these errors were encountered: