Skip to content

await futureOr may return a Future when the generic is Object #54311

Closed
@rrousselGit

Description

@rrousselGit

Consider the following code:

import 'dart:async';

void main() async {
  final value = await fn();
  print(value);
}

FutureOr<Object> fn() async {
  return Future<Object>.value(42);
}

This should print 42 but actually prints Instance of '_Future<dynamic>'

Returning anything other than FutureOr<Object> in fn fixes the issue. This includes changing Object to int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions