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

VB: Align design around speculative semantic models with C#. #64751

Merged
merged 3 commits into from
Oct 18, 2022

Conversation

AlekseyTs
Copy link
Contributor

This is a follow-up for #64634

@AlekseyTs AlekseyTs requested a review from a team as a code owner October 15, 2022 00:56
@@ -129,7 +129,7 @@ internal sealed class SpeculativeSemanticModelWithMemberModel : PublicSemanticMo

public override bool IgnoresAccessibility => _parentSemanticModel.IgnoresAccessibility;

internal sealed override SemanticModel ContainingModelOrSelf => this;
internal sealed override SemanticModel ContainingPublicModelOrSelf => this;
Copy link
Member

@jcouv jcouv Oct 17, 2022

Choose a reason for hiding this comment

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

Feels like this should be moved up into PublicSemanticModel and sealed there. #Pending

Debug.Assert(semanticModel.ContainingModelOrSelf.ContainingModelOrSelf == semanticModel.ContainingModelOrSelf);
}
Debug.Assert(semanticModel.ContainingPublicModelOrSelf != null);
Debug.Assert(semanticModel.ContainingPublicModelOrSelf != semanticModel);
Copy link
Member

@jcouv jcouv Oct 17, 2022

Choose a reason for hiding this comment

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

nit: Is it actually important that this not be a public semantic model? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it actually important that this not be a public semantic model?

I think implementation actually depends on that somewhere. I don't remember exact details, but, for example, operation nodes are cached by the internal semantic model. In any case, this was a legacy behavior and I do not intend to change it in this PR.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 2) with minor comments to consider

@jcouv jcouv self-assigned this Oct 17, 2022
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review


Private Sub New(parentSemanticModel As SyntaxTreeSemanticModel,
speculatedPosition As Integer)
Debug.Assert(Not parentSemanticModel.IsSpeculativeSemanticModel, VBResources.ChainingSpeculativeModelIsNotSupported)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I don't think we should use a localized resource for a debug.assert. If it fails on the spanish test leg, we'll get a spanish assert message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: I don't think we should use a localized resource for a debug.assert. If it fails on the spanish test leg, we'll get a spanish assert message.

This is an adjusted copy of an original assert (definitely impossible conditions were removed).
Debug.Assert(parentSemanticModelOpt Is Nothing OrElse Not parentSemanticModelOpt.IsSpeculativeSemanticModel, VBResources.ChainingSpeculativeModelIsNotSupported)

I'll leave the code as is, it is unlikely the assert will fail only on spanish leg, and, even if that happens, there will be a call stack clearly pointing at the root cause. Most of our asserts do not include any clarifying messages.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 3), with a small suggestion.

@AlekseyTs AlekseyTs merged commit 3f694a3 into dotnet:main Oct 18, 2022
@ghost ghost added this to the Next milestone Oct 18, 2022
@RikkiGibson RikkiGibson modified the milestones: Next, 17.5 P1 Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants