-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Unhandled exception thrown if generic type is specified #2568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This comment was originally written by [email protected] I still think that you should reach [email protected] instead of filing these issues. In this case, your problem isn't in the copy function
but in the main function instead:
And only in checked mode -- if you disable type checks, your program runs just fine. Specifying types MUST influence program execution in checked mode, that's its very purpose! Let's take a look at what happens:
|
Let's take this discussion to the [email protected] mailing list. Feel free to re-open the issue if you feel like this really is a bug in Dart. Added Invalid label. |
> git log --oneline 04b054b62cc437cf23451785fdc50e49cd9de139..master 0d185a39 (HEAD -> master, origin/master, origin/HEAD) Push null-safety forwards to 2.11 (#2604) 56f9f27f Hide outdated --mode flag (#2603) 61ce6f81 Avoid double loop (#2605) fa6e57d7 (disable_mixed_mode_validation) Fix outdated latest ordering (#2598) 6549e4aa Remove unused dependency from pubspec.yaml (#2592) 61543d07 Don't look for external package foo during testing (#2599) 590b448f Fixed license headers (#2595) 04e0601e Don't show entries for dev-dependencies in outdated --json --no-dev-dependencies (#2591) 8c3778c4 Configure GitHub move app (#2578) eec7beca (top_level_command) Pass --(no-)sound-null-safety arg through to VM. (#2542) 152e4740 Warn about publishing in mixed mode (#2583) 0b7a3abe Removed april fools toys (#2325) b74a5b73 Actually print hints (#2582) 8ec3a66d (pub2) Fix outdated --no-color (#2572) 7bb3d4e6 Use getSdkPath() in NullSafetyAnalysis (#2573) 3c578f24 Drop the "magic" package concept (#2577) 0e967ff0 Remove unused function (#2570) 988fefef Remove dependency overrides (#2568) Change-Id: I58bf14234ed55bf9d825de60a40ded1d65281195 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158003 Reviewed-by: Jonas Jensen <[email protected]> Commit-Queue: Sigurd Meldgaard <[email protected]>
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.
The text was updated successfully, but these errors were encountered: