Skip to content

Assertion at /Users/runner/work/1/s/src/mono/mono/metadata/class-setup-vtable.c:1007, condition `is_ok (error)' not met, function:apply_override, VAR 1 (V) cannot be expanded in this context with 1 instantiations #70190

Closed
@matthewslesinski

Description

@matthewslesinski

Description

When I'm trying to run my CLI project, I get this error thrown by Mono when it's loading my code. It gets thrown with both .NET 6 and 7 (preview 4), and my code works fine when I run it without Mono. In the past, I was blocked by a similar issue (#61244), and while that issue has since been fixed, this new one is coming up. I was able to determine a pretty simple reproduction example, and it's very similar to that other issue I just linked to, though definitely different (or maybe that previous bug was only partially fixed?), since I'm no longer seeing that previous issue occur. Also, I need to run my project with Mono because it's currently a functioning CLI application (when run without Mono) but I'm trying to eventually turn it into a Blazor WASM application.

It seems to occur when: One interface defines a method; a second interface, which is a child of the first and has at least one generic type variable, gives that method a default implementation; a third class/interface, which is a child of the second, overrides that default implementation with a different default implementation, has more generic type variables than the parent/second interface, and has its last generic type variable being passed to one of the parent/second interface's generic type variables.

Reproduction Steps

Try to run the following C# code with Mono:

public interface IA
{
    public void Foo();
}

public interface IB<T> : IA
{
    void IA.Foo() { }
}

public class C<U, V> : IB<V>
{
    void IA.Foo() { }
}

public class Program
{
    public static void Main()
    {
        IA c = new C<int, int>();
        c.Foo();
        Console.WriteLine("Your code should not reach here if you are running with Mono");
    }
}

I added these lines (inside a PropertyGroup) to my project's .csproj file to get it to run with Mono:

<UseMonoRuntime>true</UseMonoRuntime>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>

Expected behavior

Code runs successfully

Actual behavior

Assertion at /Users/runner/work/1/s/src/mono/mono/metadata/class-setup-vtable.c:1007, condition `is_ok (error)' not met, function:apply_override, VAR 1 (V) cannot be expanded in this context with 1 instantiations

This error gets thrown and aborts execution.

Regression?

No response

Known Workarounds

No response

Configuration

.NET Version: .NET 6 or .NET 7 (Preview 4)
OS: macOS Monterey
Architecture: x64
I don't think it's specific to this configuration
Issue appears in all browsers (when I try to reference my existing code from the sample Blazor WASM project)

Other information

Seems very similar to but is not the same as #61244

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions