Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: test/checker/checker_test.dart

Issue 1121993004: Inference through conditional expressions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/checker/rules.dart ('k') | test/dart_codegen/expect/async/stream_controller.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/checker/checker_test.dart
diff --git a/test/checker/checker_test.dart b/test/checker/checker_test.dart
index 931ac0b995416f6da3dadc8fc8e58b6051372b98..b1ef888333741a03e6ee35b391fc3d6b9fb32d2b 100644
--- a/test/checker/checker_test.dart
+++ b/test/checker/checker_test.dart
@@ -14,6 +14,37 @@ import '../test_util.dart';
void main() {
configureTest();
+ test('ternary operator', () {
+ testChecker({
+ '/main.dart': '''
+ abstract class Comparable<T> {
+ int compareTo(T other);
+ static int compare(Comparable a, Comparable b) => a.compareTo(b);
+ }
+ typedef int Comparator<T>(T a, T b);
+
+ typedef bool _Predicate<T>(T value);
+
+ class SplayTreeMap<K, V> {
+ Comparator<K> _comparator;
+ _Predicate _validKey;
+
+ // Initializing _comparator needs a cast, since K may not always be
+ // Comparable.
+ // Initializing _validKey shouldn't need a cast. Currently
+ // it requires inference to work because of dartbug.com/23381
+ SplayTreeMap([int compare(K key1, K key2),
+ bool isValidKey(potentialKey)]) {
+ : _comparator = /*warning:DownCastComposite*/(compare == null) ? Comparable.compare : compare,
+ _validKey = /*info:InferredType should be pass*/(isValidKey != null) ? isValidKey : ((v) => true);
+ }
+ }
+ void main() {
+ }
+ '''
+ });
+ });
+
test('dynamic invocation', () {
testChecker({
'/main.dart': '''
« no previous file with comments | « lib/src/checker/rules.dart ('k') | test/dart_codegen/expect/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698