Cleanup usage of BoundBinaryOperator.Method API#80942
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.
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.
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.
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.
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.
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; |
BoundBinaryOperator.Methodis replaced with two APIs:Closes #78628.