visitBinaryExpression method
void
visitBinaryExpression(
- BinaryExpression node
)
override
Implementation
@override
void visitBinaryExpression(BinaryExpression node) {
final expression = node.rightOperand;
if (expression.isDotShorthand) return;
_checkAndReport(
expression: expression,
declaredType: switch (node) {
BinaryExpression(operator: Token(lexeme: '==')) ||
BinaryExpression(
operator: Token(lexeme: '!='),
) => node.leftOperand.staticType,
BinaryExpression(operator: Token(lexeme: '??')) =>
// For ?? operator, try to get context type from parent
// If in argument position: use parameter type
// If in return/assignment: use declared type
// Otherwise fallback to left operand type
node.correspondingParameter?.type ??
node.findDeclaredType() ??
node.leftOperand.staticType,
_ => node.rightOperand.correspondingParameter?.type,
},
);
}