1 From: Friedemann Kleint <Friedemann.Kleint@qt.io>
2 Date: Thu, 27 Apr 2023 13:00:37 +0200
3 Subject: shiboken2/clang: Suppress class scope look up for parameters with
6 Add a flag to AbstractMetaBuilderPrivate::findTypeEntriesHelper()
7 to suppress the class scope look in case scope resolution.
9 Task-number: PYSIDE-2288
11 Change-Id: I04a4810d03845fb48393c5efed3641220bd12d87
12 Reviewed-by: Christian Tismer <tismer@stackless.com>
14 sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 16 ++++++++++++----
15 sources/shiboken2/ApiExtractor/abstractmetabuilder.h | 3 ++-
16 sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h | 1 +
17 3 files changed, 15 insertions(+), 5 deletions(-)
19 diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
20 index 2f34e16..4bf4ab4 100644
21 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
22 +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
23 @@ -1845,7 +1845,10 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
27 - AbstractMetaType *type = translateType(returnType, currentClass, {}, &errorMessage);
28 + TranslateTypeFlags flags;
29 + if (functionItem->scopeResolution())
30 + flags.setFlag(AbstractMetaBuilder::NoClassScopeLookup);
31 + AbstractMetaType *type = translateType(returnType, currentClass, flags, &errorMessage);
33 const QString reason = msgUnmatchedReturnType(functionItem, errorMessage);
34 qCWarning(lcShiboken, "%s",
35 @@ -1880,7 +1883,10 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
39 - AbstractMetaType *metaType = translateType(arg->type(), currentClass, {}, &errorMessage);
40 + TranslateTypeFlags flags;
41 + if (arg->scopeResolution())
42 + flags.setFlag(AbstractMetaBuilder::NoClassScopeLookup);
43 + AbstractMetaType *metaType = translateType(arg->type(), currentClass, flags, &errorMessage);
45 // If an invalid argument has a default value, simply remove it
46 // unless the function is virtual (since the override in the
47 @@ -2073,11 +2079,13 @@ static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaC
48 // Helper for translateTypeStatic()
49 TypeEntries AbstractMetaBuilderPrivate::findTypeEntries(const QString &qualifiedName,
51 + TranslateTypeFlags flags,
52 AbstractMetaClass *currentClass,
53 AbstractMetaBuilderPrivate *d)
55 // 5.1 - Try first using the current scope
57 + if (currentClass != nullptr
58 + && !flags.testFlag(AbstractMetaBuilder::NoClassScopeLookup)) {
59 if (auto type = findTypeEntryUsingContext(currentClass, qualifiedName))
62 @@ -2278,7 +2286,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateTypeStatic(const TypeInfo
63 typeInfo.clearInstantiations();
66 - TypeEntries types = findTypeEntries(qualifiedName, name, currentClass, d);
67 + TypeEntries types = findTypeEntries(qualifiedName, name, flags, currentClass, d);
68 if (!flags.testFlag(AbstractMetaBuilder::TemplateArgument)) {
69 // Avoid clashes between QByteArray and enum value QMetaType::QByteArray
70 // unless we are looking for template arguments.
71 diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
72 index 8916eaf..f333ad5 100644
73 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
74 +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h
75 @@ -94,7 +94,8 @@ public:
77 enum TranslateTypeFlag {
78 DontResolveType = 0x1,
79 - TemplateArgument = 0x2
80 + TemplateArgument = 0x2,
81 + NoClassScopeLookup = 0x4
83 Q_DECLARE_FLAGS(TranslateTypeFlags, TranslateTypeFlag);
85 diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
86 index 8468950..8ddd369 100644
87 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
88 +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
89 @@ -154,6 +154,7 @@ public:
90 TranslateTypeFlags flags = {},
91 QString *errorMessageIn = nullptr);
92 static TypeEntries findTypeEntries(const QString &qualifiedName, const QString &name,
93 + TranslateTypeFlags flags = {},
94 AbstractMetaClass *currentClass = nullptr,
95 AbstractMetaBuilderPrivate *d = nullptr);