From aaf17266b0e183e4c080123b89c930e8c6bfb4e9 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 1 Mar 2022 19:49:40 -0800 Subject: [PATCH] Use ExceptionUtilities.UnexpectedValue instead of Unreachable (#59849) --- .../Portable/Operations/CSharpOperationFactory.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 6d4c4b8241256..eedd886bb88b5 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -208,8 +208,6 @@ public CSharpOperationFactory(SemanticModel semanticModel) case BoundKind.TupleLiteral: case BoundKind.ConvertedTupleLiteral: return CreateBoundTupleOperation((BoundTupleExpression)boundNode); - case BoundKind.UnconvertedInterpolatedString: - throw ExceptionUtilities.Unreachable; case BoundKind.InterpolatedString: return CreateBoundInterpolatedStringExpressionOperation((BoundInterpolatedString)boundNode); case BoundKind.StringInsert: @@ -218,8 +216,6 @@ public CSharpOperationFactory(SemanticModel semanticModel) return CreateBoundLocalFunctionStatementOperation((BoundLocalFunctionStatement)boundNode); case BoundKind.AnonymousObjectCreationExpression: return CreateBoundAnonymousObjectCreationExpressionOperation((BoundAnonymousObjectCreationExpression)boundNode); - case BoundKind.AnonymousPropertyDeclaration: - throw ExceptionUtilities.Unreachable; case BoundKind.ConstantPattern: return CreateBoundConstantPatternOperation((BoundConstantPattern)boundNode); case BoundKind.DeclarationPattern: @@ -268,10 +264,6 @@ public CSharpOperationFactory(SemanticModel semanticModel) return CreateRangeExpressionOperation((BoundRangeExpression)boundNode); case BoundKind.SwitchSection: return CreateBoundSwitchSectionOperation((BoundSwitchSection)boundNode); - case BoundKind.UnconvertedConditionalOperator: - throw ExceptionUtilities.Unreachable; - case BoundKind.UnconvertedSwitchExpression: - throw ExceptionUtilities.Unreachable; case BoundKind.ConvertedSwitchExpression: return CreateBoundSwitchExpressionOperation((BoundConvertedSwitchExpression)boundNode); case BoundKind.SwitchExpressionArm: @@ -326,6 +318,10 @@ public CSharpOperationFactory(SemanticModel semanticModel) _ => null }; return new NoneOperation(children, _semanticModel, boundNode.Syntax, type: type, constantValue, isImplicit: isImplicit); + case BoundKind.UnconvertedInterpolatedString: + case BoundKind.UnconvertedConditionalOperator: + case BoundKind.UnconvertedSwitchExpression: + case BoundKind.AnonymousPropertyDeclaration: default: // If you're hitting this because the IOperation test hook has failed, see // /docs/Compilers/IOperation Test Hook.md for instructions on how to fix. @@ -849,7 +845,7 @@ private IOperation CreateBoundObjectInitializerMemberOperation(BoundObjectInitia return new PropertyReferenceOperation(property.GetPublicSymbol(), arguments, createReceiver(), _semanticModel, syntax, type, isImplicit); default: - throw ExceptionUtilities.Unreachable; + throw ExceptionUtilities.UnexpectedValue(memberSymbol.Kind); } IOperation? createReceiver() => memberSymbol?.IsStatic == true ?