dart-sdk/tests/language_2/implicit_downcast_during_yield_star_test.dart
Paul Berry 9693e47d89 Insert implicit downcasts for the expressions in a return or yield statement.
Tests that have begun failing due to this change are marked with a
reference to issue #31402.

Change-Id: Id570bf354583a3780087ffc820eefc3619573af4
Reviewed-on: https://dart-review.googlesource.com/22842
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-11-22 15:33:07 +00:00

23 lines
514 B
Dart

// Copyright (c) 2017, 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.
import "package:expect/expect.dart";
class A {}
class B extends A {}
Iterable<B> f(Iterable<A> a) sync* {
yield* a;
}
void main() {
B b = new B();
for (var x in f(<B>[b])) {} // No error
var iterator = f(<A>[b]).iterator;
Expect.throwsTypeError(() {
iterator.moveNext();
});
}