QmlJS: Fix more invalid M325 cases

Fixes: QTCREATORBUG-27380
Change-Id: I76d1ef3d2f2a4cc9d930a006ecb3b564efea3fbc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
This commit is contained in:
Christian Stenger
2022-04-13 13:11:57 +02:00
parent cf96a91b69
commit 9656eb9e7a
2 changed files with 19 additions and 1 deletions

View File

@@ -1306,7 +1306,17 @@ static bool isStringValue(const Value *value)
if (value->asStringValue())
return true;
if (auto obj = value->asObjectValue())
return obj->className() == "QString" || obj->className() == "string";
return obj->className() == "QString" || obj->className() == "string" || obj->className() == "String";
return false;
}
static bool isBooleanValue(const Value *value)
{
if (value->asBooleanValue())
return true;
if (auto obj = value->asObjectValue())
return obj->className() == "boolean" || obj->className() == "Boolean";
return false;
}
@@ -1324,6 +1334,8 @@ static bool strictCompareConstant(const Value *lhs, const Value *rhs)
return false;
if (isStringValue(lhs) && isStringValue(rhs))
return false;
if (isBooleanValue(lhs) && isBooleanValue(rhs))
return false;
if (lhs->asBooleanValue() && !rhs->asBooleanValue())
return true;
if (lhs->asNumberValue() && !rhs->asNumberValue())

View File

@@ -139,6 +139,12 @@ Rectangle {
if (nObj === 1) {}
if (nNum === 1) {}
var bObj = Boolean(1 > 0);
if (bObj === b) {}
var sBool = String(b);
if (sBool === s) {}
}
ListView {