Paul Berry
2b8411f626
Enable language feature inference-update-2.
...
This language feature allows type promotion to apply to private final
fields, e.g.:
class C {
final int? _x;
C(this._x);
}
f(C c) {
if (c._x != null) {
print(c._x.abs()); // (1)
}
}
Previously the line marked (1) would have needed to be written
`print(c._x!.abs());`.
Note that to ensure soundness, there are certain restrictions:
- Public fields don't undergo promotion (because a public field might
be overridden by a class in some other library).
- Non-final fields don't undergo promotion (because a non-final field
might be modified as a side effect of code executed between the type
test and the field's usage).
- Fields that are forwarded to `noSuchMethod` in the same library
don't undergo promotion (because there's no guarantee that
`noSuchMethod` will return the same value on every invocation). For
example:
class C {
final int? _x;
C(this._x);
}
class D implements C {
@override
noSuchMethod(...) => ...;
}
f(C c) {
if (c._x != null) {
print(c._x.abs()); // ERROR: `c._x` might dispatch to
// `D.noSuchMethod`, in which case there's
// no guarantee that it will return a
// non-null value the second time it's
// invoked.
}
}
- If two classes define fields or getters of the same name, and
promotion is not permitted for one of them, then it isn't permitted
for the other. This is because there might be a class in some other
library that's a subclass of both classes, causing a reference to
one field or getter to dispatch to the other. For example:
class C {
final int? _x;
C(this._x);
}
class D {
int? get _x => ...;
}
f(C c) {
if (c._x != null) {
print(c._x.abs()); // ERROR: `c._x` might dispatch to `D._x`
// (e.g. because some library might declare
// `class E extends D implements C`), in
// which case there's no guarantee that it
// will return a non-null value the second
// time it's invoked.
}
}
Change-Id: Ib9183581aa0194377e38ab70d37c3e9f0bb57a75
Bug: https://github.com/dart-lang/language/issues/2020
Tested: TAP global presubmit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314600
Reviewed-by: Ryan Macnak <rmacnak@google.com >
Reviewed-by: Nate Bosch <nbosch@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2023-07-28 23:56:52 +00:00
..
2023-07-27 21:32:40 +00:00
2023-07-10 12:23:15 +00:00
2023-07-27 20:17:17 +00:00
2023-04-17 15:58:28 +00:00
2023-06-15 19:01:00 +00:00
2023-07-17 15:01:21 +00:00
2023-04-20 17:42:06 +00:00
2023-06-06 02:07:58 +00:00
2023-04-10 18:15:12 +00:00
2023-05-24 08:42:14 +00:00
2023-07-03 12:29:15 +00:00
2023-07-26 23:23:26 +00:00
2023-06-06 16:20:47 +00:00
2023-03-30 19:27:17 +00:00
2020-11-13 22:10:54 +00:00
2023-04-21 08:06:49 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2021-03-19 15:29:57 +00:00
2023-07-11 15:13:58 +00:00
2023-04-12 22:18:54 +00:00
2023-03-06 22:06:59 +00:00
2023-03-06 22:06:59 +00:00
2023-05-10 11:38:57 +00:00
2023-06-28 01:00:18 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-06-28 01:00:18 +00:00
2023-06-28 01:00:18 +00:00
2023-06-15 19:01:00 +00:00
2023-02-06 21:49:07 +00:00
2023-07-26 23:23:26 +00:00
2021-03-02 16:28:12 +00:00
2023-07-26 21:14:09 +00:00
2023-06-15 00:34:18 +00:00
2023-06-21 15:24:30 +00:00
2023-04-20 17:42:06 +00:00
2023-07-27 20:17:17 +00:00
2023-06-28 11:48:26 +00:00
2023-06-28 11:48:26 +00:00
2021-02-02 11:35:00 +00:00
2021-02-02 11:35:00 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2021-02-02 11:35:00 +00:00
2021-09-10 22:21:36 +00:00
2023-04-12 22:18:54 +00:00
2021-09-10 22:21:36 +00:00
2023-04-10 18:15:12 +00:00
2021-09-10 22:21:36 +00:00
2023-04-12 22:18:54 +00:00
2022-01-20 00:57:57 +00:00
2023-04-10 18:15:12 +00:00
2021-09-10 22:21:36 +00:00
2023-04-10 18:15:12 +00:00
2023-01-20 12:37:49 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2022-02-22 21:48:14 +00:00
2023-06-28 01:00:18 +00:00
2022-02-22 21:48:14 +00:00
2023-06-28 01:00:18 +00:00
2022-06-08 19:41:52 +00:00
2022-06-08 22:57:03 +00:00
2023-06-28 01:00:18 +00:00
2022-06-23 15:58:15 +00:00
2023-07-11 15:13:58 +00:00
2022-06-08 22:57:03 +00:00
2023-06-28 01:00:18 +00:00
2022-06-08 22:57:03 +00:00
2023-06-23 20:35:00 +00:00
2023-02-27 22:26:36 +00:00
2023-06-23 20:35:00 +00:00
2021-12-16 21:33:49 +00:00
2023-06-23 20:35:00 +00:00
2021-12-16 21:33:49 +00:00
2023-06-23 20:35:00 +00:00
2022-01-20 00:57:57 +00:00
2022-01-20 00:57:57 +00:00
2023-06-23 20:35:00 +00:00
2021-12-16 21:33:49 +00:00
2022-01-20 00:57:57 +00:00
2023-04-10 18:15:12 +00:00
2022-11-14 15:42:52 +00:00
2023-05-22 16:43:04 +00:00
2023-04-10 21:38:57 +00:00
2023-04-10 21:38:57 +00:00
2023-04-10 21:38:57 +00:00
2023-07-12 17:14:18 +00:00
2022-01-20 00:57:57 +00:00
2023-04-10 18:15:12 +00:00
2023-07-20 17:06:44 +00:00
2023-07-28 10:01:53 +00:00
2023-04-20 17:42:06 +00:00
2023-07-26 21:53:49 +00:00
2021-10-14 00:10:12 +00:00
2023-07-20 17:06:44 +00:00
2023-06-29 17:29:48 +00:00
2023-07-27 20:17:17 +00:00
2023-07-18 19:33:37 +00:00
2023-06-29 08:04:20 +00:00
2021-04-26 07:52:47 +00:00
2021-07-08 14:22:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2021-03-19 20:24:48 +00:00
2021-03-19 20:24:48 +00:00
2021-03-19 20:24:48 +00:00
2022-01-20 00:57:57 +00:00
2021-03-19 20:24:48 +00:00
2023-07-26 17:15:36 +00:00
2023-06-30 14:03:03 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-26 21:53:49 +00:00
2023-04-12 22:18:54 +00:00
2022-09-12 12:33:57 +00:00
2022-09-12 12:33:57 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-07-11 15:13:58 +00:00
2023-05-31 08:06:08 +00:00
2023-06-06 02:07:58 +00:00
2022-10-06 10:33:09 +00:00
2023-04-10 18:15:12 +00:00
2023-06-15 17:19:37 +00:00
2023-06-15 17:19:37 +00:00
2023-07-28 23:56:52 +00:00
2023-07-28 23:56:52 +00:00
2023-07-26 23:23:26 +00:00
2023-07-26 23:23:26 +00:00
2023-06-28 09:21:11 +00:00
2023-04-26 22:18:51 +00:00
2023-07-27 20:17:17 +00:00
2020-11-03 10:27:44 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-12 15:46:27 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-03-29 18:11:49 +00:00
2023-07-26 21:53:49 +00:00
2023-04-18 19:39:05 +00:00
2021-01-15 23:32:02 +00:00
2023-02-06 22:19:55 +00:00
2023-04-10 18:15:12 +00:00
2023-06-23 20:35:00 +00:00
2023-06-23 20:35:00 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2022-01-21 02:02:00 +00:00
2023-06-27 19:42:15 +00:00
2022-12-01 10:15:58 +00:00
2023-06-06 02:07:58 +00:00
2023-05-31 08:06:08 +00:00
2021-01-15 23:32:02 +00:00
2023-07-11 15:13:58 +00:00
2023-04-12 22:18:54 +00:00
2021-01-15 23:32:02 +00:00
2022-05-11 19:52:45 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2022-01-20 00:57:57 +00:00
2023-04-13 19:29:47 +00:00
2023-04-12 22:18:54 +00:00
2023-03-06 22:06:59 +00:00
2023-04-12 22:18:54 +00:00
2022-05-11 19:52:45 +00:00
2022-05-11 19:52:45 +00:00
2023-07-26 21:14:09 +00:00
2023-07-28 10:01:53 +00:00
2023-05-10 19:08:23 +00:00
2023-04-19 09:36:41 +00:00
2023-07-26 23:23:26 +00:00
2023-07-26 23:23:26 +00:00
2023-06-09 17:57:12 +00:00
2023-06-09 17:57:12 +00:00
2023-04-17 15:58:28 +00:00
2023-04-17 15:58:28 +00:00
2023-04-17 15:58:28 +00:00
2023-07-14 10:15:06 +00:00
2023-07-27 10:47:08 +00:00
2023-07-28 10:01:53 +00:00
2023-07-28 10:01:53 +00:00
2023-07-27 10:47:08 +00:00
2023-07-14 10:15:06 +00:00
2022-11-11 01:59:28 +00:00
2023-07-14 10:15:06 +00:00
2023-07-14 10:15:06 +00:00
2023-04-19 08:47:31 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2022-05-11 19:31:04 +00:00
2021-09-30 13:19:42 +00:00
2023-04-20 17:42:06 +00:00
2023-04-10 18:15:12 +00:00
2021-09-16 17:18:37 +00:00
2023-06-29 08:04:20 +00:00
2023-06-29 08:04:20 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-21 13:56:49 +00:00
2023-06-27 22:23:17 +00:00
2023-07-11 10:15:58 +00:00
2022-08-19 18:10:15 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-26 21:53:49 +00:00
2023-03-29 19:58:33 +00:00
2023-04-10 18:15:12 +00:00
2023-03-29 19:58:33 +00:00
2023-04-10 18:15:12 +00:00
2023-04-19 09:36:41 +00:00
2023-07-26 21:53:49 +00:00
2021-01-15 23:32:02 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2021-09-02 14:14:35 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2021-01-15 23:32:02 +00:00
2023-07-26 21:53:49 +00:00
2023-02-23 03:11:08 +00:00
2023-04-10 18:15:12 +00:00
2023-05-10 16:12:28 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-07-26 21:14:09 +00:00
2022-01-20 00:57:57 +00:00
2023-07-17 15:01:21 +00:00
2021-01-15 23:32:02 +00:00
2023-06-27 07:18:50 +00:00
2023-06-30 14:03:03 +00:00
2023-07-24 16:55:47 +00:00
2021-01-15 23:32:02 +00:00
2023-07-26 23:23:26 +00:00
2023-07-26 23:23:26 +00:00
2023-06-12 15:26:29 +00:00
2023-06-12 15:26:29 +00:00
2023-06-14 20:36:48 +00:00
2023-06-12 15:26:29 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2022-03-10 23:48:05 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2021-03-31 20:51:32 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-10 20:33:33 +00:00
2023-07-10 20:33:33 +00:00
2023-06-12 15:26:29 +00:00
2023-06-12 15:26:29 +00:00
2023-06-30 14:03:03 +00:00
2023-04-10 18:15:12 +00:00
2022-06-02 23:39:45 +00:00
2022-06-02 23:39:45 +00:00
2023-05-15 20:51:38 +00:00
2022-09-27 21:34:05 +00:00
2023-04-12 22:18:54 +00:00
2020-11-11 23:42:12 +00:00
2023-04-10 18:15:12 +00:00
2022-08-19 18:10:15 +00:00
2023-04-10 18:15:12 +00:00
2021-07-02 19:06:45 +00:00
2023-05-15 20:51:38 +00:00
2023-05-03 19:17:11 +00:00
2023-04-12 22:18:54 +00:00
2023-04-20 17:42:06 +00:00
2023-04-19 09:36:41 +00:00
2023-04-19 08:47:31 +00:00
2021-08-24 16:49:23 +00:00
2023-04-10 18:15:12 +00:00
2022-11-22 18:05:24 +00:00
2023-07-14 10:15:06 +00:00
2022-12-01 14:38:44 +00:00
2023-04-28 19:29:36 +00:00
2023-07-27 20:17:17 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2021-01-15 23:32:02 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2021-09-02 19:22:16 +00:00
2023-07-06 21:10:28 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2022-12-29 10:18:02 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2021-12-16 10:39:49 +00:00
2021-12-16 10:39:49 +00:00
2023-04-12 22:18:54 +00:00
2022-03-22 19:45:03 +00:00
2022-03-22 19:45:03 +00:00
2022-03-22 19:45:03 +00:00
2023-06-28 01:00:18 +00:00
2022-03-22 19:45:03 +00:00
2022-03-22 19:45:03 +00:00
2023-07-11 22:31:57 +00:00
2023-06-28 01:00:18 +00:00
2021-05-11 11:15:53 +00:00
2023-04-10 18:15:12 +00:00
2023-06-30 14:03:03 +00:00
2023-06-30 14:03:03 +00:00
2023-06-09 17:57:12 +00:00
2021-07-16 20:50:58 +00:00
2023-06-29 08:04:20 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-11 13:29:33 +00:00
2023-07-17 15:01:21 +00:00
2023-06-23 17:01:58 +00:00
2021-08-16 11:11:04 +00:00
2023-06-23 17:01:58 +00:00
2023-01-06 07:48:22 +00:00
2021-08-16 11:11:04 +00:00
2021-08-16 11:11:04 +00:00
2023-07-21 19:06:43 +00:00
2023-07-21 19:06:43 +00:00
2023-07-21 19:06:43 +00:00
2023-07-21 19:06:43 +00:00
2023-07-11 15:13:58 +00:00
2023-04-12 22:18:54 +00:00
2023-07-11 15:13:58 +00:00
2023-04-12 22:18:54 +00:00
2022-07-29 18:11:01 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-07-17 15:01:21 +00:00
2023-07-13 08:17:38 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-28 23:25:43 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-06-30 14:03:03 +00:00
2023-06-30 14:03:03 +00:00
2022-03-22 19:45:03 +00:00
2022-03-22 19:45:03 +00:00
2022-03-22 19:45:03 +00:00
2023-07-03 10:39:53 +00:00
2022-03-22 19:45:03 +00:00
2021-01-15 23:32:02 +00:00
2022-03-22 19:45:03 +00:00
2023-06-06 02:07:58 +00:00
2023-07-03 10:39:53 +00:00
2023-04-19 08:47:31 +00:00
2023-07-26 23:23:26 +00:00
2023-06-27 19:47:04 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2021-11-02 17:42:52 +00:00
2021-08-16 11:11:04 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-02-21 19:07:57 +00:00
2023-04-10 18:15:12 +00:00
2023-05-11 21:41:01 +00:00
2023-04-12 22:18:54 +00:00
2023-04-10 18:15:12 +00:00
2023-03-06 22:06:59 +00:00
2023-01-09 15:48:57 +00:00
2023-04-26 22:18:51 +00:00
2023-07-27 20:17:17 +00:00
2023-05-10 19:08:23 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-20 17:42:06 +00:00
2023-07-12 15:46:27 +00:00
2023-06-29 17:29:48 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-07-10 20:33:33 +00:00
2023-07-10 20:33:33 +00:00
2023-07-10 20:33:33 +00:00
2021-10-05 16:32:40 +00:00
2021-10-05 16:32:40 +00:00
2021-12-15 23:12:19 +00:00
2023-02-20 14:57:57 +00:00
2022-08-03 10:32:46 +00:00
2023-04-12 22:18:54 +00:00
2023-06-24 12:56:12 +00:00
2023-07-06 08:16:47 +00:00
2023-04-17 16:26:35 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-04-12 22:18:54 +00:00
2023-07-28 10:01:53 +00:00
2023-06-23 20:35:00 +00:00
2023-05-11 03:14:27 +00:00
2023-05-11 03:14:27 +00:00
2023-05-11 03:14:27 +00:00
2023-04-10 18:15:12 +00:00
2023-04-10 18:15:12 +00:00
2023-04-12 22:18:54 +00:00
2021-12-15 22:22:36 +00:00
2021-09-02 21:46:35 +00:00
2022-08-05 11:53:37 +00:00
2023-06-23 20:35:00 +00:00
2023-06-23 20:35:00 +00:00
2023-06-20 19:28:18 +00:00
2023-06-21 11:39:50 +00:00
2023-06-06 02:07:58 +00:00
2023-06-21 11:39:50 +00:00
2023-06-28 01:00:18 +00:00
2023-06-20 19:28:18 +00:00
2022-09-10 15:12:35 +00:00
2023-04-21 22:41:28 +00:00
2023-06-06 02:07:58 +00:00
2023-06-07 19:01:51 +00:00
2023-06-16 11:22:38 +00:00
2023-06-16 11:22:38 +00:00