-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-TypeSystem-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Description
I found code that throws a VerificationException for static virtual interface methods, and generic constraints, similar to this issue #73658 but without reflection.
Reproduction Steps
Run this code:
public interface ITestItem<T>
{
}
public interface IStaticInterfaceBase<T, in TRequest>
where T : class
where TRequest : IStaticInterfaceBase<T, TRequest>
{
static abstract void TryInvoke<TItem>(TItem item, TRequest request) where TItem : ITestItem<T>;
}
public interface IStaticInterface<T, in TRequest> : IStaticInterfaceBase<T, TRequest>
where T : class
where TRequest : IStaticInterface<T, TRequest>
{
static void IStaticInterfaceBase<T, TRequest>.TryInvoke<TItem>(TItem item, TRequest request)
{
}
}
public class Request : IStaticInterface<object, Request>
{
}
internal class Program
{
public static void Invoke<T, TRequest>(TRequest request)
where T : class
where TRequest : IStaticInterfaceBase<T, TRequest> =>
TRequest.TryInvoke((ITestItem<T>) null!, request);
public static void Main(string[] args) => Invoke<object, Request>(new Request());
}
Expected behavior
The code will run without error.
Actual behavior
Unhandled exception. System.Security.VerificationException: Method StaticInterfaceBug.IStaticInterface`2[System.Object,StaticInterfaceBug.Request].StaticInterfaceBug.IStaticInterfaceBase<T,TRequest>.TryInvoke: type argument 'TItem' violates the constraint of type parameter 'TItem'.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Joe4evr and xparadoxical
Metadata
Metadata
Assignees
Labels
area-TypeSystem-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged