Skip to content

ILASM/ILDASM support for covariant returns #37045

Closed

Description

@MichalStrehovsky

The shortcut .override Class::Method ILASM syntax is generating unresolvable MemberRefs for covariant returns (only the more wordy .override method instance ReturnType Class::Method(Param1, Param2) syntax works).

ILDASM generates the shortcut syntax, things don't roundtrip. I found this when I was playing with this in the linker yesterday.

To repro, e.g. take the CompatibleWith.il test, ILASM it, then ILDASM it and ILASM it again.

After the first ILDASM:

.method /*06000009*/ public hidebysig newslot virtual 
        instance class [System.Runtime/*23000003*/]System.Collections.Generic.IList`1/*01000002*/<int32> 
        M1() cil managed
{
  .override C1/*02000004*/::M1 /*02000004::06000002*/ 
  // Code size       1 (0x1)
  .maxstack  8
  IL_0000:  ret
} // end of method C2::M1

After the second ILDASM:

.method /*06000009*/ public hidebysig newslot virtual 
        instance class [System.Runtime/*23000003*/]System.Collections.Generic.IList`1/*01000002*/<int32> 
        M1() cil managed
{
  .override C1/*01000006*/::M1 /*01000006::0A00000D*/ 
  // Code size       1 (0x1)
  .maxstack  8
  IL_0000:  ret
} // end of method C2::M1

Notice that the .override is actually using MemberRefs in the second disassembly and I don't think the MemberRefs actually resolve (didn't try with Fadi's/Jan's branch, but I don't think it will work).

The MemberRef token is defined as this:

TypeRef #6 (01000006)
-------------------------------------------------------
Token:             0x01000006
ResolutionScope:   0x00000001
TypeRefName:       C1
	MemberRef #1 (0a00000d)
	-------------------------------------------------------
		Member: (0a00000d) M1: 
		CallCnvntn: [DEFAULT]
		hasThis 
		ReturnType: GenericInst Class System.Collections.Generic.IList`1< I4>
		No arguments.

Notice the return type.

It's also weird there's no warning about this from ILASM, but that's a preexisting issue I guess.

Activity

  1. added this to the 5.0 milestone on May 27, 2020
  2. added
    untriaged
    on May 27, 2020
  3. MichalStrehovsky commented on May 27, 2020

    @MichalStrehovsky
    MemberAuthor
  4. removed
    untriaged
    on Jun 1, 2020
  5. BruceForstall commented on Jun 1, 2020

    @BruceForstall
    Contributor

    @MichalStrehovsky Someone working on the covariant return feature needs to own this implementation (and take ownership of this bug). Who would that be?

  6. MichalStrehovsky commented on Jun 2, 2020

    @MichalStrehovsky
    MemberAuthor

    @janvorli who is already Cc'd above

  7. self-assigned this
    on Jun 2, 2020
  8. self-assigned this
    on Aug 7, 2020
  9. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions