Commit 0ce3f3e6 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

C++: Ignore return type on function overrides comparison

Change-Id: I9933e1cc1fb996181e818e2ea0aff76f9255f849
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent a625d965
......@@ -222,27 +222,24 @@ int Function::methodKey() const
void Function::setMethodKey(int key)
{ f._methodKey = key; }
bool Function::isEqualTo(const Type *other) const
bool Function::isSignatureEqualTo(const Function *other) const
{
const Function *o = other->asFunctionType();
if (! o)
if (! other)
return false;
else if (isConst() != o->isConst())
else if (isConst() != other->isConst())
return false;
else if (isVolatile() != o->isVolatile())
else if (isVolatile() != other->isVolatile())
return false;
const Name *l = unqualifiedName();
const Name *r = o->unqualifiedName();
const Name *r = other->unqualifiedName();
if (l == r || (l && l->isEqualTo(r))) {
const unsigned argc = argumentCount();
if (argc != o->argumentCount())
return false;
else if (! _returnType.isEqualTo(o->_returnType))
if (argc != other->argumentCount())
return false;
for (unsigned i = 0; i < argc; ++i) {
Symbol *l = argumentAt(i);
Symbol *r = o->argumentAt(i);
Symbol *r = other->argumentAt(i);
if (! l->type().isEqualTo(r->type()))
return false;
}
......@@ -251,6 +248,14 @@ bool Function::isEqualTo(const Type *other) const
return false;
}
bool Function::isEqualTo(const Type *other) const
{
const Function *o = other->asFunctionType();
if (!isSignatureEqualTo(o))
return false;
return _returnType.isEqualTo(o->_returnType);
}
void Function::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
......
......@@ -347,6 +347,8 @@ public:
bool isPureVirtual() const;
void setPureVirtual(bool isPureVirtual);
bool isSignatureEqualTo(const Function *other) const;
// Symbol's interface
virtual FullySpecifiedType type() const;
......
......@@ -451,7 +451,6 @@ void TestCase::run()
expectedImmediate << OverrideItem(QLatin1String("...searching overrides"));
}
QCOMPARE(immediateVirtualSymbolResults, expectedImmediate);
QEXPECT_FAIL("differentReturnTypes", "Doesn't work", Abort);
QCOMPARE(finalVirtualSymbolResults, m_expectedVirtualFunctionProposal);
}
......
......@@ -144,11 +144,13 @@ QList<Symbol *> FunctionUtils::overrides(Function *function, Class *functionsCla
for (int i = 0, total = c->memberCount(); i < total; ++i) {
Symbol *candidate = c->memberAt(i);
const Name *candidateName = candidate->name();
const FullySpecifiedType candidateType = candidate->type();
if (!candidateName || !candidateType.isValid())
const Function *candidateFunc = candidate->type()->asFunctionType();
if (!candidateName || !candidateFunc)
continue;
if (candidateName->isEqualTo(referenceName) && candidateType.isEqualTo(referenceType))
if (candidateName->isEqualTo(referenceName)
&& candidateFunc->isSignatureEqualTo(function)) {
result << candidate;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment