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 library test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 } | 1826 } |
1827 '''); | 1827 '''); |
1828 } | 1828 } |
1829 } | 1829 } |
1830 | 1830 |
1831 test_class_constructor_field_formal_no_matching_field() async { | 1831 test_class_constructor_field_formal_no_matching_field() async { |
1832 // This is a compile-time error but it should still analyze consistently. | 1832 // This is a compile-time error but it should still analyze consistently. |
1833 var library = | 1833 var library = |
1834 await checkLibrary('class C { C(this.x); }', allowErrors: true); | 1834 await checkLibrary('class C { C(this.x); }', allowErrors: true); |
1835 if (isStrongMode) { | 1835 if (isStrongMode) { |
1836 checkElementText(library, r''' | 1836 if (isSharedFrontEnd) { |
| 1837 // Kernel does not store 'isFieldFormal' flag explicitly. |
| 1838 // We infer it from presence of the corresponding FieldInitializer. |
| 1839 // But if there is no field, there is no FieldInitializer. |
| 1840 checkElementText(library, r''' |
| 1841 class C { |
| 1842 C(dynamic x); |
| 1843 } |
| 1844 '''); |
| 1845 } else { |
| 1846 checkElementText(library, r''' |
1837 class C { | 1847 class C { |
1838 C(dynamic this.x); | 1848 C(dynamic this.x); |
1839 } | 1849 } |
1840 '''); | 1850 '''); |
| 1851 } |
1841 } else { | 1852 } else { |
1842 checkElementText(library, r''' | 1853 checkElementText(library, r''' |
1843 class C { | 1854 class C { |
1844 C(dynamic this.x); | 1855 C(dynamic this.x); |
1845 } | 1856 } |
1846 '''); | 1857 '''); |
1847 } | 1858 } |
1848 } | 1859 } |
1849 | 1860 |
1850 test_class_constructor_field_formal_typed_dynamic() async { | 1861 test_class_constructor_field_formal_typed_dynamic() async { |
(...skipping 7945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9796 } | 9807 } |
9797 | 9808 |
9798 test_metadata_fieldFormalParameter_withDefault() async { | 9809 test_metadata_fieldFormalParameter_withDefault() async { |
9799 var library = await checkLibrary( | 9810 var library = await checkLibrary( |
9800 'const a = null; class C { var x; C([@a this.x = null]); }'); | 9811 'const a = null; class C { var x; C([@a this.x = null]); }'); |
9801 if (isStrongMode) { | 9812 if (isStrongMode) { |
9802 checkElementText(library, r''' | 9813 checkElementText(library, r''' |
9803 class C { | 9814 class C { |
9804 dynamic x; | 9815 dynamic x; |
9805 C([@ | 9816 C([@ |
9806 a/*location: test.dart;a?*/ dynamic this.x = null]); | 9817 a/*location: test.dart;a?*/ dynamic this.x]); |
9807 } | 9818 } |
9808 const dynamic a = null; | 9819 const dynamic a = null; |
9809 '''); | 9820 '''); |
9810 } else { | 9821 } else { |
9811 checkElementText(library, r''' | 9822 checkElementText(library, r''' |
9812 class C { | 9823 class C { |
9813 dynamic x; | 9824 dynamic x; |
9814 C([@ | 9825 C([@ |
9815 a/*location: test.dart;a?*/ dynamic this.x = null]); | 9826 a/*location: test.dart;a?*/ dynamic this.x]); |
9816 } | 9827 } |
9817 const dynamic a = null; | 9828 const dynamic a = null; |
9818 '''); | 9829 '''); |
9819 } | 9830 } |
9820 } | 9831 } |
9821 | 9832 |
9822 test_metadata_functionDeclaration_function() async { | 9833 test_metadata_functionDeclaration_function() async { |
9823 var library = await checkLibrary(''' | 9834 var library = await checkLibrary(''' |
9824 const a = null; | 9835 const a = null; |
9825 @a | 9836 @a |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9906 '''); | 9917 '''); |
9907 } | 9918 } |
9908 } | 9919 } |
9909 | 9920 |
9910 test_metadata_functionTypedFormalParameter_withDefault() async { | 9921 test_metadata_functionTypedFormalParameter_withDefault() async { |
9911 var library = await checkLibrary('const a = null; f([@a g() = null]) {}'); | 9922 var library = await checkLibrary('const a = null; f([@a g() = null]) {}'); |
9912 if (isStrongMode) { | 9923 if (isStrongMode) { |
9913 checkElementText(library, r''' | 9924 checkElementText(library, r''' |
9914 const dynamic a = null; | 9925 const dynamic a = null; |
9915 dynamic f([@ | 9926 dynamic f([@ |
9916 a/*location: test.dart;a?*/ () → dynamic g = null]) {} | 9927 a/*location: test.dart;a?*/ () → dynamic g]) {} |
9917 '''); | 9928 '''); |
9918 } else { | 9929 } else { |
9919 checkElementText(library, r''' | 9930 checkElementText(library, r''' |
9920 const dynamic a = null; | 9931 const dynamic a = null; |
9921 dynamic f([@ | 9932 dynamic f([@ |
9922 a/*location: test.dart;a?*/ () → dynamic g = null]) {} | 9933 a/*location: test.dart;a?*/ () → dynamic g]) {} |
9923 '''); | 9934 '''); |
9924 } | 9935 } |
9925 } | 9936 } |
9926 | 9937 |
9927 test_metadata_importDirective() async { | 9938 test_metadata_importDirective() async { |
9928 addLibrarySource('/foo.dart', 'const b = null;'); | 9939 addLibrarySource('/foo.dart', 'const b = null;'); |
9929 var library = await checkLibrary('@a import "foo.dart"; const a = b;'); | 9940 var library = await checkLibrary('@a import "foo.dart"; const a = b;'); |
9930 if (isStrongMode) { | 9941 if (isStrongMode) { |
9931 checkElementText(library, r''' | 9942 checkElementText(library, r''' |
9932 @ | 9943 @ |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10148 '''); | 10159 '''); |
10149 } | 10160 } |
10150 } | 10161 } |
10151 | 10162 |
10152 test_metadata_simpleFormalParameter_withDefault() async { | 10163 test_metadata_simpleFormalParameter_withDefault() async { |
10153 var library = await checkLibrary('const a = null; f([@a x = null]) {}'); | 10164 var library = await checkLibrary('const a = null; f([@a x = null]) {}'); |
10154 if (isStrongMode) { | 10165 if (isStrongMode) { |
10155 checkElementText(library, r''' | 10166 checkElementText(library, r''' |
10156 const dynamic a = null; | 10167 const dynamic a = null; |
10157 dynamic f([@ | 10168 dynamic f([@ |
10158 a/*location: test.dart;a?*/ dynamic x = null]) {} | 10169 a/*location: test.dart;a?*/ dynamic x]) {} |
10159 '''); | 10170 '''); |
10160 } else { | 10171 } else { |
10161 checkElementText(library, r''' | 10172 checkElementText(library, r''' |
10162 const dynamic a = null; | 10173 const dynamic a = null; |
10163 dynamic f([@ | 10174 dynamic f([@ |
10164 a/*location: test.dart;a?*/ dynamic x = null]) {} | 10175 a/*location: test.dart;a?*/ dynamic x]) {} |
10165 '''); | 10176 '''); |
10166 } | 10177 } |
10167 } | 10178 } |
10168 | 10179 |
10169 test_metadata_topLevelVariableDeclaration() async { | 10180 test_metadata_topLevelVariableDeclaration() async { |
10170 var library = await checkLibrary('const a = null; @a int v;'); | 10181 var library = await checkLibrary('const a = null; @a int v;'); |
10171 if (isStrongMode) { | 10182 if (isStrongMode) { |
10172 checkElementText(library, r''' | 10183 checkElementText(library, r''' |
10173 const dynamic a = null; | 10184 const dynamic a = null; |
10174 @ | 10185 @ |
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13170 fail('Unexpectedly tried to get unlinked summary for $uri'); | 13181 fail('Unexpectedly tried to get unlinked summary for $uri'); |
13171 } | 13182 } |
13172 return serializedUnit; | 13183 return serializedUnit; |
13173 } | 13184 } |
13174 | 13185 |
13175 @override | 13186 @override |
13176 bool hasLibrarySummary(String uri) { | 13187 bool hasLibrarySummary(String uri) { |
13177 return true; | 13188 return true; |
13178 } | 13189 } |
13179 } | 13190 } |
OLD | NEW |