def _find_named_symbols(self, identOrOp: Union[(ASTIdentifier, ASTOperator)], templateParams: Any, templateArgs: ASTTemplateArgs, templateShorthand: bool, matchSelf: bool, recurseInAnon: bool, correctPrimaryTemplateArgs: bool, searchInSiblings: bool) -> Iterator['Symbol']:
    if Symbol.debug_lookup:
        Symbol.debug_indent += 1
        Symbol.debug_print('_find_named_symbols:')
        Symbol.debug_indent += 1
        Symbol.debug_print('self:')
        print(self.to_string((Symbol.debug_indent + 1)), end='')
        Symbol.debug_print('identOrOp:                  ', identOrOp)
        Symbol.debug_print('templateParams:             ', templateParams)
        Symbol.debug_print('templateArgs:               ', templateArgs)
        Symbol.debug_print('templateShorthand:          ', templateShorthand)
        Symbol.debug_print('matchSelf:                  ', matchSelf)
        Symbol.debug_print('recurseInAnon:              ', recurseInAnon)
        Symbol.debug_print('correctPrimaryTemplateAargs:', correctPrimaryTemplateArgs)
        Symbol.debug_print('searchInSiblings:           ', searchInSiblings)

    def isSpecialization() -> bool:
        if (len(templateParams.params) != len(templateArgs.args)):
            return True
        if (len(templateParams.params) == 0):
            return True
        for i in range(len(templateParams.params)):
            param = templateParams.params[i]
            arg = templateArgs.args[i]
            paramName = str(param.name)
            argTxt = str(arg)
            isArgPackExpansion = argTxt.endswith('...')
            if (param.isPack != isArgPackExpansion):
                return True
            argName = (argTxt[:(- 3)] if isArgPackExpansion else argTxt)
            if (paramName != argName):
                return True
        return False
    if correctPrimaryTemplateArgs:
        if ((templateParams is not None) and (templateArgs is not None)):
            if (not isSpecialization()):
                templateArgs = None

    def matches(s: 'Symbol') -> bool:
        if (s.identOrOp != identOrOp):
            return False
        if ((s.templateParams is None) != (templateParams is None)):
            if (templateParams is not None):
                return False
            if (not templateShorthand):
                return False
        if templateParams:
            if (str(s.templateParams) != str(templateParams)):
                return False
        if ((s.templateArgs is None) != (templateArgs is None)):
            return False
        if s.templateArgs:
            if (str(s.templateArgs) != str(templateArgs)):
                return False
        return True

    def candidates() -> Generator[(Symbol, None, None)]:
        s = self
        if Symbol.debug_lookup:
            Symbol.debug_print('searching in self:')
            print(s.to_string((Symbol.debug_indent + 1)), end='')
        while True:
            if matchSelf:
                (yield s)
            if recurseInAnon:
                (yield from s.children_recurse_anon)
            else:
                (yield from s._children)
            if (s.siblingAbove is None):
                break
            s = s.siblingAbove
            if Symbol.debug_lookup:
                Symbol.debug_print('searching in sibling:')
                print(s.to_string((Symbol.debug_indent + 1)), end='')
    for s in candidates():
        if Symbol.debug_lookup:
            Symbol.debug_print('candidate:')
            print(s.to_string((Symbol.debug_indent + 1)), end='')
        if matches(s):
            if Symbol.debug_lookup:
                Symbol.debug_indent += 1
                Symbol.debug_print('matches')
                Symbol.debug_indent -= 3
            (yield s)
            if Symbol.debug_lookup:
                Symbol.debug_indent += 2
    if Symbol.debug_lookup:
        Symbol.debug_indent -= 2
def _find_named_symbols(self, identOrOp: Union[(ASTIdentifier, ASTOperator)], templateParams: Any, templateArgs: ASTTemplateArgs, templateShorthand: bool, matchSelf: bool, recurseInAnon: bool, correctPrimaryTemplateArgs: bool, searchInSiblings: bool) -> Iterator['Symbol']:
    if Symbol.debug_lookup:
        Symbol.debug_indent += 1
        Symbol.debug_print('_find_named_symbols:')
        Symbol.debug_indent += 1
        Symbol.debug_print('self:')
        print(self.to_string((Symbol.debug_indent + 1)), end=)
        Symbol.debug_print('identOrOp:                  ', identOrOp)
        Symbol.debug_print('templateParams:             ', templateParams)
        Symbol.debug_print('templateArgs:               ', templateArgs)
        Symbol.debug_print('templateShorthand:          ', templateShorthand)
        Symbol.debug_print('matchSelf:                  ', matchSelf)
        Symbol.debug_print('recurseInAnon:              ', recurseInAnon)
        Symbol.debug_print('correctPrimaryTemplateAargs:', correctPrimaryTemplateArgs)
        Symbol.debug_print('searchInSiblings:           ', searchInSiblings)

    def isSpecialization() -> bool:
        if (len(templateParams.params) != len(templateArgs.args)):
            return True
        if (len(templateParams.params) == 0):
            return True
        for i in range(len(templateParams.params)):
            param = templateParams.params[i]
            arg = templateArgs.args[i]
            paramName = str(param.name)
            argTxt = str(arg)
            isArgPackExpansion = argTxt.endswith('...')
            if (param.isPack != isArgPackExpansion):
                return True
            argName = (argTxt[:(- 3)] if isArgPackExpansion else argTxt)
            if (paramName != argName):
                return True
        return False
    if correctPrimaryTemplateArgs:
        if ((templateParams is not None) and (templateArgs is not None)):
            if (not isSpecialization()):
                templateArgs = None

    def matches(s: 'Symbol') -> bool:
        if (s.identOrOp != identOrOp):
            return False
        if ((s.templateParams is None) != (templateParams is None)):
            if (templateParams is not None):
                return False
            if (not templateShorthand):
                return False
        if templateParams:
            if (str(s.templateParams) != str(templateParams)):
                return False
        if ((s.templateArgs is None) != (templateArgs is None)):
            return False
        if s.templateArgs:
            if (str(s.templateArgs) != str(templateArgs)):
                return False
        return True

    def candidates() -> Generator[(Symbol, None, None)]:
        s = self
        if Symbol.debug_lookup:
            Symbol.debug_print('searching in self:')
            print(s.to_string((Symbol.debug_indent + 1)), end=)
        while True:
            if matchSelf:
                (yield s)
            if recurseInAnon:
                (yield from s.children_recurse_anon)
            else:
                (yield from s._children)
            if (s.siblingAbove is None):
                break
            s = s.siblingAbove
            if Symbol.debug_lookup:
                Symbol.debug_print('searching in sibling:')
                print(s.to_string((Symbol.debug_indent + 1)), end=)
    for s in candidates():
        if Symbol.debug_lookup:
            Symbol.debug_print('candidate:')
            print(s.to_string((Symbol.debug_indent + 1)), end=)
        if matches(s):
            if Symbol.debug_lookup:
                Symbol.debug_indent += 1
                Symbol.debug_print('matches')
                Symbol.debug_indent -= 3
            (yield s)
            if Symbol.debug_lookup:
                Symbol.debug_indent += 2
    if Symbol.debug_lookup:
        Symbol.debug_indent -= 2