Skip to content

Commit

Permalink
Regression test for GitHub issue #71319 (#71461)
Browse files Browse the repository at this point in the history
* Regression test for GitHub issue #71319

* Fix runtime assertion failure due to wrong GC mode

* Disable the new regression test on Mono with issue #71910
  • Loading branch information
trylek authored Jul 12, 2022
1 parent aa156db commit 29a6a45
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8042,7 +8042,7 @@ MethodTable::ResolveVirtualStaticMethod(

if (allowVariantMatches)
{
equivalentOrVariantCompatible = pItfInMap->CanCastTo(pInterfaceType, NULL);
equivalentOrVariantCompatible = pItfInMap->CanCastToInterface(pInterfaceType, NULL);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

interface IFoo<in T>
{
static virtual string DoStatic() => typeof(T).ToString();
}

interface IFoo2<in T>
{
static abstract string DoStatic();
}

class Fooer<T> : IFoo2<T>
{
public static string DoStatic() => typeof(T).ToString();
}

class Program : IFoo<object>
{
static string CallStatic<T, U>() where T : IFoo<U> => T.DoStatic();
static string CallStatic2<T, U>() where T : IFoo2<U> => T.DoStatic();

static int Main()
{
string staticResult1 = CallStatic<Program, string>();
Console.WriteLine("SVM call result #1: {0} (System.Object expected - using default interface implementation)", staticResult1);
string staticResult2 = CallStatic2<Fooer<object>, string>();
Console.WriteLine("SVM call result #2: {0} (System.Object expected - using implementation in a helper class)", staticResult2);
return (staticResult1 == "System.Object" && staticResult2 == "System.Object" ? 100 : 101);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>Full</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileName).cs" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,9 @@
<ExcludeList Include="$(XunitTestBinBase)/Loader/classloader/MethodImpl/CovariantReturns/Structs/IncompatibleOverride/**">
<Issue>Crashes during LLVM AOT compilation.</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/Loader/classloader/StaticVirtualMethods/RegressionTests/GitHub_71319/**">
<Issue>https://github.com/dotnet/runtime/issues/71910</Issue>
</ExcludeList>

<ExcludeList Include="$(XunitTestBinBase)/JIT/HardwareIntrinsics/General/HwiOp/CompareVectorWithZero/**">
<Issue>https://github.com/dotnet/runtime/pull/65632#issuecomment-1046294324</Issue>
Expand Down

0 comments on commit 29a6a45

Please sign in to comment.