Skip to content

[mono] UnsafeAccessor to a virtual method on a base class through a derived type asserts #89212

Closed
@vitek-karas

Description

@vitek-karas
    class InheritanceBase
    {
        protected virtual string BaseVirtual() => $"{nameof(InheritanceBase)}.{nameof(BaseVirtual)}";
    }

    class InheritanceDerived : InheritanceBase
    {
    }

    [Fact]
    public static void Verify_InheritanceMethodResolution()
    {
        var instance = new InheritanceDerived();
        Assert.Equal($"{nameof(InheritanceBase)}.{nameof(BaseVirtual)}", BaseVirtual(instance));

        [UnsafeAccessor(UnsafeAccessorKind.Method, Name = nameof(BaseVirtual))]
        extern static string BaseVirtual(InheritanceDerived target);
    }

This fails with

* Assertion at F:\dotnet\runtime4\src\mono\mono\metadata\marshal-lightweight.c:2508, condition `target_method->klass == target_class' not met

@lambdageek - could you please route this to the right area/person

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions