qmllint: Don't dump imported enums into the current scope

This bit of code has never fulfilled any discernable function. Enum
access is done elsewhere. Add a test case to prove that access to enums
from QtQml's plugins.qmltypes still works.

Change-Id: I62fd6c1ec748c88205aa20367ee06d7a33502fa1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2020-09-24 10:06:26 +02:00
parent dbb0d83779
commit 229b24370b
4 changed files with 21 additions and 5 deletions

View File

@ -0,0 +1,6 @@
import QtQml
QtObject {
property int foo: Easing.Linear123
}

View File

@ -0,0 +1,8 @@
import QtQml
QtObject {
// Remarkably, Easing.Type.Linear is not allowed in QML
// This is in contrast to QML-declared enums. See EnumAccess2.qml
property int foo: Easing.Linear
}

View File

@ -189,7 +189,12 @@ void TestQmllint::dirtyQmlCode_data()
<< QString();
QTest::newRow("javascriptMethodsInModule")
<< QStringLiteral("javascriptMethodsInModuleBad.qml")
<< QString("Warning: Property \"unknownFunc\" not found on type \"Foo\"") << QString();
<< QString("Warning: Property \"unknownFunc\" not found on type \"Foo\"")
<< QString();
QTest::newRow("badEnumFromQtQml")
<< QStringLiteral("badEnumFromQtQml.qml")
<< QString("Warning: Property \"Linear123\" not found on type \"QQmlEasingEnums\"")
<< QString();
}
void TestQmllint::dirtyQmlCode()
@ -236,6 +241,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("Signals") << QStringLiteral("Signal.qml");
QTest::newRow("javascriptMethodsInModule")
<< QStringLiteral("javascriptMethodsInModuleGood.qml");
QTest::newRow("enumFromQtQml") << QStringLiteral("enumFromQtQml.qml");
}
void TestQmllint::cleanQmlCode()

View File

@ -164,10 +164,6 @@ void FindWarningVisitor::processImport(
const auto exports = val->exports();
for (const auto &valExport : exports)
m_exportedName2Scope.insert(prefixedName(prefix, valExport.type()), val);
const auto enums = val->enums();
for (const auto &valEnum : enums)
m_currentScope->addEnum(valEnum);
}
}