<feed xmlns='http://www.w3.org/2005/Atom'>
<title>qt/qtdeclarative.git/tests/auto/qml/qmllint/data/setRequiredPropertyThroughAliasOfAlias.qml, branch dev</title>
<subtitle>Qt Declarative (Quick 2)
</subtitle>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/'/>
<entry>
<title>Compiler: Don't make aliases to required properties required themselves</title>
<updated>2025-03-04T16:15:13+00:00</updated>
<author>
<name>Olivier De Cannière</name>
<email>olivier.decanniere@qt.io</email>
</author>
<published>2025-03-04T11:52:37+00:00</published>
<link rel='alternate' type='text/html' href='https://code.qt.io/cgit/qt/qtdeclarative.git/commit/?id=daf57e29de918b7b4be7bb0d469db0c51d41bb07'/>
<id>daf57e29de918b7b4be7bb0d469db0c51d41bb07</id>
<content type='text'>
When a property is declared as required, it needs to be bound when
creating the component containing that type.

Required properties can be aliased just like any other property. Before
this patch, aliases targeting required properties would themselves be
marked as required. This is incorrect as this forces the aliased
required property to be set through the alias. It should be legal to
alias a required property and not set required value through the alias.

Therefore, stop marking the alias as required and instead check directly
that the required property is bound in some scope for each object
creation or that it is forwarded through a root-level alias. A required
property will now also be satisfied if it is set through an alias.

For this to work, a property alias now also stores its target scope and
target property name.

This change also adds checking for object definition bindings of the
following form. These weren't checked before but really should be.
```
QtObject {
    property QtObject o: QtObject {
        required property int i // was not checked
    }
}
```

These changes affect the way qmltc enforces setting required properties.
Because it relied on aliases to required properties to be required
themselves, it will now fail to enforce certain required properties.
Created QTBUG-131777 and marked affected tests as QEXPECT_FAIL.

Fixes: QTBUG-127098
Pick-to: 6.9 6.8 6.5
Change-Id: Ib36a43fbf3cc9c79eba6db39cbaf8769f85e2b31
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a property is declared as required, it needs to be bound when
creating the component containing that type.

Required properties can be aliased just like any other property. Before
this patch, aliases targeting required properties would themselves be
marked as required. This is incorrect as this forces the aliased
required property to be set through the alias. It should be legal to
alias a required property and not set required value through the alias.

Therefore, stop marking the alias as required and instead check directly
that the required property is bound in some scope for each object
creation or that it is forwarded through a root-level alias. A required
property will now also be satisfied if it is set through an alias.

For this to work, a property alias now also stores its target scope and
target property name.

This change also adds checking for object definition bindings of the
following form. These weren't checked before but really should be.
```
QtObject {
    property QtObject o: QtObject {
        required property int i // was not checked
    }
}
```

These changes affect the way qmltc enforces setting required properties.
Because it relied on aliases to required properties to be required
themselves, it will now fail to enforce certain required properties.
Created QTBUG-131777 and marked affected tests as QEXPECT_FAIL.

Fixes: QTBUG-127098
Pick-to: 6.9 6.8 6.5
Change-Id: Ib36a43fbf3cc9c79eba6db39cbaf8769f85e2b31
Reviewed-by: Ulf Hermann &lt;ulf.hermann@qt.io&gt;
</pre>
</div>
</content>
</entry>
</feed>
