diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index cd7253f2b3b8b..7f5ade7b65314 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -27087,5 +27087,32 @@ .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 } "); } + + [Fact] + [WorkItem(24517, "https://github.com/dotnet/roslyn/issues/24517")] + public void Issue24517() + { + var source = @" +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +class C +{ + static void Main() + { + Expression>> e1 = () => new ValueTuple(1, 2); + Expression>> e2 = () => new KeyValuePair(1, 2); + + e1.Compile()(); + e2.Compile()(); + + Console.WriteLine(""Done.""); + } +}"; + var comp = CreateCompilation( + source, + options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: @"Done."); + } } } diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index 27f9d2b623d25..e9c1546d6a962 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -23084,6 +23084,33 @@ Module Module1 System.Console.WriteLine(""Done"") End Sub +End Module +" + + Dim comp1 = CreateCompilation(source0, options:=TestOptions.DebugExe) + CompileAndVerify(comp1, expectedOutput:="Done") + End Sub + + + + Public Sub Issue24517() + Dim source0 = " +Imports System +Imports System.Collections.Generic +Imports System.Linq.Expressions + +Module Module1 + + Sub Main() + Dim e1 As Expression(Of Func(Of ValueTuple(Of Integer, Integer))) = Function() new ValueTuple(Of Integer, Integer)(1, 2) + Dim e2 As Expression(Of Func(Of KeyValuePair(Of Integer, Integer))) = Function() new KeyValuePair(Of Integer, Integer)(1, 2) + + e1.Compile()() + e2.Compile()() + + System.Console.WriteLine(""Done"") + End Sub + End Module "