| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |