Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
6.4
Description
Extension types on Q_OBJECTs are fairly special. [1] documented that members of extension types are implicitly FINAL (as in final properties).
We should be able to check that no shadowing happens ahead of time in QQmlJSImportVisitor which is used by qmllint and compilers (qmlsc, qmltc).
Doing the analysis at run time in QQmlComponent case is rather costly and it would technically be a behavior change as QML-created properties shadow extension types quite well - something that e.g. qmltc doesn't want to support. In C++ land, however, an extension type property would always shadow any other same-named property (same for signals / methods, etc.).
Thus, what we can sanely do is make qmllint warn if properties are shadowed. Something like the following thus should be warned about:
// C++: class Extension : public QObject { Q_PROPERTY(int x ...) Q_PROPERTY(int y ...) ... }; class Base : public QObject { QML_EXTENDED(Extension) ... }; class Derived : public Base { Q_PROPERTY(int x ...) // shadows extension type property! ... }; // QML: Derived { x: 42 // sets (should at least - needs testing) 'x' property of Extension type // Warning: 'x' from Derived shadows extension type property 'x' property int y y: 42 // QQmlComponent: sets 'y' property of QML type, not Extension type // qmltc: sets 'y' property of Extension type // Warning: 'y' from this object shadows extension type property 'y' }
List of extension type "members" to care about (possibly not exhaustive):
- properties
- Q_INVOKABLE methods
- signals
- enums
[1]: b85ac05e4ab3ef356ef59f6c57f44855edf15c5c
Attachments
Issue Links
- is required for
-
QTBUG-120004 QML Type Compliler in Qt 6.8(?)
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-104007 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
413862,3 | WIP: detect extension property/signal overrides | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |