Description
This issue was originally filed by [email protected]
What steps will reproduce the problem?
If the following test program is executed then unhandled exception
is thrown. No exception is thrown if line (2) is put in comment,
and line (1) is uncommmented.
class _Iterable<E> implements Iterable<E> {
final Iterator<E> _iterator;
_Iterable(this._iterator);
Iterator<E> iterator() {
return _iterator;
}
}
Iterable<Comparable> copy(Iterable<Comparable> iterable) {
//return new _Iterable(iterable.iterator()); // (1) : OK
// Unhandled exception: type '_Iterable@28152909<Comparable>' is not
// a subtype of type 'Iterable<int>' of 'output'.
return new _Iterable<Comparable>(iterable.iterator()); // (2) : FAIL
}
main() {
Iterable<int> output = copy([0, 1]);
Expect.isTrue(output.iterator().hasNext());
}
You may try the test program here http://try.dartlang.org/s/skw5
What is the expected output? What do you see instead?
Expected: no exception should be thrown, specifying generic type
should not influence on the execution of the program
Actual, Dartboard: Failed type check: type tator89da13$_Iterable is not assignable to type Iterable
Actual, Dart Editor: Unhandled exception:
type '_Iterable@28152909<Comparable>' is not a subtype of type 'Iterable<int>' of 'output'.
0. Function: '::main' url: 'file:///C:/Dart/Projects/BugReport001/Test01/TestBugs.dart' line:18 col:30
What version of the product are you using? On what operating system?
Version 0.1.0.201204131908, Build 6557
Dart SDK version 6478
Windows 7 Home Premium, 64 bit
Please provide any additional information below.