forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Gather constraints from both possibilities for FutureOr
Closes flutter#37778. Bug: http://dartbug.com/37778. Change-Id: Ia8828c27ccc912831a0fea8a473c547184c99229 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115243 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
- Loading branch information
Dmitry Stefantsov
authored and
commit-bot@chromium.org
committed
Sep 10, 2019
1 parent
f1f709e
commit ccb6ba9
Showing
8 changed files
with
109 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
pkg/front_end/test/static_types/data/constraint_gatherer_for_future_or.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// The test checks the gathering of the constraints during type inference in | ||
// case the supertype of the match is a FutureOr<X> or one of its alternatives | ||
// (either Future<X> or X). | ||
|
||
import 'dart:async'; | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
// Gathering constraints for S from comparison Null <: FutureOr<S>. | ||
void func1() { | ||
void foo<S>(FutureOr<S> bar) {} | ||
|
||
/*invoke: void*/ foo/*<Null>*/(/*Null*/ null); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
// Gathering constraints for S from comparison Null <: Future<S>. | ||
void func2() { | ||
void foo<S>(Future<S> bar) {} | ||
|
||
/*invoke: void*/ foo/*<dynamic>*/(/*Null*/ null); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
// Gathering constraints for S from comparison Null <: S. | ||
void func3() { | ||
void foo<S>(S bar) {} | ||
|
||
/*invoke: void*/ foo/*<Null>*/(/*Null*/ null); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
void func4() { | ||
void foo<S>(FutureOr<FutureOr<S>> bar) {} | ||
|
||
/*invoke: void*/ foo/*<Null>*/(/*Null*/ null); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
// Gathering constraints for S from comparison int <: FutureOr<S>. | ||
void func5() { | ||
void foo<S>(FutureOr<S> bar) {} | ||
|
||
/*invoke: void*/ foo/*<int>*/(/*int*/ 42); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
// Gathering constraints for S from comparison int <: S. | ||
void func6() { | ||
void foo<S>(S bar) {} | ||
|
||
/*invoke: void*/ foo/*<int>*/(/*int*/ 42); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
void func7() { | ||
void foo<S>(FutureOr<FutureOr<S>> bar) {} | ||
|
||
/*invoke: void*/ foo/*<int>*/(/*int*/ 42); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters