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

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

Issue 1893053002: Handle fuzzy optional parameters correctly. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/lib/src/task/strong/checker.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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 /// General type checking tests 7 /// General type checking tests
8 library analyzer.test.src.task.strong.checker_test; 8 library analyzer.test.src.task.strong.checker_test;
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 f = /*warning:DOWN_CAST_COMPOSITE*/right; 730 f = /*warning:DOWN_CAST_COMPOSITE*/right;
731 f = bot; 731 f = bot;
732 } 732 }
733 } 733 }
734 '''); 734 ''');
735 }); 735 });
736 736
737 test('dynamic functions - closures are not fuzzy', () { 737 test('dynamic functions - closures are not fuzzy', () {
738 // Regression test for 738 // Regression test for
739 // https://github.com/dart-lang/sdk/issues/26118 739 // https://github.com/dart-lang/sdk/issues/26118
740 // https://github.com/dart-lang/sdk/issues/26156
740 checkFile(''' 741 checkFile('''
742 void takesF(void f(int x)) {}
743
744 typedef void TakesInt(int x);
745
746 void update(_) {}
747 void updateOpt([_]) {}
748 void updateOptNum([num x]) {}
749
750 class A {
751 TakesInt f;
752 A(TakesInt g) {
753 f = update;
754 f = updateOpt;
755 f = updateOptNum;
756 }
757 TakesInt g(bool a, bool b) {
758 if (a) {
759 return update;
760 } else if (b) {
761 return updateOpt;
762 } else {
763 return updateOptNum;
764 }
765 }
766 }
767
768 void test0() {
769 takesF(update);
770 takesF(updateOpt);
771 takesF(updateOptNum);
772 TakesInt f;
773 f = update;
774 f = updateOpt;
775 f = updateOptNum;
776 new A(update);
777 new A(updateOpt);
778 new A(updateOptNum);
779 }
780
741 void test1() { 781 void test1() {
742 void takesF(f(int x)) => null; 782 void takesF(f(int x)) => null;
743 takesF((dynamic y) => 3); 783 takesF((dynamic y) => 3);
744 } 784 }
745 785
746 void test2() { 786 void test2() {
747 int x; 787 int x;
748 int f/*<T>*/(/*=T*/ t, callback(/*=T*/ x)) { return 3; } 788 int f/*<T>*/(/*=T*/ t, callback(/*=T*/ x)) { return 3; }
749 f(x, (y) => 3); 789 f(x, (y) => 3);
750 } 790 }
(...skipping 2424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 3215
3176 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } 3216 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; }
3177 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } 3217 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; }
3178 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } 3218 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; }
3179 Iterable<int> baz4() sync* { yield* bar3(); } 3219 Iterable<int> baz4() sync* { yield* bar3(); }
3180 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); } 3220 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); }
3181 '''); 3221 ''');
3182 }); 3222 });
3183 }); 3223 });
3184 } 3224 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698