(b *keyBuilder, node *ast.Node, declaredType *Type, initialType *Type, flowContainer *ast.Node)
| 1642 | } |
| 1643 | |
| 1644 | func (c *Checker) writeFlowCacheKey(b *keyBuilder, node *ast.Node, declaredType *Type, initialType *Type, flowContainer *ast.Node) bool { |
| 1645 | switch node.Kind { |
| 1646 | case ast.KindIdentifier: |
| 1647 | if !ast.IsThisInTypeQuery(node) { |
| 1648 | symbol := c.getResolvedSymbol(node) |
| 1649 | if symbol == c.unknownSymbol { |
| 1650 | return false |
| 1651 | } |
| 1652 | b.writeSymbol(symbol) |
| 1653 | } |
| 1654 | fallthrough |
| 1655 | case ast.KindThisKeyword: |
| 1656 | b.writeByte(':') |
| 1657 | b.writeType(declaredType) |
| 1658 | if initialType != declaredType { |
| 1659 | b.writeByte('=') |
| 1660 | b.writeType(initialType) |
| 1661 | } |
| 1662 | if flowContainer != nil { |
| 1663 | b.writeByte('@') |
| 1664 | b.writeNode(flowContainer) |
| 1665 | } |
| 1666 | return true |
| 1667 | case ast.KindNonNullExpression, ast.KindParenthesizedExpression: |
| 1668 | return c.writeFlowCacheKey(b, node.Expression(), declaredType, initialType, flowContainer) |
| 1669 | case ast.KindQualifiedName: |
| 1670 | if !c.writeFlowCacheKey(b, node.AsQualifiedName().Left, declaredType, initialType, flowContainer) { |
| 1671 | return false |
| 1672 | } |
| 1673 | b.writeByte('.') |
| 1674 | b.writeString(node.AsQualifiedName().Right.Text()) |
| 1675 | return true |
| 1676 | case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: |
| 1677 | if propName, ok := c.getAccessedPropertyName(node); ok { |
| 1678 | if !c.writeFlowCacheKey(b, node.Expression(), declaredType, initialType, flowContainer) { |
| 1679 | return false |
| 1680 | } |
| 1681 | b.writeByte('.') |
| 1682 | b.writeString(propName) |
| 1683 | return true |
| 1684 | } |
| 1685 | if ast.IsElementAccessExpression(node) && ast.IsIdentifier(node.AsElementAccessExpression().ArgumentExpression) { |
| 1686 | symbol := c.getResolvedSymbol(node.AsElementAccessExpression().ArgumentExpression) |
| 1687 | if c.isConstantVariable(symbol) || c.isParameterOrMutableLocalVariable(symbol) && !c.isSymbolAssigned(symbol) { |
| 1688 | if !c.writeFlowCacheKey(b, node.Expression(), declaredType, initialType, flowContainer) { |
| 1689 | return false |
| 1690 | } |
| 1691 | b.writeString(".@") |
| 1692 | b.writeSymbol(symbol) |
| 1693 | return true |
| 1694 | } |
| 1695 | } |
| 1696 | case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern, ast.KindFunctionDeclaration, |
| 1697 | ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindMethodDeclaration: |
| 1698 | b.writeNode(node) |
| 1699 | b.writeByte('#') |
| 1700 | b.writeType(declaredType) |
| 1701 | return true |
no test coverage detected