Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

BoundBinaryOperator.Method is replaced with two APIs:

  • BinaryOperatorMethod
  • LeftTruthOperatorMethod

Closes #78628.

`BoundBinaryOperator.Method` is replaced with two APIs:
- BinaryOperatorMethod
- LeftTruthOperatorMethod

Closes dotnet#78628.
@AlekseyTs AlekseyTs requested a review from a team as a code owner October 28, 2025 22:27
Comment on lines 75 to 76
method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator } ||
method.ParameterCount == 2);
Copy link
Member

@jjonescz jjonescz Oct 29, 2025

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 change
method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator } ||
method.ParameterCount == 2);
method is ErrorMethodSymbol { ParameterCount: 0 } or { MethodKind: MethodKind.UserDefinedOperator, ParameterCount: 2 });
``` #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.

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)),
Copy link
Member

@jjonescz jjonescz Oct 29, 2025

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

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 guaranteed that the binary won'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.

Copy link
Contributor Author

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.

@AlekseyTs AlekseyTs requested review from a team and jjonescz October 29, 2025 14:34
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For a second review

operatorMethod = null;
}
MethodSymbol? binaryOperatorMethod = boundBinaryOperator.BinaryOperatorMethod;
MethodSymbol? unaryOperatorMethod = boundBinaryOperator.LeftTruthOperatorMethod;
Copy link
Member

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 🙂.

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.

BoundBinaryOperator.Method is not a binary operator symbol for node created by BindDynamicBinaryOperator

3 participants