From 06577c9e80eb150b6b9e76e7805bfed1abbae82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20De=20Canni=C3=A8re?= Date: Wed, 21 Aug 2024 13:45:14 +0200 Subject: Compiler: Only warn about missing type annotation once per function Change-Id: I6f9788c906158e549e57c04223ae10d5a789ecec Reviewed-by: Sami Shalayel Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljsfunctioninitializer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp') diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index a767da68b6..1c90167691 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -80,6 +80,7 @@ void QQmlJSFunctionInitializer::populateSignature( function->isFullyTyped = !arguments.isEmpty() || ast->typeAnnotation; if (function->argumentTypes.isEmpty()) { + bool alreadyWarnedAboutMissingAnnotations = false; for (const QQmlJS::AST::BoundName &argument : std::as_const(arguments)) { if (argument.typeAnnotation) { if (const auto type = m_typeResolver->typeFromAST(argument.typeAnnotation->type)) { @@ -94,10 +95,13 @@ void QQmlJSFunctionInitializer::populateSignature( .arg(argument.typeAnnotation->type->toString())); } } else { - function->argumentTypes.append( - m_typeResolver->tracked( - m_typeResolver->globalType(m_typeResolver->varType()))); - signatureError(u"Functions without type annotations won't be compiled"_s); + if (!alreadyWarnedAboutMissingAnnotations) { + alreadyWarnedAboutMissingAnnotations = true; + function->argumentTypes.append( + m_typeResolver->tracked( + m_typeResolver->globalType(m_typeResolver->varType()))); + signatureError(u"Functions without type annotations won't be compiled"_s); + } } } } else { -- cgit v1.2.3