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

Implement error about awaiting a type that is incompatible with await #54647

Closed
eernstg opened this issue Jan 17, 2024 · 4 comments
Closed

Implement error about awaiting a type that is incompatible with await #54647

eernstg opened this issue Jan 17, 2024 · 4 comments
Assignees
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). feature-extension-types Implementation of the extension type feature implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)

Comments

@eernstg
Copy link
Member

eernstg commented Jan 17, 2024

The PR dart-lang/language#3560 introduces the notion that a type can be incompatible with await. This concept is used to specify a new and broader error about expressions of the form await e where the static type of e has associations with an extension type that does not implement Future.

The previous rules just made it an error when the type was such an extension type, now it is also an error when it is T? where T is incompatible with await, or a type variable that extends such a type, etc. Details in dart-lang/language#3560. Example:

extension type N(Future<int> _) {}
extension type F(Future<int> _) implements Future<int> {}

void test<X, XN extends N, XF extends F>(
    N n, F f, X x, XN xn, XF xf, N? nq, F? fq, XN? xnq, XF? xfq) async {
  await n; // Error.
  await f; // OK, type `int`.
  await x; // OK, type `X`.
  await xn; // Error.
  await xf; // OK, type `int`.
  await nq; // Error.
  await fq; // OK, type `int?`.
  await xnq; // Error.
  await xfq; // OK, type `int?`.
  if (x is N) await x; // Error.
  if (x is N?) await x; // Error.
  if (x is XN) await x; // Error.
  if (x is XN?) await x; // Error.
  if (x is F) await x; // OK, type `int`.
  if (x is F?) await x; // OK, type `int?`.
  if (x is XF) await x; // OK, type `int`.
  if (x is XF?) await x; // OK, type `int?`.
}

Subtasks:

@eernstg eernstg added area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) feature-extension-types Implementation of the extension type feature labels Jan 17, 2024
@eernstg
Copy link
Member Author

eernstg commented Mar 1, 2024

@stereotype441
Copy link
Member

Here's the current state of things:

The branch cut for Dart 3.3 stable was made on Jan 3, so neither the CFE implementation nor the partial analyzer implementation has shipped in any stable release yet.

We (the language team) would like to cherry-pick this new error to a point release of Dart 3.3 stable as soon as possible, to help keep users of extension types from awaiting them in problematic ways. Although this new error is technically a breaking change, it concerns a minor corner case of a brand new language feature; we believe adoption of the new language feature is still low enough that if we act fast, it will be ok to make the cherry-pick without going through the breaking change process.

In order to do that, we need to first complete the analyzer implementation, then do a coordinated cherry-pick of 1672177, a5bbbe8, adee0a2, and the remaining analyzer work, so that they all land in the same point release of Dart 3.3 stable.

I will coordinate with the analyzer team to get the remaining analyzer work done, and then I'll file the cherry-pick request and coordinate with the scrum team to get it landed.

@stereotype441 stereotype441 self-assigned this Mar 4, 2024
@stereotype441
Copy link
Member

As of 690d49c, this is now fully supported in the main branch by the analyzer and front end.

@stereotype441
Copy link
Member

The fix has been cherry-picked to the stable branch and should go out in the next hotfix release. See #55095 for cherry-pick details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). feature-extension-types Implementation of the extension type feature implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool)
Projects
None yet
Development

No branches or pull requests

2 participants