forked from qt-creator/qt-creator
QmlJS: Soften strict equality check Pt III
Adapt to differences Qt5 vs Qt6. Fixes: QTCREATORBUG-25917 Change-Id: Ieee1cf0442016c62b82bd932dd62d0dc9a78bc26 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
This commit is contained in:
@@ -1295,7 +1295,17 @@ static bool isIntegerValue(const Value *value)
|
|||||||
if (value->asNumberValue() || value->asIntValue())
|
if (value->asNumberValue() || value->asIntValue())
|
||||||
return true;
|
return true;
|
||||||
if (auto obj = value->asObjectValue())
|
if (auto obj = value->asObjectValue())
|
||||||
return obj->className() == "Number";
|
return obj->className() == "Number" || obj->className() == "int";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isStringValue(const Value *value)
|
||||||
|
{
|
||||||
|
if (value->asStringValue())
|
||||||
|
return true;
|
||||||
|
if (auto obj = value->asObjectValue())
|
||||||
|
return obj->className() == "QString" || obj->className() == "string";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1311,6 +1321,8 @@ static bool strictCompareConstant(const Value *lhs, const Value *rhs)
|
|||||||
return false;
|
return false;
|
||||||
if (isIntegerValue(lhs) && isIntegerValue(rhs))
|
if (isIntegerValue(lhs) && isIntegerValue(rhs))
|
||||||
return false;
|
return false;
|
||||||
|
if (isStringValue(lhs) && isStringValue(rhs))
|
||||||
|
return false;
|
||||||
if (lhs->asBooleanValue() && !rhs->asBooleanValue())
|
if (lhs->asBooleanValue() && !rhs->asBooleanValue())
|
||||||
return true;
|
return true;
|
||||||
if (lhs->asNumberValue() && !rhs->asNumberValue())
|
if (lhs->asNumberValue() && !rhs->asNumberValue())
|
||||||
|
Reference in New Issue
Block a user