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

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

Issue 2295853002: fix #26992, inference failures are now an error (Closed)
Patch Set: fix comment 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/test/src/task/strong/checker_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 // 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 void test_constructors_inferFromArguments() { 619 void test_constructors_inferFromArguments() {
620 var unit = checkFile(''' 620 var unit = checkFile('''
621 class C<T> { 621 class C<T> {
622 T t; 622 T t;
623 C(this.t); 623 C(this.t);
624 } 624 }
625 625
626 var x = /*info:INFERRED_TYPE_ALLOCATION*/new C(42); 626 var x = /*info:INFERRED_TYPE_ALLOCATION*/new C(42);
627 627
628 // Don't infer if we had a context type.
629 num y; 628 num y;
630 C<int> c_int = /*info:INFERRED_TYPE_ALLOCATION*/new C(/*info:DOWN_CAST_IMPLICIT* /y); 629 C<int> c_int = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFER*/C(/ *info:DOWN_CAST_IMPLICIT*/y);
631 630
632 // These hints are not reported because we resolve with a null error listener. 631 // These hints are not reported because we resolve with a null error listener.
633 C<num> c_num = /*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(123); 632 C<num> c_num = /*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(123);
634 C<num> c_num2 = (/*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(456)) 633 C<num> c_num2 = (/*pass should be info:INFERRED_TYPE_ALLOCATION*/new C(456))
635 ..t = /*error:INVALID_ASSIGNMENT*/1.0; 634 ..t = /*error:INVALID_ASSIGNMENT*/1.0;
636 635
637 // Down't infer from explicit dynamic. 636 // Down't infer from explicit dynamic.
638 var c_dynamic = new C<dynamic>(42); 637 var c_dynamic = new C<dynamic>(42);
639 638
640 main() { 639 main() {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 void main() { 1217 void main() {
1219 { 1218 {
1220 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new A(3, "hello"); 1219 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new A(3, "hello");
1221 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new A.named(3, "hello") ; 1220 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new A.named(3, "hello") ;
1222 A<int, String> a2 = new A<int, String>(3, "hello"); 1221 A<int, String> a2 = new A<int, String>(3, "hello");
1223 A<int, String> a3 = new A<int, String>.named(3, "hello"); 1222 A<int, String> a3 = new A<int, String>.named(3, "hello");
1224 A<int, String> a4 = /*error:STATIC_TYPE_ERROR*/new A<int, dynamic>(3, "hello "); 1223 A<int, String> a4 = /*error:STATIC_TYPE_ERROR*/new A<int, dynamic>(3, "hello ");
1225 A<int, String> a5 = /*error:STATIC_TYPE_ERROR*/new A<dynamic, dynamic>.named (3, "hello"); 1224 A<int, String> a5 = /*error:STATIC_TYPE_ERROR*/new A<dynamic, dynamic>.named (3, "hello");
1226 } 1225 }
1227 { 1226 {
1228 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new A( 1227 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER,error:COULD_NOT_INFER*/A(
1229 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", 1228 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello",
1230 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 1229 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
1231 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new A.named( 1230 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER,error:COULD_NOT_INFER*/A.named(
1232 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", 1231 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello",
1233 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 1232 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
1234 } 1233 }
1235 { 1234 {
1236 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new B("hello", 3); 1235 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new B("hello", 3);
1237 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new B.named("hello", 3) ; 1236 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new B.named("hello", 3) ;
1238 A<int, String> a2 = new B<String, int>("hello", 3); 1237 A<int, String> a2 = new B<String, int>("hello", 3);
1239 A<int, String> a3 = new B<String, int>.named("hello", 3); 1238 A<int, String> a3 = new B<String, int>.named("hello", 3);
1240 A<int, String> a4 = /*error:INVALID_ASSIGNMENT*/new B<String, dynamic>("hell o", 3); 1239 A<int, String> a4 = /*error:INVALID_ASSIGNMENT*/new B<String, dynamic>("hell o", 3);
1241 A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new B<dynamic, dynamic>.name d("hello", 3); 1240 A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new B<dynamic, dynamic>.name d("hello", 3);
1242 } 1241 }
1243 { 1242 {
1244 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new B( 1243 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER,error:COULD_NOT_INFER*/B(
1245 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3, 1244 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3,
1246 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 1245 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
1247 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new B.named( 1246 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER,error:COULD_NOT_INFER*/B.named(
1248 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3, 1247 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3,
1249 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 1248 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
1250 } 1249 }
1251 { 1250 {
1252 A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new C(3); 1251 A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new C(3);
1253 A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new C.named(3); 1252 A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new C.named(3);
1254 A<int, int> a2 = new C<int>(3); 1253 A<int, int> a2 = new C<int>(3);
1255 A<int, int> a3 = new C<int>.named(3); 1254 A<int, int> a3 = new C<int>.named(3);
1256 A<int, int> a4 = /*error:INVALID_ASSIGNMENT*/new C<dynamic>(3); 1255 A<int, int> a4 = /*error:INVALID_ASSIGNMENT*/new C<dynamic>(3);
1257 A<int, int> a5 = /*error:INVALID_ASSIGNMENT*/new C<dynamic>.named(3); 1256 A<int, int> a5 = /*error:INVALID_ASSIGNMENT*/new C<dynamic>.named(3);
1258 } 1257 }
1259 { 1258 {
1260 A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new C( 1259 A<int, int> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFE R*/C(
1261 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 1260 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
1262 A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new C.named( 1261 A<int, int> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_INFE R*/C.named(
1263 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 1262 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
1264 } 1263 }
1265 { 1264 {
1266 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new D("hello"); 1265 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new D("hello");
1267 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new D.named("hello"); 1266 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new D.named("hello");
1268 A<int, String> a2 = new D<int, String>("hello"); 1267 A<int, String> a2 = new D<int, String>("hello");
1269 A<int, String> a3 = new D<String, String>.named("hello"); 1268 A<int, String> a3 = new D<String, String>.named("hello");
1270 A<int, String> a4 = /*error:INVALID_ASSIGNMENT*/new D<num, dynamic>("hello") ; 1269 A<int, String> a4 = /*error:INVALID_ASSIGNMENT*/new D<num, dynamic>("hello") ;
1271 A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new D<dynamic, dynamic>.name d("hello"); 1270 A<int, String> a5 = /*error:INVALID_ASSIGNMENT*/new D<dynamic, dynamic>.name d("hello");
1272 } 1271 }
1273 { 1272 {
1274 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new D( 1273 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER*/D(
1275 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 1274 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
1276 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new D.named( 1275 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER*/D.named(
1277 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 1276 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
1278 } 1277 }
1279 { 1278 {
1280 A<C<int>, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new E("hello"); 1279 A<C<int>, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new E("hello");
1281 } 1280 }
1282 { // Check named and optional arguments 1281 { // Check named and optional arguments
1283 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new F(3, "hello", 1282 A<int, String> a0 = /*info:INFERRED_TYPE_ALLOCATION*/new F(3, "hello",
1284 a: /*info:INFERRED_TYPE_LITERAL*/[3], 1283 a: /*info:INFERRED_TYPE_LITERAL*/[3],
1285 b: /*info:INFERRED_TYPE_LITERAL*/["hello"]); 1284 b: /*info:INFERRED_TYPE_LITERAL*/["hello"]);
1286 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new F(3, "hello", 1285 A<int, String> a1 = /*info:INFERRED_TYPE_ALLOCATION*/new F(3, "hello",
1287 a: /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNAB LE*/"hello"], 1286 a: /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNAB LE*/"hello"],
1288 b: /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNAB LE*/3]); 1287 b: /*info:INFERRED_TYPE_LITERAL*/[/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNAB LE*/3]);
1289 A<int, String> a2 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello", 3, "hello"); 1288 A<int, String> a2 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello", 3, "hello");
1290 A<int, String> a3 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello") ; 1289 A<int, String> a3 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello") ;
1291 A<int, String> a4 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello", 1290 A<int, String> a4 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER,error:COULD_NOT_INFER*/F.named(3, "hello",
1292 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*error:ARGUMENT_TYPE_NOT _ASSIGNABLE*/3); 1291 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*error:ARGUMENT_TYPE_NOT _ASSIGNABLE*/3);
1293 A<int, String> a5 = /*info:INFERRED_TYPE_ALLOCATION*/new F.named(3, "hello", 1292 A<int, String> a5 = /*info:INFERRED_TYPE_ALLOCATION*/new /*error:COULD_NOT_I NFER*/F.named(3, "hello",
1294 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello"); 1293 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello");
1295 } 1294 }
1296 } 1295 }
1297 '''); 1296 ''');
1298 } 1297 }
1299 1298
1300 void test_downwardsInferenceOnListLiterals_inferDownwards() { 1299 void test_downwardsInferenceOnListLiterals_inferDownwards() {
1301 checkFile(''' 1300 checkFile('''
1302 void foo([List<String> list1 = /*info:INFERRED_TYPE_LITERAL*/const [], 1301 void foo([List<String> list1 = /*info:INFERRED_TYPE_LITERAL*/const [],
1303 List<String> list2 = /*info:INFERRED_TYPE_LITERAL*/const [/*error:LIST _ELEMENT_TYPE_NOT_ASSIGNABLE,error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/42]]) { 1302 List<String> list2 = /*info:INFERRED_TYPE_LITERAL*/const [/*error:LIST _ELEMENT_TYPE_NOT_ASSIGNABLE,error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/42]]) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 class MyFuture<T> implements Future<T> { 1698 class MyFuture<T> implements Future<T> {
1700 MyFuture() {} 1699 MyFuture() {}
1701 MyFuture.value([T x]) {} 1700 MyFuture.value([T x]) {}
1702 dynamic noSuchMethod(invocation); 1701 dynamic noSuchMethod(invocation);
1703 MyFuture/*<S>*/ then/*<S>*/(dynamic f(T x), {Function onError}) => null; 1702 MyFuture/*<S>*/ then/*<S>*/(dynamic f(T x), {Function onError}) => null;
1704 } 1703 }
1705 1704
1706 $declared f; 1705 $declared f;
1707 // Instantiates Future<int> 1706 // Instantiates Future<int>
1708 $downwards<int> t1 = f.then((_) => 1707 $downwards<int> t1 = f.then((_) =>
1709 ${allocInfo}new $upwards.value( 1708 ${allocInfo}new /*error:COULD_NOT_INFER*/$upwards.value(
1710 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/'hi')); 1709 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/'hi'));
1711 1710
1712 // Instantiates List<int> 1711 // Instantiates List<int>
1713 $downwards<List<int>> t2 = f.then((_) => /*info:INFERRED_TYPE_LITERAL*/[3]); 1712 $downwards<List<int>> t2 = f.then((_) => /*info:INFERRED_TYPE_LITERAL*/[3]);
1714 $downwards<List<int>> g2() async { return /*info:INFERRED_TYPE_LITERAL*/[3]; } 1713 $downwards<List<int>> g2() async { return /*info:INFERRED_TYPE_LITERAL*/[3]; }
1715 $downwards<List<int>> g3() async { 1714 $downwards<List<int>> g3() async {
1716 return /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value( 1715 return /*info:INFERRED_TYPE_ALLOCATION*/new $upwards.value(
1717 /*info:INFERRED_TYPE_LITERAL*/[3]); } 1716 /*info:INFERRED_TYPE_LITERAL*/[3]); }
1718 '''; 1717 ''';
1719 } 1718 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 String s; 1766 String s;
1768 var a = new Foo().method/*<String>*/("str"); 1767 var a = new Foo().method/*<String>*/("str");
1769 s = a; 1768 s = a;
1770 new Foo(); 1769 new Foo();
1771 1770
1772 var b = new Foo<String>().method("str"); 1771 var b = new Foo<String>().method("str");
1773 s = b; 1772 s = b;
1774 var c = new Foo().method("str"); 1773 var c = new Foo().method("str");
1775 s = c; 1774 s = c;
1776 1775
1777 new Foo<String>().method(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/42); 1776 new Foo<String>()./*error:COULD_NOT_INFER*/method(/*error:ARGUMENT_TYPE_NOT_AS SIGNABLE*/42);
1778 } 1777 }
1779 '''); 1778 ''');
1780 } 1779 }
1781 1780
1782 void test_genericMethods_dartMathMinMax() { 1781 void test_genericMethods_dartMathMinMax() {
1783 checkFile(''' 1782 checkFile('''
1784 import 'dart:math'; 1783 import 'dart:math';
1785 1784
1786 void printInt(int x) => print(x); 1785 void printInt(int x) => print(x);
1787 void printDouble(double x) => print(x); 1786 void printDouble(double x) => print(x);
1788 1787
1789 num myMax(num x, num y) => max(x, y); 1788 num myMax(num x, num y) => max(x, y);
1790 1789
1791 main() { 1790 main() {
1792 // Okay if static types match. 1791 // Okay if static types match.
1793 printInt(max(1, 2)); 1792 printInt(max(1, 2));
1794 printInt(min(1, 2)); 1793 printInt(min(1, 2));
1795 printDouble(max(1.0, 2.0)); 1794 printDouble(max(1.0, 2.0));
1796 printDouble(min(1.0, 2.0)); 1795 printDouble(min(1.0, 2.0));
1797 1796
1798 // No help for user-defined functions from num->num->num. 1797 // No help for user-defined functions from num->num->num.
1799 printInt(/*info:DOWN_CAST_IMPLICIT*/myMax(1, 2)); 1798 printInt(/*info:DOWN_CAST_IMPLICIT*/myMax(1, 2));
1800 printInt(myMax(1, 2) as int); 1799 printInt(myMax(1, 2) as int);
1801 1800
1802 // Mixing int and double means return type is num. 1801 // Mixing int and double means return type is num.
1803 printInt(/*info:DOWN_CAST_IMPLICIT*/max(1, 2.0)); 1802 printInt(/*error:COULD_NOT_INFER*/max(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE* /2.0));
1804 printInt(/*info:DOWN_CAST_IMPLICIT*/min(1, 2.0)); 1803 printInt(/*error:COULD_NOT_INFER*/min(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE* /2.0));
1805 printDouble(/*info:DOWN_CAST_IMPLICIT*/max(1, 2.0)); 1804 printDouble(/*error:COULD_NOT_INFER*/max(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE* /1, 2.0));
1806 printDouble(/*info:DOWN_CAST_IMPLICIT*/min(1, 2.0)); 1805 printDouble(/*error:COULD_NOT_INFER*/min(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE* /1, 2.0));
1807 1806
1808 // Types other than int and double are not accepted. 1807 // Types other than int and double are not accepted.
1809 printInt( 1808 printInt(
1810 /*info:DOWN_CAST_IMPLICIT*/min( 1809 /*error:COULD_NOT_INFER*/min(
1811 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hi", 1810 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hi",
1812 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"there")); 1811 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"there"));
1813 } 1812 }
1814 '''); 1813 ''');
1815 } 1814 }
1816 1815
1817 void test_genericMethods_doNotInferInvalidOverrideOfGenericMethod() { 1816 void test_genericMethods_doNotInferInvalidOverrideOfGenericMethod() {
1818 checkFile(''' 1817 checkFile('''
1819 class C { 1818 class C {
1820 /*=T*/ m/*<T>*/(/*=T*/ x) => x; 1819 /*=T*/ m/*<T>*/(/*=T*/ x) => x;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 /*=T*/ m/*<T>*/(/*=T*/ x) => x; 1869 /*=T*/ m/*<T>*/(/*=T*/ x) => x;
1871 /*=T*/ g/*<T>*/(/*=T*/ x) => x; 1870 /*=T*/ g/*<T>*/(/*=T*/ x) => x;
1872 } 1871 }
1873 main() { 1872 main() {
1874 int y = /*info:DYNAMIC_CAST*/(/*info:UNNECESSARY_CAST*/new D() as C).m(42); 1873 int y = /*info:DYNAMIC_CAST*/(/*info:UNNECESSARY_CAST*/new D() as C).m(42);
1875 print(y); 1874 print(y);
1876 } 1875 }
1877 '''); 1876 ''');
1878 } 1877 }
1879 1878
1879 void test_genericMethods_inferenceError() {
1880 checkFile(r'''
1881 main() {
1882 List<String> y;
1883 Iterable<String> x = y./*error:COULD_NOT_INFER*/map(/*error:ARGUMENT_TYPE_NOT_ ASSIGNABLE*/(String z) => 1.0);
1884 }
1885 ''');
1886 }
1887
1880 void test_genericMethods_inferGenericFunctionParameterType() { 1888 void test_genericMethods_inferGenericFunctionParameterType() {
1881 var mainUnit = checkFile(''' 1889 var mainUnit = checkFile('''
1882 class C<T> extends D<T> { 1890 class C<T> extends D<T> {
1883 f/*<U>*/(x) {} 1891 f/*<U>*/(x) {}
1884 } 1892 }
1885 class D<T> { 1893 class D<T> {
1886 F/*<U>*/ f/*<U>*/(/*=U*/ u) => null; 1894 F/*<U>*/ f/*<U>*/(/*=U*/ u) => null;
1887 } 1895 }
1888 typedef void F<V>(V v); 1896 typedef void F<V>(V v);
1889 '''); 1897 ''');
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4525 } 4533 }
4526 4534
4527 /// Adds a file using [helper.addFile] and calls [helper.check]. 4535 /// Adds a file using [helper.addFile] and calls [helper.check].
4528 /// 4536 ///
4529 /// Also returns the resolved compilation unit. 4537 /// Also returns the resolved compilation unit.
4530 @override 4538 @override
4531 CompilationUnitElement checkFile(String content) { 4539 CompilationUnitElement checkFile(String content) {
4532 return helper.checkFile(content).element; 4540 return helper.checkFile(content).element;
4533 } 4541 }
4534 } 4542 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/strong/checker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698