| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
| 10 import 'package:analyzer/src/error/codes.dart'; | 10 import 'package:analyzer/src/error/codes.dart'; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 await computeAnalysisResult(source); | 196 await computeAnalysisResult(source); |
| 197 assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]); | 197 assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]); |
| 198 // Cannot verify because "_name" cannot be resolved. | 198 // Cannot verify because "_name" cannot be resolved. |
| 199 } | 199 } |
| 200 | 200 |
| 201 test_ambiguousExport() async { | 201 test_ambiguousExport() async { |
| 202 Source source = addSource(r''' | 202 Source source = addSource(r''' |
| 203 library L; | 203 library L; |
| 204 export 'lib1.dart'; | 204 export 'lib1.dart'; |
| 205 export 'lib2.dart';'''); | 205 export 'lib2.dart';'''); |
| 206 addNamedSource( | 206 addNamedSource("/lib1.dart", r''' |
| 207 "/lib1.dart", | |
| 208 r''' | |
| 209 library lib1; | 207 library lib1; |
| 210 class N {}'''); | 208 class N {}'''); |
| 211 addNamedSource( | 209 addNamedSource("/lib2.dart", r''' |
| 212 "/lib2.dart", | |
| 213 r''' | |
| 214 library lib2; | 210 library lib2; |
| 215 class N {}'''); | 211 class N {}'''); |
| 216 await computeAnalysisResult(source); | 212 await computeAnalysisResult(source); |
| 217 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); | 213 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); |
| 218 verify([source]); | 214 verify([source]); |
| 219 } | 215 } |
| 220 | 216 |
| 221 test_annotationWithNotClass() async { | 217 test_annotationWithNotClass() async { |
| 222 Source source = addSource(''' | 218 Source source = addSource(''' |
| 223 class Property { | 219 class Property { |
| 224 final int value; | 220 final int value; |
| 225 const Property(this.value); | 221 const Property(this.value); |
| 226 } | 222 } |
| 227 | 223 |
| 228 const Property property = const Property(42); | 224 const Property property = const Property(42); |
| 229 | 225 |
| 230 @property(123) | 226 @property(123) |
| 231 main() { | 227 main() { |
| 232 } | 228 } |
| 233 '''); | 229 '''); |
| 234 await computeAnalysisResult(source); | 230 await computeAnalysisResult(source); |
| 235 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); | 231 assertErrors(source, [CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS]); |
| 236 verify([source]); | 232 verify([source]); |
| 237 } | 233 } |
| 238 | 234 |
| 239 test_annotationWithNotClass_prefixed() async { | 235 test_annotationWithNotClass_prefixed() async { |
| 240 addNamedSource( | 236 addNamedSource("/annotations.dart", r''' |
| 241 "/annotations.dart", | |
| 242 r''' | |
| 243 class Property { | 237 class Property { |
| 244 final int value; | 238 final int value; |
| 245 const Property(this.value); | 239 const Property(this.value); |
| 246 } | 240 } |
| 247 | 241 |
| 248 const Property property = const Property(42); | 242 const Property property = const Property(42); |
| 249 '''); | 243 '''); |
| 250 Source source = addSource(''' | 244 Source source = addSource(''' |
| 251 import 'annotations.dart' as pref; | 245 import 'annotations.dart' as pref; |
| 252 @pref.property(123) | 246 @pref.property(123) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 f() async { | 498 f() async { |
| 505 return "$async"; | 499 return "$async"; |
| 506 } | 500 } |
| 507 '''); | 501 '''); |
| 508 await computeAnalysisResult(source); | 502 await computeAnalysisResult(source); |
| 509 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); | 503 assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]); |
| 510 verify([source]); | 504 verify([source]); |
| 511 } | 505 } |
| 512 | 506 |
| 513 test_async_used_as_identifier_in_suffix() async { | 507 test_async_used_as_identifier_in_suffix() async { |
| 514 addNamedSource( | 508 addNamedSource("/lib1.dart", r''' |
| 515 "/lib1.dart", | |
| 516 r''' | |
| 517 library lib1; | 509 library lib1; |
| 518 int async; | 510 int async; |
| 519 '''); | 511 '''); |
| 520 Source source = addSource(''' | 512 Source source = addSource(''' |
| 521 import 'lib1.dart' as l; | 513 import 'lib1.dart' as l; |
| 522 f() async { | 514 f() async { |
| 523 return l.async; | 515 return l.async; |
| 524 } | 516 } |
| 525 '''); | 517 '''); |
| 526 await computeAnalysisResult(source); | 518 await computeAnalysisResult(source); |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 f() { | 1530 f() { |
| 1539 return const A(); | 1531 return const A(); |
| 1540 }'''); | 1532 }'''); |
| 1541 await computeAnalysisResult(source); | 1533 await computeAnalysisResult(source); |
| 1542 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 1534 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 1543 verify([source]); | 1535 verify([source]); |
| 1544 } | 1536 } |
| 1545 | 1537 |
| 1546 test_constWithNonType_fromLibrary() async { | 1538 test_constWithNonType_fromLibrary() async { |
| 1547 Source source1 = addNamedSource("/lib.dart", ""); | 1539 Source source1 = addNamedSource("/lib.dart", ""); |
| 1548 Source source2 = addNamedSource( | 1540 Source source2 = addNamedSource("/lib2.dart", r''' |
| 1549 "/lib2.dart", | |
| 1550 r''' | |
| 1551 import 'lib.dart' as lib; | 1541 import 'lib.dart' as lib; |
| 1552 void f() { | 1542 void f() { |
| 1553 const lib.A(); | 1543 const lib.A(); |
| 1554 }'''); | 1544 }'''); |
| 1555 await computeAnalysisResult(source1); | 1545 await computeAnalysisResult(source1); |
| 1556 await computeAnalysisResult(source2); | 1546 await computeAnalysisResult(source2); |
| 1557 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 1547 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 1558 verify([source1]); | 1548 verify([source1]); |
| 1559 } | 1549 } |
| 1560 | 1550 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 }'''); | 1666 }'''); |
| 1677 await computeAnalysisResult(source); | 1667 await computeAnalysisResult(source); |
| 1678 assertErrors(source, [ | 1668 assertErrors(source, [ |
| 1679 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, | 1669 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, |
| 1680 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT | 1670 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT |
| 1681 ]); | 1671 ]); |
| 1682 verify([source]); | 1672 verify([source]); |
| 1683 } | 1673 } |
| 1684 | 1674 |
| 1685 test_duplicateDefinition_acrossLibraries() async { | 1675 test_duplicateDefinition_acrossLibraries() async { |
| 1686 Source librarySource = addNamedSource( | 1676 Source librarySource = addNamedSource("/lib.dart", r''' |
| 1687 "/lib.dart", | |
| 1688 r''' | |
| 1689 library lib; | 1677 library lib; |
| 1690 | 1678 |
| 1691 part 'a.dart'; | 1679 part 'a.dart'; |
| 1692 part 'b.dart';'''); | 1680 part 'b.dart';'''); |
| 1693 Source sourceA = addNamedSource( | 1681 Source sourceA = addNamedSource("/a.dart", r''' |
| 1694 "/a.dart", | |
| 1695 r''' | |
| 1696 part of lib; | 1682 part of lib; |
| 1697 | 1683 |
| 1698 class A {}'''); | 1684 class A {}'''); |
| 1699 Source sourceB = addNamedSource( | 1685 Source sourceB = addNamedSource("/b.dart", r''' |
| 1700 "/b.dart", | |
| 1701 r''' | |
| 1702 part of lib; | 1686 part of lib; |
| 1703 | 1687 |
| 1704 class A {}'''); | 1688 class A {}'''); |
| 1705 await computeAnalysisResult(librarySource); | 1689 await computeAnalysisResult(librarySource); |
| 1706 await computeAnalysisResult(sourceA); | 1690 await computeAnalysisResult(sourceA); |
| 1707 await computeAnalysisResult(sourceB); | 1691 await computeAnalysisResult(sourceB); |
| 1708 assertNoErrors(librarySource); | 1692 assertNoErrors(librarySource); |
| 1709 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1693 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1710 verify([librarySource, sourceA, sourceB]); | 1694 verify([librarySource, sourceA, sourceB]); |
| 1711 } | 1695 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 class A { | 1731 class A { |
| 1748 m() {} | 1732 m() {} |
| 1749 m() {} | 1733 m() {} |
| 1750 }'''); | 1734 }'''); |
| 1751 await computeAnalysisResult(source); | 1735 await computeAnalysisResult(source); |
| 1752 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1736 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1753 verify([source]); | 1737 verify([source]); |
| 1754 } | 1738 } |
| 1755 | 1739 |
| 1756 test_duplicateDefinition_inPart() async { | 1740 test_duplicateDefinition_inPart() async { |
| 1757 Source librarySource = addNamedSource( | 1741 Source librarySource = addNamedSource("/lib.dart", r''' |
| 1758 "/lib.dart", | |
| 1759 r''' | |
| 1760 library test; | 1742 library test; |
| 1761 part 'a.dart'; | 1743 part 'a.dart'; |
| 1762 class A {}'''); | 1744 class A {}'''); |
| 1763 Source sourceA = addNamedSource( | 1745 Source sourceA = addNamedSource("/a.dart", r''' |
| 1764 "/a.dart", | |
| 1765 r''' | |
| 1766 part of test; | 1746 part of test; |
| 1767 class A {}'''); | 1747 class A {}'''); |
| 1768 await computeAnalysisResult(librarySource); | 1748 await computeAnalysisResult(librarySource); |
| 1769 await computeAnalysisResult(sourceA); | 1749 await computeAnalysisResult(sourceA); |
| 1770 assertNoErrors(librarySource); | 1750 assertNoErrors(librarySource); |
| 1771 assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 1751 assertErrors(sourceA, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 1772 verify([librarySource, sourceA]); | 1752 verify([librarySource, sourceA]); |
| 1773 } | 1753 } |
| 1774 | 1754 |
| 1775 test_duplicateDefinition_locals_inCase() async { | 1755 test_duplicateDefinition_locals_inCase() async { |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 assertErrors(source, | 2871 assertErrors(source, |
| 2892 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]); | 2872 [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, HintCode.UNUSED_IMPORT]); |
| 2893 verify([source]); | 2873 verify([source]); |
| 2894 } | 2874 } |
| 2895 | 2875 |
| 2896 test_importOfNonLibrary() async { | 2876 test_importOfNonLibrary() async { |
| 2897 Source source = addSource(r''' | 2877 Source source = addSource(r''' |
| 2898 library lib; | 2878 library lib; |
| 2899 import 'part.dart'; | 2879 import 'part.dart'; |
| 2900 A a;'''); | 2880 A a;'''); |
| 2901 addNamedSource( | 2881 addNamedSource("/part.dart", r''' |
| 2902 "/part.dart", | |
| 2903 r''' | |
| 2904 part of lib; | 2882 part of lib; |
| 2905 class A{}'''); | 2883 class A{}'''); |
| 2906 await computeAnalysisResult(source); | 2884 await computeAnalysisResult(source); |
| 2907 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); | 2885 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); |
| 2908 verify([source]); | 2886 verify([source]); |
| 2909 } | 2887 } |
| 2910 | 2888 |
| 2911 test_inconsistentCaseExpressionTypes() async { | 2889 test_inconsistentCaseExpressionTypes() async { |
| 2912 Source source = addSource(r''' | 2890 Source source = addSource(r''' |
| 2913 f(var p) { | 2891 f(var p) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3167 get V => 0; | 3145 get V => 0; |
| 3168 @V | 3146 @V |
| 3169 main() { | 3147 main() { |
| 3170 }'''); | 3148 }'''); |
| 3171 await computeAnalysisResult(source); | 3149 await computeAnalysisResult(source); |
| 3172 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 3150 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 3173 verify([source]); | 3151 verify([source]); |
| 3174 } | 3152 } |
| 3175 | 3153 |
| 3176 test_invalidAnnotation_importWithPrefix_getter() async { | 3154 test_invalidAnnotation_importWithPrefix_getter() async { |
| 3177 addNamedSource( | 3155 addNamedSource("/lib.dart", r''' |
| 3178 "/lib.dart", | |
| 3179 r''' | |
| 3180 library lib; | 3156 library lib; |
| 3181 get V => 0;'''); | 3157 get V => 0;'''); |
| 3182 Source source = addSource(r''' | 3158 Source source = addSource(r''' |
| 3183 import 'lib.dart' as p; | 3159 import 'lib.dart' as p; |
| 3184 @p.V | 3160 @p.V |
| 3185 main() { | 3161 main() { |
| 3186 }'''); | 3162 }'''); |
| 3187 await computeAnalysisResult(source); | 3163 await computeAnalysisResult(source); |
| 3188 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 3164 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 3189 verify([source]); | 3165 verify([source]); |
| 3190 } | 3166 } |
| 3191 | 3167 |
| 3192 test_invalidAnnotation_importWithPrefix_notConstantVariable() async { | 3168 test_invalidAnnotation_importWithPrefix_notConstantVariable() async { |
| 3193 addNamedSource( | 3169 addNamedSource("/lib.dart", r''' |
| 3194 "/lib.dart", | |
| 3195 r''' | |
| 3196 library lib; | 3170 library lib; |
| 3197 final V = 0;'''); | 3171 final V = 0;'''); |
| 3198 Source source = addSource(r''' | 3172 Source source = addSource(r''' |
| 3199 import 'lib.dart' as p; | 3173 import 'lib.dart' as p; |
| 3200 @p.V | 3174 @p.V |
| 3201 main() { | 3175 main() { |
| 3202 }'''); | 3176 }'''); |
| 3203 await computeAnalysisResult(source); | 3177 await computeAnalysisResult(source); |
| 3204 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 3178 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 3205 verify([source]); | 3179 verify([source]); |
| 3206 } | 3180 } |
| 3207 | 3181 |
| 3208 test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() a
sync { | 3182 test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocation() a
sync { |
| 3209 addNamedSource( | 3183 addNamedSource("/lib.dart", r''' |
| 3210 "/lib.dart", | |
| 3211 r''' | |
| 3212 library lib; | 3184 library lib; |
| 3213 typedef V();'''); | 3185 typedef V();'''); |
| 3214 Source source = addSource(r''' | 3186 Source source = addSource(r''' |
| 3215 import 'lib.dart' as p; | 3187 import 'lib.dart' as p; |
| 3216 @p.V | 3188 @p.V |
| 3217 main() { | 3189 main() { |
| 3218 }'''); | 3190 }'''); |
| 3219 await computeAnalysisResult(source); | 3191 await computeAnalysisResult(source); |
| 3220 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 3192 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 3221 verify([source]); | 3193 verify([source]); |
| (...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4816 await computeAnalysisResult(source); | 4788 await computeAnalysisResult(source); |
| 4817 assertErrors(source, [ | 4789 assertErrors(source, [ |
| 4818 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, | 4790 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, |
| 4819 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION | 4791 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION |
| 4820 ]); | 4792 ]); |
| 4821 verify([source]); | 4793 verify([source]); |
| 4822 } | 4794 } |
| 4823 | 4795 |
| 4824 test_nonConstValueInInitializer_instanceCreation_inDifferentFile() async { | 4796 test_nonConstValueInInitializer_instanceCreation_inDifferentFile() async { |
| 4825 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); | 4797 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); |
| 4826 Source source = addNamedSource( | 4798 Source source = addNamedSource('/a.dart', r''' |
| 4827 '/a.dart', | |
| 4828 r''' | |
| 4829 import 'b.dart'; | 4799 import 'b.dart'; |
| 4830 const v = const MyClass(); | 4800 const v = const MyClass(); |
| 4831 '''); | 4801 '''); |
| 4832 addNamedSource( | 4802 addNamedSource('/b.dart', r''' |
| 4833 '/b.dart', | |
| 4834 r''' | |
| 4835 class MyClass { | 4803 class MyClass { |
| 4836 const MyClass([p = foo]); | 4804 const MyClass([p = foo]); |
| 4837 } | 4805 } |
| 4838 '''); | 4806 '''); |
| 4839 await computeAnalysisResult(source); | 4807 await computeAnalysisResult(source); |
| 4840 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 4808 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 4841 } | 4809 } |
| 4842 | 4810 |
| 4843 test_nonConstValueInInitializer_redirecting() async { | 4811 test_nonConstValueInInitializer_redirecting() async { |
| 4844 Source source = addSource(r''' | 4812 Source source = addSource(r''' |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5099 p = 1; | 5067 p = 1; |
| 5100 } | 5068 } |
| 5101 '''); | 5069 '''); |
| 5102 await computeAnalysisResult(source); | 5070 await computeAnalysisResult(source); |
| 5103 assertErrors( | 5071 assertErrors( |
| 5104 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5072 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5105 verify([source]); | 5073 verify([source]); |
| 5106 } | 5074 } |
| 5107 | 5075 |
| 5108 test_prefix_conditionalPropertyAccess_call() async { | 5076 test_prefix_conditionalPropertyAccess_call() async { |
| 5109 addNamedSource( | 5077 addNamedSource('/lib.dart', ''' |
| 5110 '/lib.dart', | |
| 5111 ''' | |
| 5112 library lib; | 5078 library lib; |
| 5113 g() {} | 5079 g() {} |
| 5114 '''); | 5080 '''); |
| 5115 Source source = addSource(''' | 5081 Source source = addSource(''' |
| 5116 import 'lib.dart' as p; | 5082 import 'lib.dart' as p; |
| 5117 f() { | 5083 f() { |
| 5118 p?.g(); | 5084 p?.g(); |
| 5119 } | 5085 } |
| 5120 '''); | 5086 '''); |
| 5121 await computeAnalysisResult(source); | 5087 await computeAnalysisResult(source); |
| 5122 assertErrors( | 5088 assertErrors( |
| 5123 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5089 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5124 verify([source]); | 5090 verify([source]); |
| 5125 } | 5091 } |
| 5126 | 5092 |
| 5127 test_prefix_conditionalPropertyAccess_call_loadLibrary() async { | 5093 test_prefix_conditionalPropertyAccess_call_loadLibrary() async { |
| 5128 addNamedSource( | 5094 addNamedSource('/lib.dart', ''' |
| 5129 '/lib.dart', | |
| 5130 ''' | |
| 5131 library lib; | 5095 library lib; |
| 5132 '''); | 5096 '''); |
| 5133 Source source = addSource(''' | 5097 Source source = addSource(''' |
| 5134 import 'lib.dart' deferred as p; | 5098 import 'lib.dart' deferred as p; |
| 5135 f() { | 5099 f() { |
| 5136 p?.loadLibrary(); | 5100 p?.loadLibrary(); |
| 5137 } | 5101 } |
| 5138 '''); | 5102 '''); |
| 5139 await computeAnalysisResult(source); | 5103 await computeAnalysisResult(source); |
| 5140 assertErrors( | 5104 assertErrors( |
| 5141 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5105 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5142 verify([source]); | 5106 verify([source]); |
| 5143 } | 5107 } |
| 5144 | 5108 |
| 5145 test_prefix_conditionalPropertyAccess_get() async { | 5109 test_prefix_conditionalPropertyAccess_get() async { |
| 5146 addNamedSource( | 5110 addNamedSource('/lib.dart', ''' |
| 5147 '/lib.dart', | |
| 5148 ''' | |
| 5149 library lib; | 5111 library lib; |
| 5150 var x; | 5112 var x; |
| 5151 '''); | 5113 '''); |
| 5152 Source source = addSource(''' | 5114 Source source = addSource(''' |
| 5153 import 'lib.dart' as p; | 5115 import 'lib.dart' as p; |
| 5154 f() { | 5116 f() { |
| 5155 return p?.x; | 5117 return p?.x; |
| 5156 } | 5118 } |
| 5157 '''); | 5119 '''); |
| 5158 await computeAnalysisResult(source); | 5120 await computeAnalysisResult(source); |
| 5159 assertErrors( | 5121 assertErrors( |
| 5160 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5122 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5161 verify([source]); | 5123 verify([source]); |
| 5162 } | 5124 } |
| 5163 | 5125 |
| 5164 test_prefix_conditionalPropertyAccess_get_loadLibrary() async { | 5126 test_prefix_conditionalPropertyAccess_get_loadLibrary() async { |
| 5165 addNamedSource( | 5127 addNamedSource('/lib.dart', ''' |
| 5166 '/lib.dart', | |
| 5167 ''' | |
| 5168 library lib; | 5128 library lib; |
| 5169 '''); | 5129 '''); |
| 5170 Source source = addSource(''' | 5130 Source source = addSource(''' |
| 5171 import 'lib.dart' deferred as p; | 5131 import 'lib.dart' deferred as p; |
| 5172 f() { | 5132 f() { |
| 5173 return p?.loadLibrary; | 5133 return p?.loadLibrary; |
| 5174 } | 5134 } |
| 5175 '''); | 5135 '''); |
| 5176 await computeAnalysisResult(source); | 5136 await computeAnalysisResult(source); |
| 5177 assertErrors( | 5137 assertErrors( |
| 5178 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5138 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5179 verify([source]); | 5139 verify([source]); |
| 5180 } | 5140 } |
| 5181 | 5141 |
| 5182 test_prefix_conditionalPropertyAccess_set() async { | 5142 test_prefix_conditionalPropertyAccess_set() async { |
| 5183 addNamedSource( | 5143 addNamedSource('/lib.dart', ''' |
| 5184 '/lib.dart', | |
| 5185 ''' | |
| 5186 library lib; | 5144 library lib; |
| 5187 var x; | 5145 var x; |
| 5188 '''); | 5146 '''); |
| 5189 Source source = addSource(''' | 5147 Source source = addSource(''' |
| 5190 import 'lib.dart' as p; | 5148 import 'lib.dart' as p; |
| 5191 f() { | 5149 f() { |
| 5192 p?.x = null; | 5150 p?.x = null; |
| 5193 } | 5151 } |
| 5194 '''); | 5152 '''); |
| 5195 await computeAnalysisResult(source); | 5153 await computeAnalysisResult(source); |
| 5196 assertErrors( | 5154 assertErrors( |
| 5197 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5155 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5198 verify([source]); | 5156 verify([source]); |
| 5199 } | 5157 } |
| 5200 | 5158 |
| 5201 test_prefix_conditionalPropertyAccess_set_loadLibrary() async { | 5159 test_prefix_conditionalPropertyAccess_set_loadLibrary() async { |
| 5202 addNamedSource( | 5160 addNamedSource('/lib.dart', ''' |
| 5203 '/lib.dart', | |
| 5204 ''' | |
| 5205 library lib; | 5161 library lib; |
| 5206 '''); | 5162 '''); |
| 5207 Source source = addSource(''' | 5163 Source source = addSource(''' |
| 5208 import 'lib.dart' deferred as p; | 5164 import 'lib.dart' deferred as p; |
| 5209 f() { | 5165 f() { |
| 5210 p?.loadLibrary = null; | 5166 p?.loadLibrary = null; |
| 5211 } | 5167 } |
| 5212 '''); | 5168 '''); |
| 5213 await computeAnalysisResult(source); | 5169 await computeAnalysisResult(source); |
| 5214 assertErrors( | 5170 assertErrors( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5240 p(); | 5196 p(); |
| 5241 } | 5197 } |
| 5242 '''); | 5198 '''); |
| 5243 await computeAnalysisResult(source); | 5199 await computeAnalysisResult(source); |
| 5244 assertErrors( | 5200 assertErrors( |
| 5245 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5201 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5246 verify([source]); | 5202 verify([source]); |
| 5247 } | 5203 } |
| 5248 | 5204 |
| 5249 test_prefixCollidesWithTopLevelMembers_functionTypeAlias() async { | 5205 test_prefixCollidesWithTopLevelMembers_functionTypeAlias() async { |
| 5250 addNamedSource( | 5206 addNamedSource("/lib.dart", r''' |
| 5251 "/lib.dart", | |
| 5252 r''' | |
| 5253 library lib; | 5207 library lib; |
| 5254 class A{}'''); | 5208 class A{}'''); |
| 5255 Source source = addSource(r''' | 5209 Source source = addSource(r''' |
| 5256 import 'lib.dart' as p; | 5210 import 'lib.dart' as p; |
| 5257 typedef p(); | 5211 typedef p(); |
| 5258 p.A a;'''); | 5212 p.A a;'''); |
| 5259 await computeAnalysisResult(source); | 5213 await computeAnalysisResult(source); |
| 5260 assertErrors( | 5214 assertErrors( |
| 5261 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 5215 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); |
| 5262 verify([source]); | 5216 verify([source]); |
| 5263 } | 5217 } |
| 5264 | 5218 |
| 5265 test_prefixCollidesWithTopLevelMembers_topLevelFunction() async { | 5219 test_prefixCollidesWithTopLevelMembers_topLevelFunction() async { |
| 5266 addNamedSource( | 5220 addNamedSource("/lib.dart", r''' |
| 5267 "/lib.dart", | |
| 5268 r''' | |
| 5269 library lib; | 5221 library lib; |
| 5270 class A{}'''); | 5222 class A{}'''); |
| 5271 Source source = addSource(r''' | 5223 Source source = addSource(r''' |
| 5272 import 'lib.dart' as p; | 5224 import 'lib.dart' as p; |
| 5273 p() {} | 5225 p() {} |
| 5274 p.A a;'''); | 5226 p.A a;'''); |
| 5275 await computeAnalysisResult(source); | 5227 await computeAnalysisResult(source); |
| 5276 assertErrors( | 5228 assertErrors( |
| 5277 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 5229 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); |
| 5278 verify([source]); | 5230 verify([source]); |
| 5279 } | 5231 } |
| 5280 | 5232 |
| 5281 test_prefixCollidesWithTopLevelMembers_topLevelVariable() async { | 5233 test_prefixCollidesWithTopLevelMembers_topLevelVariable() async { |
| 5282 addNamedSource( | 5234 addNamedSource("/lib.dart", r''' |
| 5283 "/lib.dart", | |
| 5284 r''' | |
| 5285 library lib; | 5235 library lib; |
| 5286 class A{}'''); | 5236 class A{}'''); |
| 5287 Source source = addSource(r''' | 5237 Source source = addSource(r''' |
| 5288 import 'lib.dart' as p; | 5238 import 'lib.dart' as p; |
| 5289 var p = null; | 5239 var p = null; |
| 5290 p.A a;'''); | 5240 p.A a;'''); |
| 5291 await computeAnalysisResult(source); | 5241 await computeAnalysisResult(source); |
| 5292 assertErrors( | 5242 assertErrors( |
| 5293 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 5243 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); |
| 5294 verify([source]); | 5244 verify([source]); |
| 5295 } | 5245 } |
| 5296 | 5246 |
| 5297 test_prefixCollidesWithTopLevelMembers_type() async { | 5247 test_prefixCollidesWithTopLevelMembers_type() async { |
| 5298 addNamedSource( | 5248 addNamedSource("/lib.dart", r''' |
| 5299 "/lib.dart", | |
| 5300 r''' | |
| 5301 library lib; | 5249 library lib; |
| 5302 class A{}'''); | 5250 class A{}'''); |
| 5303 Source source = addSource(r''' | 5251 Source source = addSource(r''' |
| 5304 import 'lib.dart' as p; | 5252 import 'lib.dart' as p; |
| 5305 class p {} | 5253 class p {} |
| 5306 p.A a;'''); | 5254 p.A a;'''); |
| 5307 await computeAnalysisResult(source); | 5255 await computeAnalysisResult(source); |
| 5308 assertErrors( | 5256 assertErrors( |
| 5309 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 5257 source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); |
| 5310 verify([source]); | 5258 verify([source]); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5332 p += 1; | 5280 p += 1; |
| 5333 } | 5281 } |
| 5334 '''); | 5282 '''); |
| 5335 await computeAnalysisResult(source); | 5283 await computeAnalysisResult(source); |
| 5336 assertErrors( | 5284 assertErrors( |
| 5337 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); | 5285 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); |
| 5338 verify([source]); | 5286 verify([source]); |
| 5339 } | 5287 } |
| 5340 | 5288 |
| 5341 test_prefixNotFollowedByDot_conditionalMethodInvocation() async { | 5289 test_prefixNotFollowedByDot_conditionalMethodInvocation() async { |
| 5342 addNamedSource( | 5290 addNamedSource('/lib.dart', ''' |
| 5343 '/lib.dart', | |
| 5344 ''' | |
| 5345 library lib; | 5291 library lib; |
| 5346 g() {} | 5292 g() {} |
| 5347 '''); | 5293 '''); |
| 5348 Source source = addSource(''' | 5294 Source source = addSource(''' |
| 5349 import 'lib.dart' as p; | 5295 import 'lib.dart' as p; |
| 5350 f() { | 5296 f() { |
| 5351 p?.g(); | 5297 p?.g(); |
| 5352 } | 5298 } |
| 5353 '''); | 5299 '''); |
| 5354 await computeAnalysisResult(source); | 5300 await computeAnalysisResult(source); |
| (...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6660 reset(); | 6606 reset(); |
| 6661 } | 6607 } |
| 6662 | 6608 |
| 6663 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { | 6609 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { |
| 6664 await _check_wrongNumberOfParametersForOperator(name, ""); | 6610 await _check_wrongNumberOfParametersForOperator(name, ""); |
| 6665 await _check_wrongNumberOfParametersForOperator(name, "a, b"); | 6611 await _check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 6666 } | 6612 } |
| 6667 | 6613 |
| 6668 Future<Null> _privateCollisionInMixinApplicationTest(String testCode) async { | 6614 Future<Null> _privateCollisionInMixinApplicationTest(String testCode) async { |
| 6669 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); | 6615 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); |
| 6670 addNamedSource( | 6616 addNamedSource('/lib1.dart', ''' |
| 6671 '/lib1.dart', | |
| 6672 ''' | |
| 6673 class A { | 6617 class A { |
| 6674 int _x; | 6618 int _x; |
| 6675 } | 6619 } |
| 6676 | 6620 |
| 6677 class B { | 6621 class B { |
| 6678 int _x; | 6622 int _x; |
| 6679 } | 6623 } |
| 6680 '''); | 6624 '''); |
| 6681 Source source = addSource(testCode); | 6625 Source source = addSource(testCode); |
| 6682 await computeAnalysisResult(source); | 6626 await computeAnalysisResult(source); |
| 6683 assertErrors( | 6627 assertErrors( |
| 6684 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]); | 6628 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]); |
| 6685 verify([source]); | 6629 verify([source]); |
| 6686 } | 6630 } |
| 6687 } | 6631 } |
| OLD | NEW |