def _symbol_lookup(self, nestedName: ASTNestedName, templateDecls: List[Any], onMissingQualifiedSymbol: Callable[(['Symbol', Union[(ASTIdentifier, ASTOperator)], Any, ASTTemplateArgs], 'Symbol')], strictTemplateParamArgLists: bool, ancestorLookupType: str, templateShorthand: bool, matchSelf: bool, recurseInAnon: bool, correctPrimaryTemplateArgs: bool, searchInSiblings: bool) -> SymbolLookupResult:
    if Symbol.debug_lookup:
        Symbol.debug_indent += 1
        Symbol.debug_print('_symbol_lookup:')
        Symbol.debug_indent += 1
        Symbol.debug_print('self:')
        print(self.to_string((Symbol.debug_indent + 1)), end='')
        Symbol.debug_print('nestedName:        ', nestedName)
        Symbol.debug_print('templateDecls:     ', templateDecls)
        Symbol.debug_print('strictTemplateParamArgLists:', strictTemplateParamArgLists)
        Symbol.debug_print('ancestorLookupType:', ancestorLookupType)
        Symbol.debug_print('templateShorthand: ', templateShorthand)
        Symbol.debug_print('matchSelf:         ', matchSelf)
        Symbol.debug_print('recurseInAnon:     ', recurseInAnon)
        Symbol.debug_print('correctPrimaryTemplateArgs: ', correctPrimaryTemplateArgs)
        Symbol.debug_print('searchInSiblings:  ', searchInSiblings)
    if strictTemplateParamArgLists:
        assert ((nestedName.num_templates() == len(templateDecls)) or ((nestedName.num_templates() + 1) == len(templateDecls)))
    else:
        assert (len(templateDecls) <= (nestedName.num_templates() + 1))
    names = nestedName.names
    parentSymbol = self
    if nestedName.rooted:
        while parentSymbol.parent:
            parentSymbol = parentSymbol.parent
    if (ancestorLookupType is not None):
        firstName = names[0]
        if (not firstName.is_operator()):
            while parentSymbol.parent:
                if parentSymbol.find_identifier(firstName.identOrOp, matchSelf=matchSelf, recurseInAnon=recurseInAnon, searchInSiblings=searchInSiblings):
                    if ((len(names) == 1) and (ancestorLookupType == 'class') and matchSelf and parentSymbol.parent and (parentSymbol.parent.identOrOp == firstName.identOrOp)):
                        pass
                    else:
                        break
                parentSymbol = parentSymbol.parent
    if Symbol.debug_lookup:
        Symbol.debug_print('starting point:')
        print(parentSymbol.to_string((Symbol.debug_indent + 1)), end='')
    iTemplateDecl = 0
    for name in names[:(- 1)]:
        identOrOp = name.identOrOp
        templateArgs = name.templateArgs
        if strictTemplateParamArgLists:
            if templateArgs:
                assert (iTemplateDecl < len(templateDecls))
                templateParams = templateDecls[iTemplateDecl]
                iTemplateDecl += 1
            else:
                templateParams = None
        elif (templateArgs and (iTemplateDecl < len(templateDecls))):
            templateParams = templateDecls[iTemplateDecl]
            iTemplateDecl += 1
        else:
            templateParams = None
        symbol = parentSymbol._find_first_named_symbol(identOrOp, templateParams, templateArgs, templateShorthand=templateShorthand, matchSelf=matchSelf, recurseInAnon=recurseInAnon, correctPrimaryTemplateArgs=correctPrimaryTemplateArgs)
        if (symbol is None):
            symbol = onMissingQualifiedSymbol(parentSymbol, identOrOp, templateParams, templateArgs)
            if (symbol is None):
                if Symbol.debug_lookup:
                    Symbol.debug_indent -= 2
                return None
        matchSelf = False
        parentSymbol = symbol
    if Symbol.debug_lookup:
        Symbol.debug_print('handle last name from:')
        print(parentSymbol.to_string((Symbol.debug_indent + 1)), end='')
    name = names[(- 1)]
    identOrOp = name.identOrOp
    templateArgs = name.templateArgs
    if (iTemplateDecl < len(templateDecls)):
        assert ((iTemplateDecl + 1) == len(templateDecls))
        templateParams = templateDecls[iTemplateDecl]
    else:
        assert (iTemplateDecl == len(templateDecls))
        templateParams = None
    symbols = parentSymbol._find_named_symbols(identOrOp, templateParams, templateArgs, templateShorthand=templateShorthand, matchSelf=matchSelf, recurseInAnon=recurseInAnon, correctPrimaryTemplateArgs=False, searchInSiblings=searchInSiblings)
    if Symbol.debug_lookup:
        symbols = list(symbols)
        Symbol.debug_indent -= 2
    return SymbolLookupResult(symbols, parentSymbol, identOrOp, templateParams, templateArgs)
def _symbol_lookup(self, nestedName: ASTNestedName, templateDecls: List[Any], onMissingQualifiedSymbol: Callable[(['Symbol', Union[(ASTIdentifier, ASTOperator)], Any, ASTTemplateArgs], 'Symbol')], strictTemplateParamArgLists: bool, ancestorLookupType: str, templateShorthand: bool, matchSelf: bool, recurseInAnon: bool, correctPrimaryTemplateArgs: bool, searchInSiblings: bool) -> SymbolLookupResult:
    if Symbol.debug_lookup:
        Symbol.debug_indent += 1
        Symbol.debug_print('_symbol_lookup:')
        Symbol.debug_indent += 1
        Symbol.debug_print('self:')
        print(self.to_string((Symbol.debug_indent + 1)), end=)
        Symbol.debug_print('nestedName:        ', nestedName)
        Symbol.debug_print('templateDecls:     ', templateDecls)
        Symbol.debug_print('strictTemplateParamArgLists:', strictTemplateParamArgLists)
        Symbol.debug_print('ancestorLookupType:', ancestorLookupType)
        Symbol.debug_print('templateShorthand: ', templateShorthand)
        Symbol.debug_print('matchSelf:         ', matchSelf)
        Symbol.debug_print('recurseInAnon:     ', recurseInAnon)
        Symbol.debug_print('correctPrimaryTemplateArgs: ', correctPrimaryTemplateArgs)
        Symbol.debug_print('searchInSiblings:  ', searchInSiblings)
    if strictTemplateParamArgLists:
        assert ((nestedName.num_templates() == len(templateDecls)) or ((nestedName.num_templates() + 1) == len(templateDecls)))
    else:
        assert (len(templateDecls) <= (nestedName.num_templates() + 1))
    names = nestedName.names
    parentSymbol = self
    if nestedName.rooted:
        while parentSymbol.parent:
            parentSymbol = parentSymbol.parent
    if (ancestorLookupType is not None):
        firstName = names[0]
        if (not firstName.is_operator()):
            while parentSymbol.parent:
                if parentSymbol.find_identifier(firstName.identOrOp, matchSelf=matchSelf, recurseInAnon=recurseInAnon, searchInSiblings=searchInSiblings):
                    if ((len(names) == 1) and (ancestorLookupType == 'class') and matchSelf and parentSymbol.parent and (parentSymbol.parent.identOrOp == firstName.identOrOp)):
                        pass
                    else:
                        break
                parentSymbol = parentSymbol.parent
    if Symbol.debug_lookup:
        Symbol.debug_print('starting point:')
        print(parentSymbol.to_string((Symbol.debug_indent + 1)), end=)
    iTemplateDecl = 0
    for name in names[:(- 1)]:
        identOrOp = name.identOrOp
        templateArgs = name.templateArgs
        if strictTemplateParamArgLists:
            if templateArgs:
                assert (iTemplateDecl < len(templateDecls))
                templateParams = templateDecls[iTemplateDecl]
                iTemplateDecl += 1
            else:
                templateParams = None
        elif (templateArgs and (iTemplateDecl < len(templateDecls))):
            templateParams = templateDecls[iTemplateDecl]
            iTemplateDecl += 1
        else:
            templateParams = None
        symbol = parentSymbol._find_first_named_symbol(identOrOp, templateParams, templateArgs, templateShorthand=templateShorthand, matchSelf=matchSelf, recurseInAnon=recurseInAnon, correctPrimaryTemplateArgs=correctPrimaryTemplateArgs)
        if (symbol is None):
            symbol = onMissingQualifiedSymbol(parentSymbol, identOrOp, templateParams, templateArgs)
            if (symbol is None):
                if Symbol.debug_lookup:
                    Symbol.debug_indent -= 2
                return None
        matchSelf = False
        parentSymbol = symbol
    if Symbol.debug_lookup:
        Symbol.debug_print('handle last name from:')
        print(parentSymbol.to_string((Symbol.debug_indent + 1)), end=)
    name = names[(- 1)]
    identOrOp = name.identOrOp
    templateArgs = name.templateArgs
    if (iTemplateDecl < len(templateDecls)):
        assert ((iTemplateDecl + 1) == len(templateDecls))
        templateParams = templateDecls[iTemplateDecl]
    else:
        assert (iTemplateDecl == len(templateDecls))
        templateParams = None
    symbols = parentSymbol._find_named_symbols(identOrOp, templateParams, templateArgs, templateShorthand=templateShorthand, matchSelf=matchSelf, recurseInAnon=recurseInAnon, correctPrimaryTemplateArgs=False, searchInSiblings=searchInSiblings)
    if Symbol.debug_lookup:
        symbols = list(symbols)
        Symbol.debug_indent -= 2
    return SymbolLookupResult(symbols, parentSymbol, identOrOp, templateParams, templateArgs)