dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.11k stars 4.04k forks source link

Getting a CS0570 while debugging a default interface generator method of a variant interface #43282

Open mburbea opened 4 years ago

mburbea commented 4 years ago

Consider the following interface and a dummy class that implements it.

interface I<out T>
{
    System.Collections.Generic.IEnumerable<T> M()
    {
        var x = default(T);
        yield return x;
    }
}

public class C : I<C>
{
    public static void Main() => System.Linq.Enumerable.Any(((I<C>)new C()).M());
}

now put a breakpoint on line 6 (yield return x). Execute the program and you'll notice something odd if you try to watch x, It tells you the following::

error CS0570: '<>x.<>m0(I.d__0)' is not supported by the language

Obviously, the program works so it is supported by the language, but the debugger has no idea what to do with it. This also happens for async (Task{T},ValueTask{T}, or IAsyncEnumerable<T>) returning methods

Dotnet-GitSync-Bot commented 4 years ago

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

jeffschwMSFT commented 4 years ago

@tommcdon

tommcdon commented 4 years ago

Looks like an expression evaluator issue. @tmat can you help route this?

tmat commented 4 years ago

@tommcdon Labels look good.