diff --git a/duchain/builders/typebuilder.cpp b/duchain/builders/typebuilder.cpp --- a/duchain/builders/typebuilder.cpp +++ b/duchain/builders/typebuilder.cpp @@ -514,12 +514,15 @@ if (classDec->isPublicBaseClass(iteratorDecl, currentContext()->topContext())) { /// Qualified identifier for 'current' static const QualifiedIdentifier currentQId(QStringLiteral("current")); - foreach (Declaration *d, classDec->internalContext()->findDeclarations(currentQId)) { - if (!dynamic_cast(d)) continue; - Q_ASSERT(d->type()); - injectType(d->type()->returnType()); - foundType = true; - // qCDebug(DUCHAIN) << "that's it: " << d->type()->returnType()->toString(); + auto classContext = classDec->internalContext(); + if (classContext) { + foreach (Declaration *d, classContext->findDeclarations(currentQId)) { + if (!dynamic_cast(d)) continue; + Q_ASSERT(d->type()); + injectType(d->type()->returnType()); + foundType = true; + // qCDebug(DUCHAIN) << "that's it: " << d->type()->returnType()->toString(); + } } } }