forked from qt-creator/qt-creator
Fix crashes when typing code
Problem was with cyclic recurrence. To solve it we need to check if derived class is different class than its base class. Keep completion corrected. Include some unit tests when base class has the same name as derived. Task-number: QTCREATORBUG-7887 Change-Id: I7973c0b06e3b62d2da3d06048f4327d18a0b8011 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
committed by
hjk
parent
b02e954eff
commit
7e9913f0f5
@@ -789,15 +789,37 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
|
||||
return instantiation;
|
||||
}
|
||||
|
||||
if (allBases.isEmpty() || allBases.size() == knownUsings.size())
|
||||
return reference;
|
||||
|
||||
QList<const Name *> fullyQualifiedNameForReferenceClass =
|
||||
LookupContext::fullyQualifiedName(referenceClass);
|
||||
// Find the missing bases for regular (non-template) types.
|
||||
// Ex.: class A : public B<Some>::Type {};
|
||||
foreach (const Name *baseName, allBases) {
|
||||
ClassOrNamespace *binding = this;
|
||||
if (const QualifiedNameId *qBaseName = baseName->asQualifiedNameId()) {
|
||||
QList<const Name *> fullyQualifiedNameForBaseClass;
|
||||
addNames(baseName, &fullyQualifiedNameForBaseClass);
|
||||
if (compareFullyQualifiedName(fullyQualifiedNameForReferenceClass,
|
||||
fullyQualifiedNameForBaseClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const Name *qualification = qBaseName->base())
|
||||
binding = lookupType(qualification);
|
||||
else if (binding->parent() != 0)
|
||||
//if this is global identifier we take global namespace
|
||||
//Ex: class A{}; namespace NS { class A: public ::A{}; }
|
||||
binding = binding->globalNamespace();
|
||||
else
|
||||
//if we are in the global scope
|
||||
continue;
|
||||
baseName = qBaseName->name();
|
||||
}
|
||||
else if (compareName(name, baseName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (binding) {
|
||||
ClassOrNamespace * baseBinding = binding->lookupType(baseName);
|
||||
@@ -806,7 +828,6 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user