Skip to content

CFE doesn't allow implicit cast from dynamic in async function under NNBD #42282

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

Closed
munificent opened this issue Jun 11, 2020 · 1 comment
Closed
Labels
legacy-area-front-end Legacy: Use area-dart-model instead. NNBD Issues related to NNBD Release

Comments

@munificent
Copy link
Member

Consider:

import 'dart:async';

Future<int> foo() async {
  dynamic x = 123;
  return x;
}

main() {
  foo();
}

This program runs fine normally, but if I run:

$ dart --enable-experiment=non-nullable temp.dart

Then I get:

temp.dart:9:10: Error: A value of type 'Future<dynamic>' can't be assigned to a variable of type 'FutureOr<int>'.
 - 'Future' is from 'dart:async'.
 - 'FutureOr' is from 'dart:async'.
  return x;
         ^

From talking to @eernst, my understanding is that this code should continue to be allowed under null safety.

@munificent munificent added legacy-area-front-end Legacy: Use area-dart-model instead. NNBD Issues related to NNBD Release labels Jun 11, 2020
@johnniwinther
Copy link
Member

Related to #41800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead. NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

2 participants