(expr *ast.BinaryExpression)
| 2664 | } |
| 2665 | |
| 2666 | func isNarrowingBinaryExpression(expr *ast.BinaryExpression) bool { |
| 2667 | switch expr.OperatorToken.Kind { |
| 2668 | case ast.KindEqualsToken, ast.KindBarBarEqualsToken, ast.KindAmpersandAmpersandEqualsToken, ast.KindQuestionQuestionEqualsToken: |
| 2669 | return containsNarrowableReference(expr.Left) |
| 2670 | case ast.KindEqualsEqualsToken, ast.KindExclamationEqualsToken, ast.KindEqualsEqualsEqualsToken, ast.KindExclamationEqualsEqualsToken: |
| 2671 | left := ast.SkipParentheses(expr.Left) |
| 2672 | right := ast.SkipParentheses(expr.Right) |
| 2673 | return isNarrowableOperand(left) || isNarrowableOperand(right) || |
| 2674 | isNarrowingTypeOfOperands(right, left) || isNarrowingTypeOfOperands(left, right) || |
| 2675 | (ast.IsBooleanLiteral(right) && isNarrowingExpression(left) || ast.IsBooleanLiteral(left) && isNarrowingExpression(right)) |
| 2676 | case ast.KindInstanceOfKeyword: |
| 2677 | return isNarrowableOperand(expr.Left) |
| 2678 | case ast.KindInKeyword: |
| 2679 | return isNarrowingExpression(expr.Right) |
| 2680 | case ast.KindCommaToken: |
| 2681 | return isNarrowingExpression(expr.Right) |
| 2682 | } |
| 2683 | return false |
| 2684 | } |
| 2685 | |
| 2686 | func isNarrowableOperand(expr *ast.Node) bool { |
| 2687 | switch expr.Kind { |
no test coverage detected