Skip to content

Commit

Permalink
Extension type. Issue 54648. Fix 'incompatible with await' predicate.
Browse files Browse the repository at this point in the history
Stop when see 'X & B', just check `B`, do not continue.

Bug: #54648
Change-Id: Ic447b9facd00efac309695f505df603764d8c096
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
  • Loading branch information
scheglov authored and Commit Queue committed Mar 4, 2024
1 parent 7727821 commit 690d49c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
8 changes: 2 additions & 6 deletions pkg/analyzer/lib/src/dart/element/type_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1018,16 +1018,12 @@ class TypeSystemImpl implements TypeSystem {
if (T is TypeParameterTypeImpl) {
// `T` is `X & B`, and `B` is incompatible with await.
if (T.promotedBound case var B?) {
if (isIncompatibleWithAwait(B)) {
return true;
}
return isIncompatibleWithAwait(B);
}
// `T` is a type variable with bound `S`, and `S` is incompatible
// with await.
if (T.element.bound case var S?) {
if (isIncompatibleWithAwait(S)) {
return true;
}
return isIncompatibleWithAwait(S);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ class IsIncompatibleWithAwaitTest extends AbstractTypeSystemTest {
test_typeParameter_promotedBound_extensionType_implementsFuture() {
var futureOfIntNone = futureNone(intNone);

var A = extensionType(
'A',
// Incompatible with `await`, used as a bound.
// Does not matter, `T` is promoted to not incompatible.
var N = extensionType(
'N',
representationType: futureOfIntNone,
);

var F = extensionType(
'F',
representationType: futureOfIntNone,
interfaces: [
futureOfIntNone,
Expand All @@ -125,8 +132,11 @@ class IsIncompatibleWithAwaitTest extends AbstractTypeSystemTest {

isNotIncompatible(
typeParameterTypeNone(
typeParameter('T'),
promotedBound: interfaceTypeNone(A),
typeParameter(
'T',
bound: interfaceTypeNone(N),
),
promotedBound: interfaceTypeNone(F),
),
);
}
Expand Down

0 comments on commit 690d49c

Please sign in to comment.