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

langversion does not affect overload resolution #9965

Closed
vcsjones opened this issue Mar 22, 2016 · 2 comments
Closed

langversion does not affect overload resolution #9965

vcsjones opened this issue Mar 22, 2016 · 2 comments
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design

Comments

@vcsjones
Copy link
Member

Version Used: csc 1.1.0.51109

Steps to Reproduce:

  1. Compile the below snippet using csc /out:foo.exe /target:exe /langversion:5 foo.cs
using System;
using System.Threading.Tasks;

namespace Blarg
{
    class Program
    {
        static void Main(string[] args)
        {
            Create<string>(async blah =>
            {
                while (true)
                {
                    Console.WriteLine("foo.");
                }
            });
        }

        public static void Create<TResult>(Func<IObserver<TResult>, Task> subscribeAsync)
        {
        }

        public static void Create<TResult>(Func<IObserver<TResult>, Task<Action>> subscribeAsync)
        {
        }
    }
}

Expected Behavior: Compilation fails with an overload ambiguity error. It appears that the langversion does not affect the improvements to overload resolution that were introduced in C# 6.

Actual Behavior: Compilation succeeds.

@gafter gafter added Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design labels Mar 22, 2016
@gafter
Copy link
Member

gafter commented Mar 22, 2016

This is intentional. The language version switch affects the syntax supported by the compiler.

@vcsjones
Copy link
Member Author

It feels a bit inconsistent with #2725, since that didn't really introduce any new syntax either, just where the syntax could be used.

Regardless, thanks for clarifying this is intentional.

@gafter gafter closed this as completed Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design
Projects
None yet
Development

No branches or pull requests

2 participants