diff --git a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionArmBinder.cs b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionArmBinder.cs index ebec7a0aacbe45b7cbffada49392f33852669900..c31b4b68b0f90565160a837d959f7885c27a2648 100644 --- a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionArmBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionArmBinder.cs @@ -34,13 +34,13 @@ internal override BoundSwitchExpressionArm BindSwitchExpressionArm(SwitchExpress { Debug.Assert(node == _arm); var caseBinder = this.GetBinder(node); - var hasErrors = _switchExpressionBinder.SwitchGoverningExpression.HasErrors; + var hasErrors = _switchExpressionBinder.SwitchGoverningType.IsErrorType(); var locals = _armScopeBinder.Locals; var pattern = caseBinder.BindPattern(node.Pattern, _switchExpressionBinder.SwitchGoverningType, hasErrors, diagnostics); var guard = node.WhenClause != null - ? caseBinder.BindBooleanExpression((ExpressionSyntax)node.WhenClause.Condition, diagnostics) + ? caseBinder.BindBooleanExpression(node.WhenClause.Condition, diagnostics) : null; - var result = caseBinder.BindValue((ExpressionSyntax)node.Expression, diagnostics, BindValueKind.RValue); + var result = caseBinder.BindValue(node.Expression, diagnostics, BindValueKind.RValue); return new BoundSwitchExpressionArm(node, locals, pattern, guard, result, hasErrors); } } diff --git a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs index d9db44b7a0cb8ad8295465d0d03f0bab27eaab82..1ea296a8df2ec15cf20f5d8e91027876ee5df016 100644 --- a/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs @@ -45,7 +45,7 @@ internal override BoundExpression BindSwitchExpressionCore(SwitchExpressionSynta /// private TypeSymbol InferResultType(ImmutableArray switchCases, DiagnosticBag diagnostics) { - var seenTypes = new HashSet(); + var seenTypes = PooledHashSet.GetInstance(); var typesInOrder = ArrayBuilder.GetInstance(); foreach (var @case in switchCases) { @@ -65,6 +65,7 @@ private TypeSymbol InferResultType(ImmutableArray swit commonType = CreateErrorType(); } + seenTypes.Free(); return commonType; } diff --git a/src/Compilers/CSharp/Portable/Parser/LanguageParser_Patterns.cs b/src/Compilers/CSharp/Portable/Parser/LanguageParser_Patterns.cs index 20f43752e4592548cd8247d6a5447350ee9eb475..f7c28bafe872dcb266ea3dba941e7e633093e68c 100644 --- a/src/Compilers/CSharp/Portable/Parser/LanguageParser_Patterns.cs +++ b/src/Compilers/CSharp/Portable/Parser/LanguageParser_Patterns.cs @@ -454,7 +454,7 @@ bool looksLikeCast() { // There is an ambiguity between a deconstruction pattern `(` pattern `)` // and a constant expression pattern that happens to be parenthesized. - // Per 2017-11-20 LDM we treat such syntax as a parenthseized expression always. + // Per 2017-11-20 LDM we treat such syntax as a parenthesized expression always. return _syntaxFactory.ConstantPattern(_syntaxFactory.ParenthesizedExpression(openParenToken, cp.Expression, closeParenToken)); } }