Code Monkey home page Code Monkey logo

TypeSafeStream<int> from Stream<Object> failing in Dart 1.25.0-dev.10.0 about async HOT 7 CLOSED

dart-lang avatar dart-lang commented on June 1, 2024
TypeSafeStream from Stream failing in Dart 1.25.0-dev.10.0

from async.

Comments (7)

srawlins avatar srawlins commented on June 1, 2024

I'm pretty sure this is because of dart-lang/sdk#30339, so the tests should not have been passing earlier :)

These tests rely on re-ified types, if I'm not mistaken, so should only run in DDC or Dart 2.0 tools.

from async.

whesse avatar whesse commented on June 1, 2024

So the tests should be annotated so they only run in strong mode or on DDC. There are no status files for package:test tests, so I think the annotations have to go on the tests themselves. Until this is done, the tests will be failing on the package waterfall.

from async.

nex3 avatar nex3 commented on June 1, 2024

For reference, the failures we're seeing are of the form:

01:05 +833 -9: [VM] test/typed_wrapper/stream_test.dart: with valid types,
forwards where() [E]
  type 'List<Object>' is not a subtype of type 'List<int>' of 'function result'
where
    List is from dart:core
    Object is from dart:core
    Object is from dart:core
    Object is from dart:core
    List is from dart:core
    int is from dart:core
  
  package:async/src/typed/stream.dart 104:7   TypeSafeStream.toList
  test/typed_wrapper/stream_test.dart 297:44  main.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async                                  _Completer.completeError
  package:async/src/typed/stream.dart 104:54  TypeSafeStream.toList
  ===== asynchronous gap ===========================
  dart:async                                  _asyncThenWrapperHelper
  package:async/src/typed/stream.dart 103:34  TypeSafeStream.toList
  test/typed_wrapper/stream_test.dart 297:44  main.<fn>.<fn>

The code throwing the error is:

  Future<List<T>> toList() async =>
      DelegatingList.typed<T>(await _stream.toList());

In Dart 1.0 semantics, I would expect this to ignore the type parameter on DelegatingList.typed() and thus return a Future<List<dynamic>>, which is a subtype of Future<List<T>>. It seems that it's instead returning a Future<List<Object>>, which indicates that this might be broken for real-world users. @leafpetersen, can you shed light on why this is a List<Object>?

from async.

leafpetersen avatar leafpetersen commented on June 1, 2024

Maybe because of this:

 static List<E> typed<E>(List base) =>
      base is List<E> ? base : new TypeSafeList<E>(base);

On the VM, this will always return base, no? Presumably here, base has type List<Object>.

from async.

nex3 avatar nex3 commented on June 1, 2024

If DelegatingList.typed() is returning base as-is, that means base is List<int> is true. But if that's the case, shouldn't base be a valid return type for toList()?

from async.

leafpetersen avatar leafpetersen commented on June 1, 2024

We're talking about Dart 1.0, right?

In Dart 1.0 semantics, I would expect this to ignore the type parameter on DelegatingList.typed()

it does, so the question that is being asked at runtime is base is List<dynamic>, which is always true. This test program when run on the VM prints "true":

bool foo<T>(base) {
  return base is List<T>;
}

void main() {
  print(foo<int>(<String>[]));
}

from async.

nex3 avatar nex3 commented on June 1, 2024

Oh, right. In that case, I guess the test is legitimately 2.0-only, since we really do want to test what happens when the underlying type is Object. We don't currently have a way to mark that in test, since test doesn't actually support any Dart 2.0 platforms currently, so maybe the thing to do is just to skip the test for now...

from async.

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.