Update changelog to include the recent breaking change

Link to the breaking change request:
https://github.com/dart-lang/sdk/issues/37985

Change-Id: I0fcb058e953a43a20e7b663f63bb88100f376a6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116762
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
This commit is contained in:
Dmitry Stefantsov 2019-09-12 07:37:17 +00:00 committed by commit-bot@chromium.org
parent 60ca2b840d
commit a62289451d
2 changed files with 18 additions and 11 deletions

View file

@ -4,6 +4,20 @@
### Language
* **Breaking change** [#37985](https://github.com/dart-lang/sdk/issues/37985):
Inference is changed when using `Null` values in a `FutureOr` context.
Namely, constraints of the forms similar to `Null` <: `FutureOr<T>` now
yield `Null` as the solution for `T`. For example, the following code will
now print "Null", and it was printing "dynamic" before (note that the
anonymous closure `() {}` in the example has `Null` as its return type):
```dart
import 'dart:async';
void foo<T>(FutureOr<T> Function() f) { print(T); }
main() { foo(() {}); }
```
### Core libraries
### Dart VM

View file

@ -298,17 +298,10 @@ abstract class TypeConstraintGatherer {
DartType supertypeArg = supertype.typeArguments[0];
DartType supertypeFuture = futureType(supertypeArg);
// The outcome of both trySubtypeMatch and _isSubtypeMatch is includes the
// returned boolean value and the added constraints to _protoConstraints.
// Here we need to match 'subtype' against both possibilities of the
// FutureOr<X> which is 'supertype,' that is, we need to match 'subtype'
// against Future<X> and X. However, if the first matching against
// Future<X> finds any new constraints and adds them to _protoConstraints,
// we should prefer them over the constraints possibly found while
// matching against X. Note that if matching against Future<X> returned
// true, but didn't find any new constraints, then matching against X
// should still be done and the new constraints should still be added to
// _protoConstraints.
// The match against FutureOr<X> succeeds if the match against either
// Future<X> or X succeeds. If they both succeed, the one adding new
// constraints should be preferred. If both matches against Future<X> and
// X add new constraints, the former should be preferred over the latter.
int oldProtoConstraintsLength = _protoConstraints.length;
bool matchesFuture = trySubtypeMatch(subtype, supertypeFuture);
bool matchesArg = oldProtoConstraintsLength != _protoConstraints.length