Closed
Description
This should print true/true and it does so with CoreCLR or Native AOT in .NET 7. Starting with native AOT .NET 8, it prints true/false because CastCache cached the wrong answer. Likely regressed in #90234. Cc @VSadov
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
object o = new Shapeshifter();
Console.WriteLine(Is(o));
Console.WriteLine(Cast(o) != null);
[MethodImpl(MethodImplOptions.NoInlining)]
static bool Is(object o) => o is IEnumerable<object>;
[MethodImpl(MethodImplOptions.NoInlining)]
static IEnumerable<object> Cast(object o) => o as IEnumerable<object>;
class Shapeshifter : IDynamicInterfaceCastable
{
public RuntimeTypeHandle GetInterfaceImplementation(RuntimeTypeHandle interfaceType) => throw new NotImplementedException();
public bool IsInterfaceImplemented(RuntimeTypeHandle interfaceType, bool throwIfNotImplemented) => true;
}
Metadata
Metadata
Assignees
Type
Projects
Status
No status