This project is read-only.
1
Vote

Possible compiler error

description

Hello,

I have just found an error on C# 5 compiler (Eric Lippert has confirmed is an error) and I would like to let you know it so that it will not go into Roslyn (if it has not been fixed yet). I did not have the chance to perform the test using Roslyn. So, I'm not sure if that behavior stands. Here is the drill:

Given the following implementation

class P
{
static void Main()
{
    IBeta ibeta = new Beta();
    ibeta.Foo((dynamic)"");
}
}

interface IAlfa
{
void Foo(string s);
}

interface IBeta : IAlfa
{
}

class Beta : IBeta
{
public void Foo(string s) {}
}

Line:

ibeta.Foo((dynamic)"");

will throw a RuntimeBinderException ('IBeta' does not contain a definition for 'Foo'). If I reomve the dynamic cast everything works fine.

You mind check that?

Thanks

comments