Skip to content
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

Seemingly needless error CS0121: The call is ambiguous between the following methods or properties: 'x(Action)' and 'x(Func<Task>)' #14885

Closed
sandersaares opened this issue Nov 2, 2016 · 1 comment
Labels

Comments

@sandersaares
Copy link

Version Used:
VS 2015 Update 3

Steps to Reproduce:

Attempt to compile the following code:

private void x()
{
}

private void yyyyyyyyyyyyyyy(Action a)
{
}

private void yyyyyyyyyyyyyyy(Func<Task> a)
{
}

private void z()
{
	yyyyyyyyyyyyyyy(x);
}

Expected Behavior:

Code compiles and the Action overload is used in z().

Actual Behavior:

CS0121: The call is ambiguous between the following methods or properties: 'foo.yyyyyyyyyyyyyyy(Action)' and 'foo.yyyyyyyyyyyyyyy(Func)'

Further notes:

Explicitly casting it as yyyyyyyyyyyyyyy((Action)x); works fine.

Casting as yyyyyyyyyyyyyyy((Func<Task>)x); is a compile error.

@gafter
Copy link
Member

gafter commented Nov 2, 2016

This is bullet 3 in #250

@gafter gafter closed this as completed Nov 2, 2016
@gafter gafter added Resolution-Duplicate The described behavior is tracked in another issue Language-C# Feature Request Area-Language Design labels Nov 2, 2016
dahlbyk added a commit to dahlbyk/Xamarin.Forms that referenced this issue Jul 9, 2019
CS0121: The call is ambiguous between the following methods or
properties: 'Device.InvokeOnMainThreadAsync(Action)' and
'Device.InvokeOnMainThreadAsync(Func<Task>)'

dotnet/roslyn#14885
dotnet/csharplang#98
StephaneDelcroix pushed a commit to xamarin/Xamarin.Forms that referenced this issue Jul 16, 2019
…6718)

* [Core] Use local functions

* [Core] Extract DeviceUnitTests

* [Core] Ensure actually called from main thread

* [Core] Add InvokeOnMainThread tests

WithAsyncTask is expected to fail.

* [Core] Rename local wrapper functions

* [Core] Avoid ambiguous call

CS0121: The call is ambiguous between the following methods or
properties: 'Device.InvokeOnMainThreadAsync(Action)' and
'Device.InvokeOnMainThreadAsync(Func<Task>)'

dotnet/roslyn#14885
dotnet/csharplang#98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants