Coder Social home page Coder Social logo

Comments (3)

eernstg avatar eernstg commented on July 2, 2024 1

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.

Cat-sushi avatar Cat-sushi commented on July 2, 2024

Following example is fine,

extension type Csv(List<List<String?>> _) implements List<List<String?>> {}

Csv parseCsvLines(String string) {
///
}

from sdk.

lrhn avatar lrhn commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.