fix #27766, allow implicit casts from dynamic to composite types

R=leafp@google.com

Review URL: https://codereview.chromium.org/2477093002 .
This commit is contained in:
Jennifer Messerly 2016-11-04 17:37:13 -07:00
parent 68f290c9d8
commit 43bcc5945e
3 changed files with 16 additions and 3 deletions

View file

@ -21,6 +21,19 @@ Patch release, resolves one issue:
* Dartium: Fixes a bug that caused crashes. No issue filed
### Strong Mode
* It is no longer a warning when casting from dynamic to a composite type
(SDK issue [27766](https://github.com/dart-lang/sdk/issues/27766)).
```dart
main() {
dynamic obj = <int>[1, 2, 3];
// This is now allowed without a warning.
List<int> list = obj;
}
```
## 1.20.0 - 2016-10-11
### Dart VM

View file

@ -1107,7 +1107,7 @@ class CodeChecker extends RecursiveAstVisitor {
downCastComposite =
typeArgs.isEmpty || typeArgs.any((t) => t.isDynamic);
} else {
downCastComposite = true;
downCastComposite = !from.isDynamic;
}
}

View file

@ -988,7 +988,7 @@ Stream<int> bar4() async* { yield /*error:YIELD_OF_INVALID_TYPE*/new Stream<int>
baz1() async* { yield* /*info:DYNAMIC_CAST*/x; }
Stream baz2() async* { yield* /*info:DYNAMIC_CAST*/x; }
Stream<int> baz3() async* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; }
Stream<int> baz3() async* { yield* /*info:DYNAMIC_CAST*/x; }
Stream<int> baz4() async* { yield* new Stream<int>(); }
Stream<int> baz5() async* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new Stream(); }
''');
@ -1005,7 +1005,7 @@ Iterable<int> bar4() sync* { yield /*error:YIELD_OF_INVALID_TYPE*/bar3(); }
baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; }
Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; }
Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; }
Iterable<int> baz3() sync* { yield* /*info:DYNAMIC_CAST*/x; }
Iterable<int> baz4() sync* { yield* bar3(); }
Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); }
''');