Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long switch expression is duplicated in InferTypesWorker_DoNotCallDirectly overloads #66116

Closed
Youssef1313 opened this issue Dec 24, 2022 · 2 comments · Fixed by #71412
Closed
Labels
Area-IDE Concept-Design Debt Engineering Debt, Design Debt, or poor product code quality good first issue The issue is reserved for a first time, non-Microsoft contributor help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@Youssef1313
Copy link
Member

return parent switch
{
AnonymousObjectMemberDeclaratorSyntax memberDeclarator => InferTypeInMemberDeclarator(memberDeclarator),
ArgumentSyntax argument => InferTypeInArgument(argument),
ArrayCreationExpressionSyntax arrayCreationExpression => InferTypeInArrayCreationExpression(arrayCreationExpression),
ArrayRankSpecifierSyntax arrayRankSpecifier => InferTypeInArrayRankSpecifier(arrayRankSpecifier),
ArrayTypeSyntax arrayType => InferTypeInArrayType(arrayType),
ArrowExpressionClauseSyntax arrowClause => InferTypeInArrowExpressionClause(arrowClause),
AssignmentExpressionSyntax assignmentExpression => InferTypeInBinaryOrAssignmentExpression(assignmentExpression, assignmentExpression.OperatorToken, assignmentExpression.Left, assignmentExpression.Right, expression),
AttributeArgumentSyntax attribute => InferTypeInAttributeArgument(attribute),
AttributeSyntax _ => InferTypeInAttribute(),
AwaitExpressionSyntax awaitExpression => InferTypeInAwaitExpression(awaitExpression),
BinaryExpressionSyntax binaryExpression => InferTypeInBinaryOrAssignmentExpression(binaryExpression, binaryExpression.OperatorToken, binaryExpression.Left, binaryExpression.Right, expression),
CastExpressionSyntax castExpression => InferTypeInCastExpression(castExpression, expression),
CatchDeclarationSyntax catchDeclaration => InferTypeInCatchDeclaration(catchDeclaration),
CatchFilterClauseSyntax catchFilterClause => InferTypeInCatchFilterClause(catchFilterClause),
CheckedExpressionSyntax checkedExpression => InferTypes(checkedExpression),
ConditionalAccessExpressionSyntax conditionalAccessExpression => InferTypeInConditionalAccessExpression(conditionalAccessExpression),
ConditionalExpressionSyntax conditionalExpression => InferTypeInConditionalExpression(conditionalExpression, expression),
ConstantPatternSyntax constantPattern => InferTypeInConstantPattern(constantPattern),
DoStatementSyntax doStatement => InferTypeInDoStatement(doStatement),
EqualsValueClauseSyntax equalsValue => InferTypeInEqualsValueClause(equalsValue),
ExpressionColonSyntax expressionColon => InferTypeInExpressionColon(expressionColon),
ExpressionStatementSyntax _ => InferTypeInExpressionStatement(),
ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, expression),
ForStatementSyntax forStatement => InferTypeInForStatement(forStatement, expression),
IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement),
InitializerExpressionSyntax initializerExpression => InferTypeInInitializerExpression(initializerExpression, expression),
IsPatternExpressionSyntax isPatternExpression => InferTypeInIsPatternExpression(isPatternExpression, node),
LockStatementSyntax lockStatement => InferTypeInLockStatement(lockStatement),
MemberAccessExpressionSyntax memberAccessExpression => InferTypeInMemberAccessExpression(memberAccessExpression, expression),
NameColonSyntax nameColon => InferTypeInNameColon(nameColon),
NameEqualsSyntax nameEquals => InferTypeInNameEquals(nameEquals),
LambdaExpressionSyntax lambdaExpression => InferTypeInLambdaExpression(lambdaExpression),
PostfixUnaryExpressionSyntax postfixUnary => InferTypeInPostfixUnaryExpression(postfixUnary),
PrefixUnaryExpressionSyntax prefixUnary => InferTypeInPrefixUnaryExpression(prefixUnary),
RecursivePatternSyntax propertyPattern => InferTypeInRecursivePattern(propertyPattern),
PropertyPatternClauseSyntax propertySubpattern => InferTypeInPropertyPatternClause(propertySubpattern),
RefExpressionSyntax refExpression => InferTypeInRefExpression(refExpression),
ReturnStatementSyntax returnStatement => InferTypeForReturnStatement(returnStatement),
SubpatternSyntax subpattern => InferTypeInSubpattern(subpattern, node),
SwitchExpressionArmSyntax arm => InferTypeInSwitchExpressionArm(arm),
SwitchLabelSyntax switchLabel => InferTypeInSwitchLabel(switchLabel),
SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement),
ThrowExpressionSyntax throwExpression => InferTypeInThrowExpression(throwExpression),
ThrowStatementSyntax throwStatement => InferTypeInThrowStatement(throwStatement),
UsingStatementSyntax usingStatement => InferTypeInUsingStatement(usingStatement),
WhenClauseSyntax whenClause => InferTypeInWhenClause(whenClause),
WhileStatementSyntax whileStatement => InferTypeInWhileStatement(whileStatement),
YieldStatementSyntax yieldStatement => InferTypeInYieldStatement(yieldStatement),
_ => SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>(),
};
}

return parent switch
{
AnonymousObjectCreationExpressionSyntax anonymousObjectCreation => InferTypeInAnonymousObjectCreation(anonymousObjectCreation, token),
AnonymousObjectMemberDeclaratorSyntax memberDeclarator => InferTypeInMemberDeclarator(memberDeclarator, token),
ArgumentListSyntax argument => InferTypeInArgumentList(argument, token),
ArgumentSyntax argument => InferTypeInArgument(argument, token),
ArrayCreationExpressionSyntax arrayCreationExpression => InferTypeInArrayCreationExpression(arrayCreationExpression, token),
ArrayRankSpecifierSyntax arrayRankSpecifier => InferTypeInArrayRankSpecifier(arrayRankSpecifier, token),
ArrayTypeSyntax arrayType => InferTypeInArrayType(arrayType, token),
ArrowExpressionClauseSyntax arrowClause => InferTypeInArrowExpressionClause(arrowClause),
AssignmentExpressionSyntax assignmentExpression => InferTypeInBinaryOrAssignmentExpression(assignmentExpression, assignmentExpression.OperatorToken, assignmentExpression.Left, assignmentExpression.Right, previousToken: token),
AttributeArgumentListSyntax attributeArgumentList => InferTypeInAttributeArgumentList(attributeArgumentList, token),
AttributeArgumentSyntax argument => InferTypeInAttributeArgument(argument, token),
AttributeListSyntax attributeDeclaration => InferTypeInAttributeDeclaration(attributeDeclaration, token),
AttributeTargetSpecifierSyntax attributeTargetSpecifier => InferTypeInAttributeTargetSpecifier(attributeTargetSpecifier, token),
AwaitExpressionSyntax awaitExpression => InferTypeInAwaitExpression(awaitExpression, token),
BinaryExpressionSyntax binaryExpression => InferTypeInBinaryOrAssignmentExpression(binaryExpression, binaryExpression.OperatorToken, binaryExpression.Left, binaryExpression.Right, previousToken: token),
BinaryPatternSyntax binaryPattern => GetPatternTypes(binaryPattern),
BracketedArgumentListSyntax bracketedArgumentList => InferTypeInBracketedArgumentList(bracketedArgumentList, token),
CastExpressionSyntax castExpression => InferTypeInCastExpression(castExpression, previousToken: token),
CatchDeclarationSyntax catchDeclaration => InferTypeInCatchDeclaration(catchDeclaration, token),
CatchFilterClauseSyntax catchFilterClause => InferTypeInCatchFilterClause(catchFilterClause, token),
CheckedExpressionSyntax checkedExpression => InferTypes(checkedExpression),
ConditionalExpressionSyntax conditionalExpression => InferTypeInConditionalExpression(conditionalExpression, previousToken: token),
DefaultExpressionSyntax defaultExpression => InferTypeInDefaultExpression(defaultExpression),
DoStatementSyntax doStatement => InferTypeInDoStatement(doStatement, token),
EqualsValueClauseSyntax equalsValue => InferTypeInEqualsValueClause(equalsValue, token),
ExpressionColonSyntax expressionColon => InferTypeInExpressionColon(expressionColon, token),
ExpressionStatementSyntax _ => InferTypeInExpressionStatement(token),
ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, previousToken: token),
ForStatementSyntax forStatement => InferTypeInForStatement(forStatement, previousToken: token),
IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement, token),
ImplicitArrayCreationExpressionSyntax implicitArray => InferTypeInImplicitArrayCreation(implicitArray),
InitializerExpressionSyntax initializerExpression => InferTypeInInitializerExpression(initializerExpression, previousToken: token),
LockStatementSyntax lockStatement => InferTypeInLockStatement(lockStatement, token),
MemberAccessExpressionSyntax memberAccessExpression => InferTypeInMemberAccessExpression(memberAccessExpression, previousToken: token),
NameColonSyntax nameColon => InferTypeInNameColon(nameColon, token),
NameEqualsSyntax nameEquals => InferTypeInNameEquals(nameEquals, token),
BaseObjectCreationExpressionSyntax objectCreation => InferTypeInObjectCreationExpression(objectCreation, token),
LambdaExpressionSyntax lambdaExpression => InferTypeInLambdaExpression(lambdaExpression, token),
PostfixUnaryExpressionSyntax postfixUnary => InferTypeInPostfixUnaryExpression(postfixUnary, token),
PrefixUnaryExpressionSyntax prefixUnary => InferTypeInPrefixUnaryExpression(prefixUnary, token),
RelationalPatternSyntax relationalPattern => InferTypeInRelationalPattern(relationalPattern),
ReturnStatementSyntax returnStatement => InferTypeForReturnStatement(returnStatement, token),
SingleVariableDesignationSyntax singleVariableDesignationSyntax => InferTypeForSingleVariableDesignation(singleVariableDesignationSyntax),
SwitchLabelSyntax switchLabel => InferTypeInSwitchLabel(switchLabel, token),
SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token),
ThrowStatementSyntax throwStatement => InferTypeInThrowStatement(throwStatement, token),
TupleExpressionSyntax tupleExpression => InferTypeInTupleExpression(tupleExpression, token),
UnaryPatternSyntax unaryPattern => GetPatternTypes(unaryPattern),
UsingStatementSyntax usingStatement => InferTypeInUsingStatement(usingStatement, token),
WhenClauseSyntax whenClause => InferTypeInWhenClause(whenClause, token),
WhileStatementSyntax whileStatement => InferTypeInWhileStatement(whileStatement, token),
YieldStatementSyntax yieldStatement => InferTypeInYieldStatement(yieldStatement, token),
_ => SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>(),
};

We should make sure there is a single method of the two that have this switch expression, and should make sure that cases from both are handled.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 24, 2022
@mavasani mavasani added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Concept-Design Debt Engineering Debt, Design Debt, or poor product code quality good first issue The issue is reserved for a first time, non-Microsoft contributor and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 19, 2023
@mavasani mavasani added this to the Backlog milestone Oct 19, 2023
@vibeeshan025
Copy link
Contributor

New to Roslyn's contribution. Shall I work on this?

@CyrusNajmabadi
Copy link
Member

Sure. You could work on this!

vibeeshan025 pushed a commit to vibeeshan025/roslyn that referenced this issue Dec 25, 2023
vibeeshan025 pushed a commit to vibeeshan025/roslyn that referenced this issue Dec 26, 2023
vibeeshan025 pushed a commit to vibeeshan025/roslyn that referenced this issue Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Design Debt Engineering Debt, Design Debt, or poor product code quality good first issue The issue is reserved for a first time, non-Microsoft contributor help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants