96a4dd4c19
https://dart-review.googlesource.com/c/sdk/+/498840 added support for promotion of properties (private, final instance variables with a name which isn't used much for other purposes) in the context of anonymous methods. This CL reduces the set of situations where this feature is enabled such that only `this` will allow property promotions to be carried in (such that `this._x` is promoted in `v.=> this._x` when `v` is such that `v._x` has been promoted before the anonymous method occurs). It also generalizes the mechanism such that property promotions are carried out (so we can do `if (v.=> _x is int) v._x.isEven;`). Tests has been adjusted accordingly. Change-Id: Ibe70713d3d9c89a6d95f9c3dd28df8f147cb518d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502660 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Erik Ernst <eernst@google.com>
14 lines
462 B
Dart
14 lines
462 B
Dart
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// SharedOptions=--enable-experiment=anonymous-methods
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
final int? x = 2;
|
|
Expect.isTrue((x != null).=> this ? x.isEven : false);
|
|
Expect.isTrue((x != null).(p) => p ? x.isEven : false);
|
|
}
|