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

Fix crash in 'use collection initializer' #75242

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #75214

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner September 25, 2024 19:49
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 25, 2024
@@ -94,8 +93,35 @@ public AbstractSpeculationAnalyzer(
}

protected abstract ISyntaxFacts SyntaxFactsService { get; }

protected abstract SyntaxNode GetSemanticRootForSpeculation(TExpressionSyntax expression);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moved all the abstract methods to the top of the file.

protected abstract TExpressionSyntax GetForEachStatementExpression(TForEachStatementSyntax forEachStatement);
protected abstract bool IsForEachTypeInferred(TForEachStatementSyntax forEachStatement, SemanticModel semanticModel);
protected abstract bool ForEachConversionsAreCompatible(SemanticModel originalModel, TForEachStatementSyntax originalForEach, SemanticModel newModel, TForEachStatementSyntax newForEach);
protected abstract void GetForEachSymbols(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method changed to add more information back.

Dim info = model.GetForEachStatementInfo(forEach)
getEnumeratorMethod = info.GetEnumeratorMethod
elementType = info.ElementType
localVariables = ImmutableArray.Create(DirectCast(model.GetDeclaredSymbol(forEach), ILocalSymbol))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always safe in VB. it doesn't have deconstructions in foreach statements.

@CyrusNajmabadi
Copy link
Member Author

@akhera99 ptal :)

@CyrusNajmabadi CyrusNajmabadi merged commit 06fccd5 into dotnet:main Sep 26, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the useCollectionCrash branch September 26, 2024 17:10
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
2 participants