Skip to content

Commit

Permalink
Add regression test for a default interface method issue (dotnet#109917)
Browse files Browse the repository at this point in the history
Regression test from dotnet#109893. This was fixed in dotnet#108235 but that one only has testcases that involve `IDynamicInterfaceCastable`.
  • Loading branch information
MichalStrehovsky authored and mikelle-rogers committed Dec 4, 2024
1 parent 1340064 commit 1071c9e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/tests/nativeaot/SmokeTests/UnitTests/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static int Run()
TestSharedInterfaceMethods.Run();
TestGenericAnalysis.Run();
TestRuntime108229Regression.Run();
TestRuntime109893Regression.Run();
TestCovariantReturns.Run();
TestDynamicInterfaceCastable.Run();
TestStaticInterfaceMethodsAnalysis.Run();
Expand Down Expand Up @@ -872,6 +873,37 @@ public static void Run()
}
}

class TestRuntime109893Regression
{
class Type<T> : IType<T>;

class MyVisitor : IVisitor
{
public object? Visit<T>(IType<T> _) => typeof(T);
}

interface IType
{
object? Accept(IVisitor visitor);
}

interface IType<T> : IType
{
object? IType.Accept(IVisitor visitor) => visitor.Visit(this);
}

interface IVisitor
{
object? Visit<T>(IType<T> type);
}

public static void Run()
{
IType type = new Type<object>();
type.Accept(new MyVisitor());
}
}

class TestCovariantReturns
{
interface IFoo
Expand Down

0 comments on commit 1071c9e

Please sign in to comment.