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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2215873002: fix #26512, correct handling of fuzzy arrows in strong mode LUB (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase & fix pass through of arg Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/generated/type_system_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import '../../../reflective_tests.dart'; 7 import '../../../reflective_tests.dart';
8 import 'strong_test_helper.dart'; 8 import 'strong_test_helper.dart';
9 9
10 void main() { 10 void main() {
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 Iterable<double> id; 2605 Iterable<double> id;
2606 int x = 2606 int x =
2607 /*info:ASSIGNMENT_CAST should be error:INVALID_ASSIGNMENT*/ 2607 /*info:ASSIGNMENT_CAST should be error:INVALID_ASSIGNMENT*/
2608 b ? li : id; 2608 b ? li : id;
2609 return /*warning:DOWN_CAST_COMPOSITE should be pass*/b ? li : id; 2609 return /*warning:DOWN_CAST_COMPOSITE should be pass*/b ? li : id;
2610 } 2610 }
2611 } 2611 }
2612 '''); 2612 ''');
2613 } 2613 }
2614 2614
2615 void test_leastUpperBounds_fuzzyArrows() {
2616 checkFile(r'''
2617 typedef String TakesA<T>(T item);
2618
2619 void main() {
2620 TakesA<int> f;
2621 TakesA<dynamic> g;
2622 TakesA<String> h;
2623 g = h;
2624 f = /*warning:DOWN_CAST_COMPOSITE*/f ?? g;
2625 }
2626 ''');
2627 }
2628
2615 void test_loadLibrary() { 2629 void test_loadLibrary() {
2616 addFile('''library lib1;''', name: '/lib1.dart'); 2630 addFile('''library lib1;''', name: '/lib1.dart');
2617 checkFile(r''' 2631 checkFile(r'''
2618 import 'lib1.dart' deferred as lib1; 2632 import 'lib1.dart' deferred as lib1;
2619 import 'dart:async' show Future; 2633 import 'dart:async' show Future;
2620 main() { 2634 main() {
2621 Future f = lib1.loadLibrary(); 2635 Future f = lib1.loadLibrary();
2622 }'''); 2636 }''');
2623 } 2637 }
2624 2638
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 // There's no telling if that will work. For example, consider: 3329 // There's no telling if that will work. For example, consider:
3316 // 3330 //
3317 // new SplayTreeMap<Uri>(); 3331 // new SplayTreeMap<Uri>();
3318 // 3332 //
3319 // This would end up calling .compareTo() on a Uri, which doesn't 3333 // This would end up calling .compareTo() on a Uri, which doesn't
3320 // define that since it doesn't implement Comparable. 3334 // define that since it doesn't implement Comparable.
3321 SplayTreeMap([int compare(K key1, K key2), 3335 SplayTreeMap([int compare(K key1, K key2),
3322 bool isValidKey(potentialKey)]) 3336 bool isValidKey(potentialKey)])
3323 : _comparator = /*warning:DOWN_CAST_COMPOSITE*/(compare == null) ? Comparabl e.compare : compare, 3337 : _comparator = /*warning:DOWN_CAST_COMPOSITE*/(compare == null) ? Comparabl e.compare : compare,
3324 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) { 3338 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) {
3325 _Predicate<Object> v = (isValidKey != null) 3339
3340 // NOTE: this is a down cast because isValidKey has fuzzy arrow type.
3341 _Predicate<Object> v = /*warning:DOWN_CAST_COMPOSITE*/(isValidKey != null)
3326 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); 3342 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
3327 3343
3328 v = (isValidKey != null) 3344 v = (isValidKey != null)
3329 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); 3345 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
3330 } 3346 }
3331 } 3347 }
3332 void main() { 3348 void main() {
3333 Object obj = 42; 3349 Object obj = 42;
3334 dynamic dyn = 42; 3350 dynamic dyn = 42;
3335 int i = 42; 3351 int i = 42;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 // Regression test for https://github.com/dart-lang/sdk/issues/25069 3625 // Regression test for https://github.com/dart-lang/sdk/issues/25069
3610 checkFile(''' 3626 checkFile('''
3611 typedef int Foo(); 3627 typedef int Foo();
3612 void foo() {} 3628 void foo() {}
3613 void main () { 3629 void main () {
3614 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 3630 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
3615 } 3631 }
3616 '''); 3632 ''');
3617 } 3633 }
3618 } 3634 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/type_system_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698