diff --git a/duchain/builders/declarationbuilder.cpp b/duchain/builders/declarationbuilder.cpp --- a/duchain/builders/declarationbuilder.cpp +++ b/duchain/builders/declarationbuilder.cpp @@ -931,17 +931,19 @@ const QualifiedIdentifier& identifier, AstNode* node) { + DUChainWriteLocker lock(DUChain::lock()); + // we must not re-assign $this in a class context /// Qualified identifier for 'this' static const QualifiedIdentifier thisQId(QStringLiteral("this")); if ( identifier == thisQId && currentContext()->parentContext() && currentContext()->parentContext()->type() == DUContext::Class ) { - + // checks if imports \ArrayAccess ClassDeclaration* currentClass = dynamic_cast(currentContext()->parentContext()->owner()); ClassDeclaration* arrayAccess = nullptr; - + auto imports = currentContext()->parentContext()->importedParentContexts(); for( const DUContext::Import& ctx : imports ) { DUContext* import = ctx.context(topContext()); @@ -954,9 +956,9 @@ } } } - + IntegralType* thisVar = static_cast(type.data()); - // check if this is used as array + // check if this is used as array if(arrayAccess && currentClass && thisVar && thisVar->dataType() == AbstractType::TypeArray) { uint noOfFunc = 0; @@ -971,23 +973,21 @@ } } } - + if(noOfFunc < 4) { // check if class is not abstract if(currentClass->classModifier() != ClassDeclarationData::ClassModifier::Abstract) { reportError(i18n("Class %1 contains %2 abstract methods and must therefore be declared abstract or implement the remaining methods.",currentClass->prettyName().str(),4-noOfFunc), QList() << node); } } - + return; } - + reportError(i18n("Cannot re-assign $this."), QList() << node); return; } - DUChainWriteLocker lock(DUChain::lock()); - const RangeInRevision newRange = editorFindRange(node, node); // check if this variable is already declared