You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[dart2js] Refine types based on test with late sentinel
A small number of getters for `late final` instance fields with
initializers have better code.
When the initializing expression provably does not write to the backing
field*, the field value is re-used rather than re-loaded for the 'final'
check (that the field has not been assigned during the evaluation of the
initializer). We are testing both `value === $` and `value !== $`:
```
value = _this.___LayoutWidgetState_firstChild_FI;
if (value === $) {
result = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
value !== $ && A.throwUnnamedLateFieldADI();
_this.___LayoutWidgetState_firstChild_FI = result;
value = result;
}
```
In this change we refine the type of the tested value to late sentinel,
allowing the check to be removed:
```
if (value === $)
value = _this.___LayoutWidgetState_firstChild_FI = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
```
*This effect analysis is pretty simple ('writes some field'), but if
improved, we might expect more `late final` getters to benefit.
Change-Id: I444ed157083663b848fb2f115d0575e544b47727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430962
Reviewed-by: Mayank Patke <[email protected]>
Commit-Queue: Stephen Adams <[email protected]>
0 commit comments