Skip to content

Commit

Permalink
Regression test for GitHub issue dotnet#71319
Browse files Browse the repository at this point in the history
  • Loading branch information
trylek committed Jul 10, 2022
1 parent 60af631 commit fd772ab
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
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>

0 comments on commit fd772ab

Please sign in to comment.