diff --git a/Src/Compilers/Core/Portable/SynthesizedLocalKind.cs b/Src/Compilers/Core/Portable/SynthesizedLocalKind.cs
index 134868837820ccf70df2d357c5337a6b470aa4ec..94a80fbd6144dea290938d0bd67e6a452447b767 100644
--- a/Src/Compilers/Core/Portable/SynthesizedLocalKind.cs
+++ b/Src/Compilers/Core/Portable/SynthesizedLocalKind.cs
@@ -107,11 +107,10 @@ internal enum SynthesizedLocalKind
// VB TODO:
ForDirection = 14,
- // VB TODO:
- // degenerate select key (can we EnC when stopped on case?)
-
- // VB TODO: XmlInExpressionLambda locals are always lifted and must have distinct names.
- XmlInExpressionLambda = 15,
+ ///
+ /// Local variable used to store the value of Select Case during the execution of Case statements.
+ ///
+ SelectCaseValue = 15,
// VB TODO
OnErrorActiveHandler = 16,
@@ -169,6 +168,9 @@ internal enum SynthesizedLocalKind
///
CachedAnonymousMethodDelegate = 31,
+ // VB TODO: XmlInExpressionLambda locals are always lifted and must have distinct names.
+ XmlInExpressionLambda = 32,
+
///
/// All values have to be less than or equal to ()
///
diff --git a/Src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_SelectCase.vb b/Src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_SelectCase.vb
index 56559d4bbe27817ef4aacd66c59d7a49ffa1adc5..072b62bd7d51b2c0a4f6468d05a88671d3fac5df 100644
--- a/Src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_SelectCase.vb
+++ b/Src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_SelectCase.vb
@@ -193,6 +193,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
statementBuilder.Add(New BoundSequencePoint(selectExprStmtSyntax, Nothing))
End If
+
If generateUnstructuredExceptionHandlingResumeCode Then
RegisterUnstructuredExceptionHandlingResumeTarget(selectExprStmtSyntax, canThrow:=True, statements:=statementBuilder)
' If the Select throws, a Resume Next should branch to the End Select.
@@ -217,7 +218,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim selectExprType = rewrittenSelectExpression.Type
' Store the select expression result in a temp
- Dim tempLocal = New SynthesizedLocal(Me.currentMethodOrLambda, selectExprType, SynthesizedLocalKind.LoweringTemp)
+ Dim selectStatementSyntax = DirectCast(selectExprStmtSyntax.Parent, SelectBlockSyntax).SelectStatement
+ Dim tempLocal = New SynthesizedLocal(Me.currentMethodOrLambda, selectExprType, SynthesizedLocalKind.SelectCaseValue, selectStatementSyntax)
tempLocals = ImmutableArray.Create(Of LocalSymbol)(tempLocal)
Dim boundTemp = New BoundLocal(rewrittenSelectExpression.Syntax, tempLocal, selectExprType)
diff --git a/Src/Compilers/VisualBasic/Test/Emit/PDB/PDBTests.vb b/Src/Compilers/VisualBasic/Test/Emit/PDB/PDBTests.vb
index 6b9c56c044d26c5f6593c90243d73d896d1b4f77..3de7152bd04800e3f2f939e3e192c27e5dd561e7 100644
--- a/Src/Compilers/VisualBasic/Test/Emit/PDB/PDBTests.vb
+++ b/Src/Compilers/VisualBasic/Test/Emit/PDB/PDBTests.vb
@@ -1940,9 +1940,9 @@ End Module
-
+
-
+
@@ -2069,7 +2069,7 @@ End Module
-
+
@@ -2133,9 +2133,9 @@ End Module
-
+
-
+
@@ -2199,9 +2199,9 @@ End Module
-
+
-
+
@@ -2392,7 +2392,7 @@ End Module
-
+
@@ -7522,6 +7522,61 @@ End Class
+)
+ End Sub
+
+
+ Sub SynthesizedVariableForSelectCastValue()
+ Dim source =
+
+
+Imports System
+Class C
+ Sub F(args As String())
+ Select Case args(0)
+ Case "a"
+ Console.WriteLine(1)
+ Case "b"
+ Console.WriteLine(2)
+ Case "c"
+ Console.WriteLine(3)
+ End Select
+ End Sub
+End Class
+
+
+
+ Dim c = CreateCompilationWithMscorlibAndVBRuntime(source, options:=TestOptions.DebugDll)
+ c.VerifyDiagnostics()
+ c.VerifyPdb("C.F",
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
)
End Sub
diff --git a/Src/Compilers/VisualBasic/Test/Semantic/BasicCompilerSemanticTest.vbproj b/Src/Compilers/VisualBasic/Test/Semantic/BasicCompilerSemanticTest.vbproj
index 0dc19a3b2eb8cbe072e6079d9124acfe098e423b..271db48b4b59cd841f8c2f2243e85c3d2a7a2c76 100644
--- a/Src/Compilers/VisualBasic/Test/Semantic/BasicCompilerSemanticTest.vbproj
+++ b/Src/Compilers/VisualBasic/Test/Semantic/BasicCompilerSemanticTest.vbproj
@@ -203,7 +203,7 @@
-
+
diff --git a/Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTest.vb b/Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTests.vb
similarity index 99%
rename from Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTest.vb
rename to Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTests.vb
index aaaa3f0127019ad1d72e4c2f430d1cce503be786..b2aa95108271e6101401665fd976868a2b65456a 100644
--- a/Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTest.vb
+++ b/Src/Compilers/VisualBasic/Test/Semantic/Semantics/SelectCaseTests.vb
@@ -1,12 +1,10 @@
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-Imports Microsoft.CodeAnalysis.Text
-Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
- Public Class SelectCaseTest
+ Public Class SelectCaseTests
Inherits BasicTestBase
Public Sub SelectCaseExpression_NothingLiteral()