Skip to content

Commit

Permalink
Add runtime test for static gsharedvt methods (dotnet#101489)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotlarmilos authored and michaelgsharp committed May 8, 2024
1 parent 50eb87e commit 1557838
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_94467/Runtime_94467.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Xunit;

public static class Runtime_94467
{
public interface ITypeChecker
{
static abstract bool Test<T>(T value);
}

public interface IHandler
{
bool Test<T>(T value);
}

public struct TypeChecker : ITypeChecker
{
public static bool Test<T>(T value) => true;
}

public class Handler<TChecker> : IHandler where TChecker : ITypeChecker
{
public bool Test<T>(T value) => TChecker.Test(value);
}

public static IHandler GetHandler() => new Handler<TypeChecker>();

[Fact]
public static int Test()
{
try {
var handler = GetHandler();
if (handler.Test<bool>(true) && handler.Test<bool?>(true))
return 100;
else
return 101;
} catch (Exception) {
return -1;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 1557838

Please sign in to comment.