Skip to content

Commit 30661f5

Browse files
Add regression test for a default interface method issue (#109917)
Regression test from #109893. This was fixed in #108235 but that one only has testcases that involve `IDynamicInterfaceCastable`.
1 parent f87428b commit 30661f5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/tests/nativeaot/SmokeTests/UnitTests/Interfaces.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static int Run()
4646
TestSharedInterfaceMethods.Run();
4747
TestGenericAnalysis.Run();
4848
TestRuntime108229Regression.Run();
49+
TestRuntime109893Regression.Run();
4950
TestCovariantReturns.Run();
5051
TestDynamicInterfaceCastable.Run();
5152
TestStaticInterfaceMethodsAnalysis.Run();
@@ -872,6 +873,37 @@ public static void Run()
872873
}
873874
}
874875

876+
class TestRuntime109893Regression
877+
{
878+
class Type<T> : IType<T>;
879+
880+
class MyVisitor : IVisitor
881+
{
882+
public object? Visit<T>(IType<T> _) => typeof(T);
883+
}
884+
885+
interface IType
886+
{
887+
object? Accept(IVisitor visitor);
888+
}
889+
890+
interface IType<T> : IType
891+
{
892+
object? IType.Accept(IVisitor visitor) => visitor.Visit(this);
893+
}
894+
895+
interface IVisitor
896+
{
897+
object? Visit<T>(IType<T> type);
898+
}
899+
900+
public static void Run()
901+
{
902+
IType type = new Type<object>();
903+
type.Accept(new MyVisitor());
904+
}
905+
}
906+
875907
class TestCovariantReturns
876908
{
877909
interface IFoo

0 commit comments

Comments
 (0)