Skip to content
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

[ddc] Async return type FutureOr<Object> returns Future<dynamic> #54318

Closed
eernstg opened this issue Dec 12, 2023 · 2 comments
Closed

[ddc] Async return type FutureOr<Object> returns Future<dynamic> #54318

eernstg opened this issue Dec 12, 2023 · 2 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler

Comments

@eernstg
Copy link
Member

eernstg commented Dec 12, 2023

This is the DDC specific issue for the behavior reported in #54311, which has the details (some details here: #54311 (comment)).

The main point is that we can have an async function with declared return type FutureOr<Object> that actually returns a Future<dynamic> (it should return a Future<Object>). The Kernel code which is generated for the example program seems to be correct, so the issue seems to be caused by the processing of this Kernel code in backends.

@eernstg eernstg added web-dev-compiler area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Dec 12, 2023
@eernstg eernstg changed the title [ddc] Return type FutureOr<Object> returns Future<dynamic> [ddc] Async return type FutureOr<Object> returns Future<dynamic> Dec 13, 2023
@eernstg
Copy link
Member Author

eernstg commented May 13, 2024

This issue might have been resolved already:

import 'dart:async';

void main() async {
  final value = await fn();
  print(value); // Correct: '42', wrong: 'Instance of Future<dynamic>'.
}

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

DartPad (any channel) prints '42'.

@sigmundch or @nshahan, can we close this issue now? (which would also allow us to close #54311)

@sigmundch
Copy link
Member

@eernstg thanks for the follow up. I was chatting with @nshahan about it this week and I think it's fair to close it.

We don't recall doing any specific changes for it, but It's possible that we missed the issue it was first filed and that this was always working in DDC. I just tried with a Dart 3.2.0 SDK, which existed prior to this issue, and it was also printing 42 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler
Projects
None yet
Development

No branches or pull requests

2 participants