Skip to content

Update doc for OpCodes.Constrained to "support" static abstract interface members. #9139

Open
@gurustron

Description

@gurustron

The doc explicitly says that this opcode can appear only a callvirt instruction:

The constrained prefix is permitted only on a callvirt instruction.

But according to sharplab the following:

public interface ITestable {
    public abstract static void Test();
}

public class MyTester<T> where T : ITestable {
    public void RunTest() {
        T.Test();
    }
}

Leads to the following IL:

    .method public hidebysig 
        instance void RunTest () cil managed 
    {
        // Method begins at RVA 0x208e
        // Code size 12 (0xc)
        .maxstack 8

        IL_0000: constrained. !T
        IL_0006: call void ITestable::Test()
        IL_000b: ret
    } // end of method MyTester`1::RunTest

Assuming that sharplab is right and this is intended behaviour it seems that update for docs can be needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityarea-System.Reflection.Emitdoc-bugProblem with the content; needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions