Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

21 lines
352 B
C#

public static class CoalescingWithGenericsBug
{
class Service { public void Foo () { } }
static T Provide<T> () where T : class
{
return FindExisting<T> () ?? System.Activator.CreateInstance<T> ();
}
static T FindExisting<T> () where T : class
{
return null;
}
public static int Main ()
{
Provide<Service> ().Foo ();
return 0;
}
}