Skip to content

VerificationException with reflection, static abstract interface methods, and generic constraints #73658

@stephentoub

Description

@stephentoub

This:

internal static class Program
{
    static void Main()
    {
        Type s = typeof(Program).Assembly.GetType("Outer`1+Inner");
        Type i = s.GetInterface("IStatics");
        s.GetInterfaceMap(i);
    }
}

class Outer<TOuter>
{
    struct Inner : IStatics
    {
        public static void M<TInner>() where TInner : IConstraint { }
    }

    interface IStatics
    {
        static abstract void M<TInner>() where TInner : IConstraint;
    }

    interface IConstraint { }
}

throws:

Unhandled exception. System.Security.VerificationException: Method Outer`1+Inner[TOuter].M: type argument 'TInner' violates the constraint of type parameter 'TInner'.
   at System.RuntimeType.GetInterfaceMap(Type ifaceType)

Is that expected?

Metadata

Metadata

Labels

area-TypeSystem-coreclrin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions