-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fix #2490. Update incompatible with await tests according to the changed rule #2516
Conversation
… the changed rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again some tricky corners to consider. ;-)
LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart
Outdated
Show resolved
Hide resolved
LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more comment.
test<X extends NumET>(X x) async { | ||
if (x is int) { | ||
await x; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably do something like this:
extension type E1(Object _) {} // Incompatible with await.
extension type E2(Future<int> _) implements E1, Future<int> {} // Compatible.
Future<void> foo<X extends E1>(X x) async {
E1 y = x;
// await y; // Error, reported today.
await x; // Error, `E` is not compatible with await. Not reported.
if (x is E2) { // `x` has type `X & E2`.
await x; // OK, result has type `int`.
}
}
void main() async {
await foo(E1(Future.value(1)));
}
(By the way, I just tried a completely fresh CFE, it does report an error for the line marked 'Not reported'. Moving fast. ;-)
I removed extension type E1(Object _) {} // Incompatible with await.
extension type E2(Future<int> _) implements E1, Future<int> {} // Compatible.
Future<void> foo<X extends E1>(X x) async {
E1 y = x;
// await y; // Error, reported today. <- this checked in `static_analysis_extension_types_A08_t01.dart`
await x; // Error, `E` is not compatible with await. Not reported. <- checked in `static_analysis_extension_types_A08_t07.dart`
if (x is E2) { // `x` has type `X & E2`.
await x; // OK, result has type `int`. <- checked in `static_analysis_extension_types_A08_t11.dart`
}
}
void main() async {
await foo(E1(Future.value(1)));
} So, I think, there is no need to add the test above. Please take another look |
OK, updated asserts is a safe bet: Landing this. However, I'm still wondering: Do we have a test that covers the case where we can a // Like this.
extension type E1(Object _) {} // Incompatible with await.
extension type E2(Future<int> _) implements E1, Future<int> {} // Compatible. This is a tricky case because an algorithm that searches for an extension type that doesn't implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please see co19/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t11.dart Lines 19 to 37 in 5125c01
|
Great, thanks! |
2024-02-02 sgrekhov22@gmail.com Fix dart-lang/co19#2517. Fix wrong test, add experimental flags (dart-lang/co19#2518) 2024-02-02 sgrekhov22@gmail.com Fix dart-lang/co19#2490. Update incompatible with await tests according to the changed rule (dart-lang/co19#2516) 2024-02-01 sgrekhov22@gmail.com dart-lang/co19#2420. Add more exhaustiveness tests (dart-lang/co19#2513) 2024-01-31 sgrekhov22@gmail.com dart-lang/co19#2446. Add additional test for cast pattern (dart-lang/co19#2514) 2024-01-30 sgrekhov22@gmail.com dart-lang/co19#1399. Add more tests for records (dart-lang/co19#2511) 2024-01-30 sgrekhov22@gmail.com dart-lang/co19#2485. Update map and list constant literals tests. Add parenthesized for records (dart-lang/co19#2512) 2024-01-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2490. Add more await tests for extension types (dart-lang/co19#2500) 2024-01-29 sgrekhov22@gmail.com dart-lang/co19#2119. Fix typo in Subtyping tests description (dart-lang/co19#2510) 2024-01-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2505. Add more tests for `call` member (dart-lang/co19#2506) 2024-01-29 sgrekhov22@gmail.com dart-lang/co19#2420. Add cast-pattern tests for extension types (dart-lang/co19#2458) Change-Id: I631705a013f9a77910ae0f0be5a9fea01e7c719f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350240 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: William Hesse <whesse@google.com>
… the changed rule (dart-lang#2516) Update incompatible with await tests according to the changed rule
… the changed rule (dart-lang#2516) Update incompatible with await tests according to the changed rule
No description provided.