QmlJSCheck: Add Error message for recursively instantiated type

Change-Id: I68b46a929c65fb21ee8473cda44f7de4e40009c7
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2020-06-04 15:45:08 +02:00
parent 083b02377d
commit afb499a138
3 changed files with 6 additions and 0 deletions

View File

@@ -942,6 +942,9 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
if (checkTypeForDesignerSupport(typeId)) if (checkTypeForDesignerSupport(typeId))
addMessage(WarnUnsupportedTypeInVisualDesigner, typeErrorLocation, typeName); addMessage(WarnUnsupportedTypeInVisualDesigner, typeErrorLocation, typeName);
if (QFileInfo(_doc->fileName()).baseName() == getRightMostIdentifier(typeId)->name.toString())
addMessage(ErrTypeIsInstantiatedRecursively, typeErrorLocation, typeName);
if (checkTypeForQmlUiSupport(typeId)) if (checkTypeForQmlUiSupport(typeId))
addMessage(ErrUnsupportedTypeInQmlUi, typeErrorLocation, typeName); addMessage(ErrUnsupportedTypeInQmlUi, typeErrorLocation, typeName);

View File

@@ -245,6 +245,8 @@ StaticAnalysisMessages::StaticAnalysisMessages()
tr("Duplicate import (%1)."), 1); tr("Duplicate import (%1)."), 1);
newMsg(ErrHitMaximumRecursion, Error, newMsg(ErrHitMaximumRecursion, Error,
tr("Hit maximum recursion limit when visiting AST.")); tr("Hit maximum recursion limit when visiting AST."));
newMsg(ErrTypeIsInstantiatedRecursively, Error,
tr("Type cannot be instantiated recursively (%1)."), 1);
} }
} // anonymous namespace } // anonymous namespace

View File

@@ -89,6 +89,7 @@ enum Type
MaybeWarnEqualityTypeCoercion = 126, MaybeWarnEqualityTypeCoercion = 126,
WarnConfusingExpressionStatement = 127, WarnConfusingExpressionStatement = 127,
StateCannotHaveChildItem = 128, StateCannotHaveChildItem = 128,
ErrTypeIsInstantiatedRecursively = 129,
HintDeclarationsShouldBeAtStartOfFunction = 201, HintDeclarationsShouldBeAtStartOfFunction = 201,
HintOneStatementPerLine = 202, HintOneStatementPerLine = 202,
WarnImperativeCodeNotEditableInVisualDesigner = 203, WarnImperativeCodeNotEditableInVisualDesigner = 203,