Skip to content

[Default interfaces] VerifyVirtualMethodsImplemented wrong for generic interfaces #9716

@MichalStrehovsky

Description

@MichalStrehovsky

Type Fooer declares it implements IFoo`1<class [System.Runtime]System.ValueType>, but it doesn't. We still load the type just fine, violating type safety in the process, because the logic that checks for default interface method implementation is bogus and succeeds if we implement any instantiation of that generic interface.

.assembly extern System.Runtime { }

.assembly notimplemented { }

.class interface private abstract auto ansi IFoo`1<T>
{
  .method public hidebysig newslot abstract virtual instance void Frob() cil managed
  {
  }
}

.class interface private abstract auto ansi IBar
       implements class IFoo`1<class [System.Runtime]System.String>
{
  .method public hidebysig newslot virtual final instance void Frob() cil managed
  {
    .override class IFoo`1<class [System.Runtime]System.String>::Frob
    ret
  }
}

.class private auto ansi beforefieldinit Fooer
       extends [System.Runtime]System.Object
       implements IBar, class IFoo`1<class [System.Runtime]System.ValueType>
{
  .method public hidebysig specialname rtspecialname 
          instance void .ctor() cil managed
  {
    ldarg.0
    call instance void [System.Runtime]System.Object::.ctor()
    ret
  }
}

.method public hidebysig static void Main() cil managed
{
  .entrypoint
  newobj instance void Fooer::.ctor()
  pop
  ret
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions