-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cleanup usage of BoundBinaryOperator.Method API #80942
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
Conversation
`BoundBinaryOperator.Method` is replaced with two APIs: - BinaryOperatorMethod - LeftTruthOperatorMethod Closes dotnet#78628.
| method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator } || | ||
| method.ParameterCount == 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be simplified to the following?
| method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator } || | |
| method.ParameterCount == 2); | |
| method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator, ParameterCount: 2 }); | |
| ``` #Resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be simplified to the following?
Suggested code is not semantically equivalent. Lowering can use String.Concat methods for string concatenation scenarios, but they are not operators
| BoundBinaryOperator binary => binary.Update( | ||
| binary.OperatorKind, | ||
| binary.Data?.WithUpdatedMethod(GetUpdatedSymbol(binary, binary.Method)), | ||
| binary.Data?.WithUpdatedMethod(GetUpdatedSymbol(binary, binary.BinaryOperatorMethod)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it guaranteed that the binary won't be dynamic here? If yes, should that be asserted? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it guaranteed that the
binarywon't be dynamic here? If yes, should that be asserted?
Probably not and we don't need to make this assumption here. Usage of the truth operator by compiler is unspecified and, at the moment, is not subject for nullable analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the same time, I guess, we could avoid "erasing" the truth operator information, even though it is not used by SemanticModel.
|
@dotnet/roslyn-compiler For a second review |
| operatorMethod = null; | ||
| } | ||
| MethodSymbol? binaryOperatorMethod = boundBinaryOperator.BinaryOperatorMethod; | ||
| MethodSymbol? unaryOperatorMethod = boundBinaryOperator.LeftTruthOperatorMethod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes me happy 🙂.
BoundBinaryOperator.Methodis replaced with two APIs:Closes #78628.