-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Labels
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 Foos implementing IFoo could end up in a situation where we have an empty array of Foos (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];
}
}