Skip to content

CFE sometimes infers the wrong type for Future return types in interfaces across nullability boundaries. #40479

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
Markzipan opened this issue Feb 5, 2020 · 2 comments
Assignees
Labels
front-end-fasta legacy-area-front-end Legacy: Use area-dart-model instead. NNBD Issues related to NNBD Release

Comments

@Markzipan
Copy link
Contributor

Snippet below consists of two files:

Opted-out:

// @dart = 2.6

import 'tt.dart';
import "dart:async";

class B implements A<int> {
  then<B>() => Future<B>.value();
}

main() {}

Opted-in:

class A<R> {
  Future<T> then<T>() => Future<T>.value();
}

errors with the null-safety experiment enabled with:

Error: The return type of the method 'B.then' is 'dynamic', which does not match the return type, 'Future<B>', of the overridden method, 'A.then'.
 - 'Future' is from 'dart:async'.
Change to a subtype of 'Future<B>'.
  then<B>() => Future<B>.value();
  ^
Context: This is the overridden method ('then').
  Future<T> then<T>() => Future<T>.value();
            ^

but passes with the experiment disabled.

@Markzipan Markzipan added front-end-fasta legacy-area-front-end Legacy: Use area-dart-model instead. NNBD Issues related to NNBD Release labels Feb 5, 2020
@johnniwinther
Copy link
Member

Like caused by the missing normalization as with #40454

@chloestefantsova chloestefantsova self-assigned this Feb 10, 2020
@chloestefantsova
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end-fasta 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

3 participants