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

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

Issue 2348583005: fix #27382, tweak inference heuristic when we have no upper bound info (Closed)
Patch Set: Created 4 years, 3 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/generated/type_system.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 /// Tests for type inference. 7 /// Tests for type inference.
8 library analyzer.test.src.task.strong.inferred_type_test; 8 library analyzer.test.src.task.strong.inferred_type_test;
9 9
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 List<A> list = result; 1760 List<A> list = result;
1761 list = result2; 1761 list = result2;
1762 } 1762 }
1763 1763
1764 class A {} 1764 class A {}
1765 class B extends A {} 1765 class B extends A {}
1766 class C extends A {} 1766 class C extends A {}
1767 '''); 1767 ''');
1768 } 1768 }
1769 1769
1770 void test_genericFunctions_returnTypedef() {
1771 checkFile(r'''
1772 typedef void ToValue<T>(T value);
1773
1774 main() {
1775 ToValue/*<T>*/ f/*<T>*/(dynamic /*=T*/ x) => null;
1776 var x = f/*<int>*/(42);
1777 var y = f(42);
1778 ToValue<int> takesInt = x;
1779 takesInt = y;
1780 }
1781 ''');
1782 }
1783
1770 void test_genericMethods_basicDownwardInference() { 1784 void test_genericMethods_basicDownwardInference() {
1771 checkFile(r''' 1785 checkFile(r'''
1772 /*=T*/ f/*<S, T>*/(/*=S*/ s) => null; 1786 /*=T*/ f/*<S, T>*/(/*=S*/ s) => null;
1773 main() { 1787 main() {
1774 String x = f(42); 1788 String x = f(42);
1775 String y = (f)(42); 1789 String y = (f)(42);
1776 } 1790 }
1777 '''); 1791 ''');
1778 } 1792 }
1779 1793
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 } 4568 }
4555 4569
4556 /// Adds a file using [helper.addFile] and calls [helper.check]. 4570 /// Adds a file using [helper.addFile] and calls [helper.check].
4557 /// 4571 ///
4558 /// Also returns the resolved compilation unit. 4572 /// Also returns the resolved compilation unit.
4559 @override 4573 @override
4560 CompilationUnitElement checkFile(String content) { 4574 CompilationUnitElement checkFile(String content) {
4561 return helper.checkFile(content).element; 4575 return helper.checkFile(content).element;
4562 } 4576 }
4563 } 4577 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698