Closed
Description
Found this when I was looking at #1077 (it looks like having to declare IsAssignableFrom
linker unsafe would be quite a pain.)
It wouldn't be completely academical to assume that an app that has some Foo
s implementing IFoo
could end up in a situation where we have an empty array of Foo
s (because no Foo
was allocated because the code that normally news them up was e.g. linked out) that we need to cast to an array of IFoo
.
Linker currently produces invalid output for this because it strips the IFoo
implementation off Foo
:
using System;
interface IFoo { }
class Foo : IFoo { }
class Program
{
static void Main()
{
// need to go through object to force a cast for added dramatic effect at runtime
// otherwise this would just silently break type safety
IFoo[] foos = (IFoo[])(object)new Foo[0];
}
}