Comments (3)
An async*
function will return an instance of Stream<T>
for some T
, no matter what, so your declared return type can't promise a proper subtype of that (you can't expect that function to return a MySpecialStream<OfAnything>
, because the code that creates the object which is returned isn't written by you, it's generated by the compiler).
However, it would actually be sound to allow this return type to be an extension type whose representation type is an acceptable return type for the async*
function: If it has representation type Stream<int>
and we're actually returning a Stream<int>
then it doesn't hurt (from a soundness perspective) that it is typed as a MyExtensionType
, where
extension type MyExtensionType(Stream<int> it) implements Stream<int> {...}
See dart-lang/language#3607 for a proposal to do this. You can vote for this proposal if you wish to support the introduction of this kind of relaxation of the rules about the return type of async*
and similar functions.
from sdk.
Following example is fine,
extension type Csv(List<List<String?>> _) implements List<List<String?>> {}
Csv parseCsvLines(String string) {
///
}
from sdk.
Which is also to say that this is working as currently intended, and it's a language change to make it work differently.
The issue belongs in the language repo, not here, but drive there is already an issue there, I'll just close this as a duplicate.
from sdk.
Related Issues (20)
- Surprising type inference failure HOT 1
- RegExp breaks when passing parenthesis `()` HOT 2
- Inconsistent behavior of `if case` pattern with type promotion in Dart when compiling to JavaScript vs Native HOT 3
- AOT compiler seems to remove switch branches that are actually needed at runtime HOT 3
- [test-runner] Matching too many file names with `Co19TestSuite.isTestFile`?
- "Invalid argument(s):: InterfaceType(s) can only be created for declarations" when using augmentations HOT 8
- pkg/dds/test/dap/integration/debug_attach_test is failing on Windows HOT 23
- Dart Docker version stuck on 3.3.1, 3.3.2 and 3.3.3 out HOT 3
- Dart infers "num" for result of generic function when only ints are involved HOT 1
- [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Illegal argument in isolate message: object is unsendable - Library:'dart:async' Class: _Future@4048458 (see restrictions listed at `SendPort.send()` documentation for more information) HOT 2
- [dart2wasm] Include the text of the condition when throwing an assertion HOT 3
- `uri_does_not_exist` on right click -> new file in VSCode HOT 9
- Stale analysis after changing file
- Generic type T itself becomes nullable if a variable of type T? has a null value HOT 1
- List.toList() Type problem HOT 5
- Compiler failed when runing flutter app
- Null checks not narrowing types for instance variables HOT 2
- Import recovery fails for "import augment" without a semicolon HOT 4
- Specify dart line length in lsp configurations HOT 1
- AddDiagnosticPropertyReference should handle augmentations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.