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 init-only: Conversions in init-only phase #50770

Merged
merged 4 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions src/Compilers/VisualBasic/Portable/Symbols/PropertySymbol.vb
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,34 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return False
End If

Select Case receiverOpt.Kind
Case BoundKind.WithLValueExpressionPlaceholder
' This can be a `Me` reference used as a target for a `With` statement
Dim currentBinder As Binder = containingBinder

While currentBinder IsNot Nothing AndAlso currentBinder.ContainingMember Is containingMember
Dim withBlockBinder = TryCast(currentBinder, WithBlockBinder)
If withBlockBinder IsNot Nothing Then
Return withBlockBinder.Info?.ExpressionPlaceholder Is receiverOpt AndAlso
withBlockBinder.Info.OriginalExpression.Kind = BoundKind.MeReference
If receiverOpt.Kind = BoundKind.WithLValueExpressionPlaceholder OrElse receiverOpt.Kind = BoundKind.WithRValueExpressionPlaceholder Then
' This can be a reference used as a target for a `With` statement
Dim currentBinder As Binder = containingBinder

While currentBinder IsNot Nothing AndAlso currentBinder.ContainingMember Is containingMember
Dim withBlockBinder = TryCast(currentBinder, WithBlockBinder)
If withBlockBinder IsNot Nothing Then
If withBlockBinder.Info?.ExpressionPlaceholder Is receiverOpt Then
receiverOpt = withBlockBinder.Info.OriginalExpression
End If

currentBinder = currentBinder.ContainingBinder
End While
Exit While
End If

Return False
currentBinder = currentBinder.ContainingBinder
End While
End If

Case BoundKind.MeReference, BoundKind.MyBaseReference, BoundKind.MyClassReference
Return True
Case Else
Return False
End Select
Do
Select Case receiverOpt.Kind
Case BoundKind.MeReference, BoundKind.MyBaseReference, BoundKind.MyClassReference
Return True
Case BoundKind.Parenthesized
Copy link
Member

@jcouv jcouv Jan 28, 2021

Choose a reason for hiding this comment

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

Looks like this fixes the handling for parenthesized receiver in With. Do we have a test for that case? #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.

Looks like this fixes the handling for parenthesized receiver in With. Do we have a test for that case?

EvaluationInitOnlySetter_10


In reply to: 566277477 [](ancestors = 566277477)

receiverOpt = DirectCast(receiverOpt, BoundParenthesized).Expression
Case Else
Return False
End Select
Loop
End If

Dim sourceProperty As SourcePropertySymbol = TryCast(Me, SourcePropertySymbol)
Expand Down
Loading