Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Overload resolution ambiguity introduced by SDK 8.0.300-preview.24203.14 #73346

Closed
danielcweber opened this issue May 6, 2024 · 3 comments · Fixed by #73373
Closed

Overload resolution ambiguity introduced by SDK 8.0.300-preview.24203.14 #73346

danielcweber opened this issue May 6, 2024 · 3 comments · Fixed by #73373
Assignees
Milestone

Comments

@danielcweber
Copy link

danielcweber commented May 6, 2024

The SDK 8 preview that comes with the latest VS2022 preview introduces an overload resolution ambiguity that is not in the stable SDK.

Version Used:

8.0.300-preview.24203.14

Steps to Reproduce:

See this repo for a reproduction and this or this workflow run to watch a build fail.

The issue is also in the latest SDK 9 preview. It's not reproducible on dotnetfiddle/sharplab, the latest SDK bits there are seemingly not recent enough.

Everything is fine on 8.0.204.

This might be related to collection expression conversions since the method overload in question has a params [] parameter.

Note: I also opened an issue in the sdk repo but this might be the more appropriate place.

Update
AzDO issues:

@cston
Copy link
Member

cston commented May 6, 2024

Overload resolution is not preferring the overload with the more specific params array type in this case (in BetterFunctionMember).

cc @AlekseyTs

@AlekseyTs
Copy link
Contributor

The code from the repo:

using System;

namespace OverloadResolutionRepro
{
    public class Foo
    {
        public void Method<S>(params Func<Bar, S>[] projections) => throw new NotImplementedException();
        public void Method<S>(params Func<Bar, Wrapper<S>>[] projections) => throw new NotImplementedException();
    }

    public class Bar
    {
        public Wrapper<int> WrappedValue { get; set; } = new Wrapper<int>();
    }

    public struct Wrapper<TValue>
    {
    }

    public class EntryPoint
    {
        static void Main()
        {
            new Foo().Method(x => x.WrappedValue);
        }
    }
}

@danielcweber
Copy link
Author

The error code is CS0121 (if you came here by searching issues for this code) and apparently the bug made it's way into SDK 8.0.300.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants