Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.compile_time_error_code_test; | 5 library analyzer.test.generated.compile_time_error_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/error.dart'; | 7 import 'package:analyzer/src/generated/error.dart'; |
| 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 | 10 |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 final int i = f(); | 890 final int i = f(); |
| 891 const A(); | 891 const A(); |
| 892 } | 892 } |
| 893 int f() { | 893 int f() { |
| 894 return 3; | 894 return 3; |
| 895 }'''); | 895 }'''); |
| 896 computeLibrarySourceErrors(source); | 896 computeLibrarySourceErrors(source); |
| 897 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is | 897 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is |
| 898 // redundant and ought to be suppressed. | 898 // redundant and ought to be suppressed. |
| 899 assertErrors(source, [ | 899 assertErrors(source, [ |
| 900 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST , | 900 CompileTimeErrorCode |
| 901 .CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST, | |
| 901 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE | 902 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE |
| 902 ]); | 903 ]); |
| 903 verify([source]); | 904 verify([source]); |
| 904 } | 905 } |
| 905 | 906 |
| 906 void test_constConstructorWithFieldInitializedByNonConst_static() { | 907 void test_constConstructorWithFieldInitializedByNonConst_static() { |
| 907 Source source = addSource(r''' | 908 Source source = addSource(r''' |
| 908 class A { | 909 class A { |
| 909 static final int i = f(); | 910 static final int i = f(); |
| 910 const A(); | 911 const A(); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1258 Source source = addSource(r''' | 1259 Source source = addSource(r''' |
| 1259 f(p) { | 1260 f(p) { |
| 1260 const C = p; | 1261 const C = p; |
| 1261 }'''); | 1262 }'''); |
| 1262 computeLibrarySourceErrors(source); | 1263 computeLibrarySourceErrors(source); |
| 1263 assertErrors(source, | 1264 assertErrors(source, |
| 1264 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | 1265 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
| 1265 verify([source]); | 1266 verify([source]); |
| 1266 } | 1267 } |
| 1267 | 1268 |
| 1269 void test_constInitializedWithNonConstValue_finalField() { | |
|
Brian Wilkerson
2016/01/23 17:32:26
Seems like we ought to have at least one test of t
skybrian
2016/01/26 02:07:14
This test is implicitly a regression test. It show
| |
| 1270 Source source = addSource(r''' | |
| 1271 class Foo { | |
| 1272 final field = []; | |
| 1273 foo([int x = field]) {} | |
| 1274 } | |
| 1275 '''); | |
| 1276 computeLibrarySourceErrors(source); | |
| 1277 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | |
| 1278 verify([source]); | |
| 1279 } | |
| 1280 | |
| 1268 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { | 1281 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { |
| 1269 Source source = addSource("const List L = [0];"); | 1282 Source source = addSource("const List L = [0];"); |
| 1270 computeLibrarySourceErrors(source); | 1283 computeLibrarySourceErrors(source); |
| 1271 assertErrors(source, | 1284 assertErrors(source, |
| 1272 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | 1285 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
| 1273 verify([source]); | 1286 verify([source]); |
| 1274 } | 1287 } |
| 1275 | 1288 |
| 1276 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { | 1289 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { |
| 1277 Source source = addSource("const Map M = {'a' : 0};"); | 1290 Source source = addSource("const Map M = {'a' : 0};"); |
| 1278 computeLibrarySourceErrors(source); | 1291 computeLibrarySourceErrors(source); |
| 1279 assertErrors(source, | 1292 assertErrors(source, |
| 1280 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); | 1293 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); |
| 1281 verify([source]); | 1294 verify([source]); |
| 1282 } | 1295 } |
| 1283 | 1296 |
| 1284 void test_constInitializedWithNonConstValueFromDeferredClass() { | 1297 void test_constInitializedWithNonConstValueFromDeferredClass() { |
| 1285 resolveWithErrors(<String>[ | 1298 resolveWithErrors(<String>[ |
| 1286 r''' | 1299 r''' |
| 1287 library lib1; | 1300 library lib1; |
| 1288 const V = 1;''', | 1301 const V = 1;''', |
| 1289 r''' | 1302 r''' |
| 1290 library root; | 1303 library root; |
| 1291 import 'lib1.dart' deferred as a; | 1304 import 'lib1.dart' deferred as a; |
| 1292 const B = a.V;''' | 1305 const B = a.V;''' |
| 1293 ], <ErrorCode>[ | 1306 ], <ErrorCode>[ |
| 1294 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERR ED_LIBRARY | 1307 CompileTimeErrorCode |
|
skybrian
2016/01/23 04:07:36
I believe this is reversing a dartfmt I did with a
Brian Wilkerson
2016/01/23 17:32:26
No problem. It's unavoidable.
| |
| 1308 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY | |
| 1295 ]); | 1309 ]); |
| 1296 } | 1310 } |
| 1297 | 1311 |
| 1298 void test_constInitializedWithNonConstValueFromDeferredClass_nested() { | 1312 void test_constInitializedWithNonConstValueFromDeferredClass_nested() { |
| 1299 resolveWithErrors(<String>[ | 1313 resolveWithErrors(<String>[ |
| 1300 r''' | 1314 r''' |
| 1301 library lib1; | 1315 library lib1; |
| 1302 const V = 1;''', | 1316 const V = 1;''', |
| 1303 r''' | 1317 r''' |
| 1304 library root; | 1318 library root; |
| 1305 import 'lib1.dart' deferred as a; | 1319 import 'lib1.dart' deferred as a; |
| 1306 const B = a.V + 1;''' | 1320 const B = a.V + 1;''' |
| 1307 ], <ErrorCode>[ | 1321 ], <ErrorCode>[ |
| 1308 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERR ED_LIBRARY | 1322 CompileTimeErrorCode |
| 1323 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY | |
| 1309 ]); | 1324 ]); |
| 1310 } | 1325 } |
| 1311 | 1326 |
| 1312 void test_constInstanceField() { | 1327 void test_constInstanceField() { |
| 1313 Source source = addSource(r''' | 1328 Source source = addSource(r''' |
| 1314 class C { | 1329 class C { |
| 1315 const int f = 0; | 1330 const int f = 0; |
| 1316 }'''); | 1331 }'''); |
| 1317 computeLibrarySourceErrors(source); | 1332 computeLibrarySourceErrors(source); |
| 1318 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); | 1333 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1820 } | 1835 } |
| 1821 class B extends A { | 1836 class B extends A { |
| 1822 static int get x => 0; | 1837 static int get x => 0; |
| 1823 }'''); | 1838 }'''); |
| 1824 computeLibrarySourceErrors(source); | 1839 computeLibrarySourceErrors(source); |
| 1825 assertErrors( | 1840 assertErrors( |
| 1826 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1841 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| 1827 verify([source]); | 1842 verify([source]); |
| 1828 } | 1843 } |
| 1829 | 1844 |
| 1830 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() { | 1845 void |
| 1846 test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() { | |
| 1831 Source source = addSource(r''' | 1847 Source source = addSource(r''' |
| 1832 abstract class A { | 1848 abstract class A { |
| 1833 int get x; | 1849 int get x; |
| 1834 } | 1850 } |
| 1835 class B extends A { | 1851 class B extends A { |
| 1836 static int get x => 0; | 1852 static int get x => 0; |
| 1837 }'''); | 1853 }'''); |
| 1838 computeLibrarySourceErrors(source); | 1854 computeLibrarySourceErrors(source); |
| 1839 assertErrors( | 1855 assertErrors( |
| 1840 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1856 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| 1841 verify([source]); | 1857 verify([source]); |
| 1842 } | 1858 } |
| 1843 | 1859 |
| 1844 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { | 1860 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { |
| 1845 Source source = addSource(r''' | 1861 Source source = addSource(r''' |
| 1846 class A { | 1862 class A { |
| 1847 x() {} | 1863 x() {} |
| 1848 } | 1864 } |
| 1849 class B extends A { | 1865 class B extends A { |
| 1850 static x() {} | 1866 static x() {} |
| 1851 }'''); | 1867 }'''); |
| 1852 computeLibrarySourceErrors(source); | 1868 computeLibrarySourceErrors(source); |
| 1853 assertErrors( | 1869 assertErrors( |
| 1854 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1870 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| 1855 verify([source]); | 1871 verify([source]); |
| 1856 } | 1872 } |
| 1857 | 1873 |
| 1858 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() { | 1874 void |
| 1875 test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() { | |
| 1859 Source source = addSource(r''' | 1876 Source source = addSource(r''' |
| 1860 abstract class A { | 1877 abstract class A { |
| 1861 x(); | 1878 x(); |
| 1862 } | 1879 } |
| 1863 abstract class B extends A { | 1880 abstract class B extends A { |
| 1864 static x() {} | 1881 static x() {} |
| 1865 }'''); | 1882 }'''); |
| 1866 computeLibrarySourceErrors(source); | 1883 computeLibrarySourceErrors(source); |
| 1867 assertErrors( | 1884 assertErrors( |
| 1868 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1885 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| 1869 verify([source]); | 1886 verify([source]); |
| 1870 } | 1887 } |
| 1871 | 1888 |
| 1872 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { | 1889 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { |
| 1873 Source source = addSource(r''' | 1890 Source source = addSource(r''' |
| 1874 class A { | 1891 class A { |
| 1875 set x(value) {} | 1892 set x(value) {} |
| 1876 } | 1893 } |
| 1877 class B extends A { | 1894 class B extends A { |
| 1878 static set x(value) {} | 1895 static set x(value) {} |
| 1879 }'''); | 1896 }'''); |
| 1880 computeLibrarySourceErrors(source); | 1897 computeLibrarySourceErrors(source); |
| 1881 assertErrors( | 1898 assertErrors( |
| 1882 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1899 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| 1883 verify([source]); | 1900 verify([source]); |
| 1884 } | 1901 } |
| 1885 | 1902 |
| 1886 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() { | 1903 void |
| 1904 test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() { | |
| 1887 Source source = addSource(r''' | 1905 Source source = addSource(r''' |
| 1888 abstract class A { | 1906 abstract class A { |
| 1889 set x(value); | 1907 set x(value); |
| 1890 } | 1908 } |
| 1891 class B extends A { | 1909 class B extends A { |
| 1892 static set x(value) {} | 1910 static set x(value) {} |
| 1893 }'''); | 1911 }'''); |
| 1894 computeLibrarySourceErrors(source); | 1912 computeLibrarySourceErrors(source); |
| 1895 assertErrors( | 1913 assertErrors( |
| 1896 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 1914 source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1960 assertErrors(source, [ | 1978 assertErrors(source, [ |
| 1961 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 1979 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 1962 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT | 1980 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT |
| 1963 ]); | 1981 ]); |
| 1964 verify([source]); | 1982 verify([source]); |
| 1965 } | 1983 } |
| 1966 | 1984 |
| 1967 void test_extendsDisallowedClass_class_double() { | 1985 void test_extendsDisallowedClass_class_double() { |
| 1968 Source source = addSource("class A extends double {}"); | 1986 Source source = addSource("class A extends double {}"); |
| 1969 computeLibrarySourceErrors(source); | 1987 computeLibrarySourceErrors(source); |
| 1970 assertErrors(source, [ | 1988 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); |
| 1971 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS | |
| 1972 ]); | |
| 1973 verify([source]); | 1989 verify([source]); |
| 1974 } | 1990 } |
| 1975 | 1991 |
| 1976 void test_extendsDisallowedClass_class_int() { | 1992 void test_extendsDisallowedClass_class_int() { |
| 1977 Source source = addSource("class A extends int {}"); | 1993 Source source = addSource("class A extends int {}"); |
| 1978 computeLibrarySourceErrors(source); | 1994 computeLibrarySourceErrors(source); |
| 1979 assertErrors(source, [ | 1995 assertErrors(source, [ |
| 1980 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 1996 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 1981 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT | 1997 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT |
| 1982 ]); | 1998 ]); |
| 1983 verify([source]); | 1999 verify([source]); |
| 1984 } | 2000 } |
| 1985 | 2001 |
| 1986 void test_extendsDisallowedClass_class_Null() { | 2002 void test_extendsDisallowedClass_class_Null() { |
| 1987 Source source = addSource("class A extends Null {}"); | 2003 Source source = addSource("class A extends Null {}"); |
| 1988 computeLibrarySourceErrors(source); | 2004 computeLibrarySourceErrors(source); |
| 1989 assertErrors(source, [ | 2005 assertErrors(source, [ |
| 1990 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 2006 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 1991 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT | 2007 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT |
| 1992 ]); | 2008 ]); |
| 1993 verify([source]); | 2009 verify([source]); |
| 1994 } | 2010 } |
| 1995 | 2011 |
| 1996 void test_extendsDisallowedClass_class_num() { | 2012 void test_extendsDisallowedClass_class_num() { |
| 1997 Source source = addSource("class A extends num {}"); | 2013 Source source = addSource("class A extends num {}"); |
| 1998 computeLibrarySourceErrors(source); | 2014 computeLibrarySourceErrors(source); |
| 1999 assertErrors(source, [ | 2015 assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); |
| 2000 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS | |
| 2001 ]); | |
| 2002 verify([source]); | 2016 verify([source]); |
| 2003 } | 2017 } |
| 2004 | 2018 |
| 2005 void test_extendsDisallowedClass_class_String() { | 2019 void test_extendsDisallowedClass_class_String() { |
| 2006 Source source = addSource("class A extends String {}"); | 2020 Source source = addSource("class A extends String {}"); |
| 2007 computeLibrarySourceErrors(source); | 2021 computeLibrarySourceErrors(source); |
| 2008 assertErrors(source, [ | 2022 assertErrors(source, [ |
| 2009 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 2023 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 2010 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT | 2024 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT |
| 2011 ]); | 2025 ]); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2631 class A { | 2645 class A { |
| 2632 static var F = m(); | 2646 static var F = m(); |
| 2633 m() {} | 2647 m() {} |
| 2634 }'''); | 2648 }'''); |
| 2635 computeLibrarySourceErrors(source); | 2649 computeLibrarySourceErrors(source); |
| 2636 assertErrors( | 2650 assertErrors( |
| 2637 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 2651 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); |
| 2638 verify([source]); | 2652 verify([source]); |
| 2639 } | 2653 } |
| 2640 | 2654 |
| 2641 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation( ) { | 2655 void |
| 2656 test_implicitThisReferenceInInitializer_redirectingConstructorInvocation() { | |
| 2642 Source source = addSource(r''' | 2657 Source source = addSource(r''' |
| 2643 class A { | 2658 class A { |
| 2644 A(p) {} | 2659 A(p) {} |
| 2645 A.named() : this(f); | 2660 A.named() : this(f); |
| 2646 var f; | 2661 var f; |
| 2647 }'''); | 2662 }'''); |
| 2648 computeLibrarySourceErrors(source); | 2663 computeLibrarySourceErrors(source); |
| 2649 assertErrors( | 2664 assertErrors( |
| 2650 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 2665 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); |
| 2651 verify([source]); | 2666 verify([source]); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2997 Source source = addSource(r''' | 3012 Source source = addSource(r''' |
| 2998 import 'lib.dart' as p; | 3013 import 'lib.dart' as p; |
| 2999 @p.V | 3014 @p.V |
| 3000 main() { | 3015 main() { |
| 3001 }'''); | 3016 }'''); |
| 3002 computeLibrarySourceErrors(source); | 3017 computeLibrarySourceErrors(source); |
| 3003 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 3018 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 3004 verify([source]); | 3019 verify([source]); |
| 3005 } | 3020 } |
| 3006 | 3021 |
| 3007 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio n() { | 3022 void |
| 3023 test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation () { | |
| 3008 addNamedSource( | 3024 addNamedSource( |
| 3009 "/lib.dart", | 3025 "/lib.dart", |
| 3010 r''' | 3026 r''' |
| 3011 library lib; | 3027 library lib; |
| 3012 typedef V();'''); | 3028 typedef V();'''); |
| 3013 Source source = addSource(r''' | 3029 Source source = addSource(r''' |
| 3014 import 'lib.dart' as p; | 3030 import 'lib.dart' as p; |
| 3015 @p.V | 3031 @p.V |
| 3016 main() { | 3032 main() { |
| 3017 }'''); | 3033 }'''); |
| (...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4646 library lib1; | 4662 library lib1; |
| 4647 const int c = 1;''', | 4663 const int c = 1;''', |
| 4648 r''' | 4664 r''' |
| 4649 library root; | 4665 library root; |
| 4650 import 'lib1.dart' deferred as a; | 4666 import 'lib1.dart' deferred as a; |
| 4651 class A { | 4667 class A { |
| 4652 final int x; | 4668 final int x; |
| 4653 const A() : x = a.c; | 4669 const A() : x = a.c; |
| 4654 }''' | 4670 }''' |
| 4655 ], <ErrorCode>[ | 4671 ], <ErrorCode>[ |
| 4656 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRA RY | 4672 CompileTimeErrorCode |
| 4673 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY | |
| 4657 ]); | 4674 ]); |
| 4658 } | 4675 } |
| 4659 | 4676 |
| 4660 void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() { | 4677 void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() { |
| 4661 resolveWithErrors(<String>[ | 4678 resolveWithErrors(<String>[ |
| 4662 r''' | 4679 r''' |
| 4663 library lib1; | 4680 library lib1; |
| 4664 const int c = 1;''', | 4681 const int c = 1;''', |
| 4665 r''' | 4682 r''' |
| 4666 library root; | 4683 library root; |
| 4667 import 'lib1.dart' deferred as a; | 4684 import 'lib1.dart' deferred as a; |
| 4668 class A { | 4685 class A { |
| 4669 final int x; | 4686 final int x; |
| 4670 const A() : x = a.c + 1; | 4687 const A() : x = a.c + 1; |
| 4671 }''' | 4688 }''' |
| 4672 ], <ErrorCode>[ | 4689 ], <ErrorCode>[ |
| 4673 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRA RY | 4690 CompileTimeErrorCode |
| 4691 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY | |
| 4674 ]); | 4692 ]); |
| 4675 } | 4693 } |
| 4676 | 4694 |
| 4677 void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() { | 4695 void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() { |
| 4678 resolveWithErrors(<String>[ | 4696 resolveWithErrors(<String>[ |
| 4679 r''' | 4697 r''' |
| 4680 library lib1; | 4698 library lib1; |
| 4681 const int c = 1;''', | 4699 const int c = 1;''', |
| 4682 r''' | 4700 r''' |
| 4683 library root; | 4701 library root; |
| 4684 import 'lib1.dart' deferred as a; | 4702 import 'lib1.dart' deferred as a; |
| 4685 class A { | 4703 class A { |
| 4686 const A.named(p); | 4704 const A.named(p); |
| 4687 const A() : this.named(a.c); | 4705 const A() : this.named(a.c); |
| 4688 }''' | 4706 }''' |
| 4689 ], <ErrorCode>[ | 4707 ], <ErrorCode>[ |
| 4690 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRA RY | 4708 CompileTimeErrorCode |
| 4709 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY | |
| 4691 ]); | 4710 ]); |
| 4692 } | 4711 } |
| 4693 | 4712 |
| 4694 void test_nonConstValueInInitializerFromDeferredLibrary_super() { | 4713 void test_nonConstValueInInitializerFromDeferredLibrary_super() { |
| 4695 resolveWithErrors(<String>[ | 4714 resolveWithErrors(<String>[ |
| 4696 r''' | 4715 r''' |
| 4697 library lib1; | 4716 library lib1; |
| 4698 const int c = 1;''', | 4717 const int c = 1;''', |
| 4699 r''' | 4718 r''' |
| 4700 library root; | 4719 library root; |
| 4701 import 'lib1.dart' deferred as a; | 4720 import 'lib1.dart' deferred as a; |
| 4702 class A { | 4721 class A { |
| 4703 const A(p); | 4722 const A(p); |
| 4704 } | 4723 } |
| 4705 class B extends A { | 4724 class B extends A { |
| 4706 const B() : super(a.c); | 4725 const B() : super(a.c); |
| 4707 }''' | 4726 }''' |
| 4708 ], <ErrorCode>[ | 4727 ], <ErrorCode>[ |
| 4709 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRA RY | 4728 CompileTimeErrorCode |
| 4729 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY | |
| 4710 ]); | 4730 ]); |
| 4711 } | 4731 } |
| 4712 | 4732 |
| 4713 void test_nonGenerativeConstructor_explicit() { | 4733 void test_nonGenerativeConstructor_explicit() { |
| 4714 Source source = addSource(r''' | 4734 Source source = addSource(r''' |
| 4715 class A { | 4735 class A { |
| 4716 factory A.named() {} | 4736 factory A.named() {} |
| 4717 } | 4737 } |
| 4718 class B extends A { | 4738 class B extends A { |
| 4719 B() : super.named(); | 4739 B() : super.named(); |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6263 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); | 6283 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); |
| 6264 verify([source]); | 6284 verify([source]); |
| 6265 reset(); | 6285 reset(); |
| 6266 } | 6286 } |
| 6267 | 6287 |
| 6268 void _check_wrongNumberOfParametersForOperator1(String name) { | 6288 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 6269 _check_wrongNumberOfParametersForOperator(name, ""); | 6289 _check_wrongNumberOfParametersForOperator(name, ""); |
| 6270 _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6290 _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6271 } | 6291 } |
| 6272 } | 6292 } |
| OLD | NEW |