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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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 library analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/error/listener.dart'; 9 import 'package:analyzer/error/listener.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 EntityRef xInitializerReturnType = 1005 EntityRef xInitializerReturnType =
1006 getTypeRefForSlot(findVariable('x').initializer.inferredReturnTypeSlot); 1006 getTypeRefForSlot(findVariable('x').initializer.inferredReturnTypeSlot);
1007 EntityRef yInitializerReturnType = 1007 EntityRef yInitializerReturnType =
1008 getTypeRefForSlot(findVariable('y').initializer.inferredReturnTypeSlot); 1008 getTypeRefForSlot(findVariable('y').initializer.inferredReturnTypeSlot);
1009 expect(xInitializerReturnType.reference, yInitializerReturnType.reference); 1009 expect(xInitializerReturnType.reference, yInitializerReturnType.reference);
1010 } 1010 }
1011 1011
1012 test_cascaded_export_hide_hide() { 1012 test_cascaded_export_hide_hide() {
1013 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C hide B, C;'); 1013 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C hide B, C;');
1014 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); 1014 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
1015 serializeLibraryText( 1015 serializeLibraryText('''
1016 '''
1017 import 'lib1.dart'; 1016 import 'lib1.dart';
1018 A a; 1017 A a;
1019 B b; 1018 B b;
1020 C c; 1019 C c;
1021 ''', 1020 ''', allowErrors: true);
1022 allowErrors: true);
1023 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); 1021 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A');
1024 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1022 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1025 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1023 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1026 } 1024 }
1027 1025
1028 test_cascaded_export_hide_show() { 1026 test_cascaded_export_hide_show() {
1029 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C show A, C;'); 1027 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C show A, C;');
1030 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); 1028 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
1031 serializeLibraryText( 1029 serializeLibraryText('''
1032 '''
1033 import 'lib1.dart'; 1030 import 'lib1.dart';
1034 A a; 1031 A a;
1035 B b; 1032 B b;
1036 C c; 1033 C c;
1037 ''', 1034 ''', allowErrors: true);
1038 allowErrors: true);
1039 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); 1035 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A');
1040 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1036 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1041 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1037 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1042 } 1038 }
1043 1039
1044 test_cascaded_export_show_hide() { 1040 test_cascaded_export_show_hide() {
1045 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B hide B, C;'); 1041 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B hide B, C;');
1046 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); 1042 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
1047 serializeLibraryText( 1043 serializeLibraryText('''
1048 '''
1049 import 'lib1.dart'; 1044 import 'lib1.dart';
1050 A a; 1045 A a;
1051 B b; 1046 B b;
1052 C c; 1047 C c;
1053 ''', 1048 ''', allowErrors: true);
1054 allowErrors: true);
1055 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); 1049 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A');
1056 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1050 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1057 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1051 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1058 } 1052 }
1059 1053
1060 test_cascaded_export_show_show() { 1054 test_cascaded_export_show_show() {
1061 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B show A, C;'); 1055 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B show A, C;');
1062 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); 1056 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
1063 serializeLibraryText( 1057 serializeLibraryText('''
1064 '''
1065 import 'lib1.dart'; 1058 import 'lib1.dart';
1066 A a; 1059 A a;
1067 B b; 1060 B b;
1068 C c; 1061 C c;
1069 ''', 1062 ''', allowErrors: true);
1070 allowErrors: true);
1071 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); 1063 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A');
1072 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1064 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1073 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1065 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1074 } 1066 }
1075 1067
1076 test_cascaded_import_hide_hide() { 1068 test_cascaded_import_hide_hide() {
1077 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); 1069 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
1078 serializeLibraryText( 1070 serializeLibraryText('''
1079 '''
1080 import 'lib.dart' hide C hide B, C; 1071 import 'lib.dart' hide C hide B, C;
1081 A a; 1072 A a;
1082 B b; 1073 B b;
1083 C c; 1074 C c;
1084 ''', 1075 ''', allowErrors: true);
1085 allowErrors: true);
1086 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); 1076 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A');
1087 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1077 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1088 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1078 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1089 } 1079 }
1090 1080
1091 test_cascaded_import_hide_show() { 1081 test_cascaded_import_hide_show() {
1092 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); 1082 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
1093 serializeLibraryText( 1083 serializeLibraryText('''
1094 '''
1095 import 'lib.dart' hide C show A, C; 1084 import 'lib.dart' hide C show A, C;
1096 A a; 1085 A a;
1097 B b; 1086 B b;
1098 C c; 1087 C c;
1099 ''', 1088 ''', allowErrors: true);
1100 allowErrors: true);
1101 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); 1089 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A');
1102 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1090 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1103 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1091 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1104 } 1092 }
1105 1093
1106 test_cascaded_import_show_hide() { 1094 test_cascaded_import_show_hide() {
1107 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); 1095 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
1108 serializeLibraryText( 1096 serializeLibraryText('''
1109 '''
1110 import 'lib.dart' show A, B hide B, C; 1097 import 'lib.dart' show A, B hide B, C;
1111 A a; 1098 A a;
1112 B b; 1099 B b;
1113 C c; 1100 C c;
1114 ''', 1101 ''', allowErrors: true);
1115 allowErrors: true);
1116 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); 1102 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A');
1117 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1103 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1118 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1104 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1119 } 1105 }
1120 1106
1121 test_cascaded_import_show_show() { 1107 test_cascaded_import_show_show() {
1122 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); 1108 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
1123 serializeLibraryText( 1109 serializeLibraryText('''
1124 '''
1125 import 'lib.dart' show A, B show A, C; 1110 import 'lib.dart' show A, B show A, C;
1126 A a; 1111 A a;
1127 B b; 1112 B b;
1128 C c; 1113 C c;
1129 ''', 1114 ''', allowErrors: true);
1130 allowErrors: true);
1131 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); 1115 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A');
1132 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); 1116 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
1133 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); 1117 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
1134 } 1118 }
1135 1119
1136 test_class_abstract() { 1120 test_class_abstract() {
1137 UnlinkedClass cls = serializeClassText('abstract class C {}'); 1121 UnlinkedClass cls = serializeClassText('abstract class C {}');
1138 expect(cls.isAbstract, true); 1122 expect(cls.isAbstract, true);
1139 } 1123 }
1140 1124
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 numTypeParameters: 2) 2009 numTypeParameters: 2)
2026 ], 2010 ],
2027 numTypeArguments: 2); 2011 numTypeArguments: 2);
2028 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); 2012 checkTypeRef(r.typeArguments[0], 'dart:core', 'int');
2029 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); 2013 checkTypeRef(r.typeArguments[1], 'dart:core', 'String');
2030 } 2014 }
2031 ]); 2015 ]);
2032 } 2016 }
2033 2017
2034 test_constExpr_invokeConstructor_generic_named_imported() { 2018 test_constExpr_invokeConstructor_generic_named_imported() {
2035 addNamedSource( 2019 addNamedSource('/a.dart', '''
2036 '/a.dart',
2037 '''
2038 class C<K, V> { 2020 class C<K, V> {
2039 const C.named(); 2021 const C.named();
2040 } 2022 }
2041 '''); 2023 ''');
2042 UnlinkedVariable variable = serializeVariableText(''' 2024 UnlinkedVariable variable = serializeVariableText('''
2043 import 'a.dart'; 2025 import 'a.dart';
2044 const v = const C<int, String>.named(); 2026 const v = const C<int, String>.named();
2045 '''); 2027 ''');
2046 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2028 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2047 UnlinkedExprOperation.invokeConstructor, 2029 UnlinkedExprOperation.invokeConstructor,
2048 ], ints: [ 2030 ], ints: [
2049 0, 2031 0,
2050 0 2032 0
2051 ], referenceValidators: [ 2033 ], referenceValidators: [
2052 (EntityRef r) { 2034 (EntityRef r) {
2053 checkTypeRef(r, null, 'named', 2035 checkTypeRef(r, null, 'named',
2054 expectedKind: ReferenceKind.constructor, 2036 expectedKind: ReferenceKind.constructor,
2055 prefixExpectations: [ 2037 prefixExpectations: [
2056 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 2038 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
2057 absoluteUri: absUri('/a.dart'), numTypeParameters: 2) 2039 absoluteUri: absUri('/a.dart'), numTypeParameters: 2)
2058 ], 2040 ],
2059 numTypeArguments: 2); 2041 numTypeArguments: 2);
2060 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); 2042 checkTypeRef(r.typeArguments[0], 'dart:core', 'int');
2061 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); 2043 checkTypeRef(r.typeArguments[1], 'dart:core', 'String');
2062 } 2044 }
2063 ]); 2045 ]);
2064 } 2046 }
2065 2047
2066 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { 2048 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() {
2067 addNamedSource( 2049 addNamedSource('/a.dart', '''
2068 '/a.dart',
2069 '''
2070 class C<K, V> { 2050 class C<K, V> {
2071 const C.named(); 2051 const C.named();
2072 } 2052 }
2073 '''); 2053 ''');
2074 UnlinkedVariable variable = serializeVariableText(''' 2054 UnlinkedVariable variable = serializeVariableText('''
2075 import 'a.dart' as p; 2055 import 'a.dart' as p;
2076 const v = const p.C<int, String>.named(); 2056 const v = const p.C<int, String>.named();
2077 '''); 2057 ''');
2078 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2058 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2079 UnlinkedExprOperation.invokeConstructor, 2059 UnlinkedExprOperation.invokeConstructor,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 expectedKind: ReferenceKind.classOrEnum, 2094 expectedKind: ReferenceKind.classOrEnum,
2115 numTypeParameters: 2, 2095 numTypeParameters: 2,
2116 numTypeArguments: 2); 2096 numTypeArguments: 2);
2117 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); 2097 checkTypeRef(r.typeArguments[0], 'dart:core', 'int');
2118 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); 2098 checkTypeRef(r.typeArguments[1], 'dart:core', 'String');
2119 } 2099 }
2120 ]); 2100 ]);
2121 } 2101 }
2122 2102
2123 test_constExpr_invokeConstructor_generic_unnamed_imported() { 2103 test_constExpr_invokeConstructor_generic_unnamed_imported() {
2124 addNamedSource( 2104 addNamedSource('/a.dart', '''
2125 '/a.dart',
2126 '''
2127 class C<K, V> { 2105 class C<K, V> {
2128 const C(); 2106 const C();
2129 } 2107 }
2130 '''); 2108 ''');
2131 UnlinkedVariable variable = serializeVariableText(''' 2109 UnlinkedVariable variable = serializeVariableText('''
2132 import 'a.dart'; 2110 import 'a.dart';
2133 const v = const C<int, String>(); 2111 const v = const C<int, String>();
2134 '''); 2112 ''');
2135 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2113 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2136 UnlinkedExprOperation.invokeConstructor, 2114 UnlinkedExprOperation.invokeConstructor,
2137 ], ints: [ 2115 ], ints: [
2138 0, 2116 0,
2139 0 2117 0
2140 ], referenceValidators: [ 2118 ], referenceValidators: [
2141 (EntityRef r) { 2119 (EntityRef r) {
2142 checkTypeRef(r, absUri('/a.dart'), 'C', 2120 checkTypeRef(r, absUri('/a.dart'), 'C',
2143 expectedKind: ReferenceKind.classOrEnum, 2121 expectedKind: ReferenceKind.classOrEnum,
2144 numTypeParameters: 2, 2122 numTypeParameters: 2,
2145 numTypeArguments: 2); 2123 numTypeArguments: 2);
2146 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); 2124 checkTypeRef(r.typeArguments[0], 'dart:core', 'int');
2147 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); 2125 checkTypeRef(r.typeArguments[1], 'dart:core', 'String');
2148 } 2126 }
2149 ]); 2127 ]);
2150 } 2128 }
2151 2129
2152 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { 2130 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() {
2153 addNamedSource( 2131 addNamedSource('/a.dart', '''
2154 '/a.dart',
2155 '''
2156 class C<K, V> { 2132 class C<K, V> {
2157 const C(); 2133 const C();
2158 } 2134 }
2159 '''); 2135 ''');
2160 UnlinkedVariable variable = serializeVariableText(''' 2136 UnlinkedVariable variable = serializeVariableText('''
2161 import 'a.dart' as p; 2137 import 'a.dart' as p;
2162 const v = const p.C<int, String>(); 2138 const v = const p.C<int, String>();
2163 '''); 2139 ''');
2164 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2140 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2165 UnlinkedExprOperation.invokeConstructor, 2141 UnlinkedExprOperation.invokeConstructor,
(...skipping 30 matching lines...) Expand all
2196 ], referenceValidators: [ 2172 ], referenceValidators: [
2197 (EntityRef r) => checkTypeRef(r, null, 'named', 2173 (EntityRef r) => checkTypeRef(r, null, 'named',
2198 expectedKind: ReferenceKind.constructor, 2174 expectedKind: ReferenceKind.constructor,
2199 prefixExpectations: [ 2175 prefixExpectations: [
2200 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2176 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
2201 ]) 2177 ])
2202 ]); 2178 ]);
2203 } 2179 }
2204 2180
2205 test_constExpr_invokeConstructor_named_imported() { 2181 test_constExpr_invokeConstructor_named_imported() {
2206 addNamedSource( 2182 addNamedSource('/a.dart', '''
2207 '/a.dart',
2208 '''
2209 class C { 2183 class C {
2210 const C.named(); 2184 const C.named();
2211 } 2185 }
2212 '''); 2186 ''');
2213 UnlinkedVariable variable = serializeVariableText(''' 2187 UnlinkedVariable variable = serializeVariableText('''
2214 import 'a.dart'; 2188 import 'a.dart';
2215 const v = const C.named(); 2189 const v = const C.named();
2216 '''); 2190 ''');
2217 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2191 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2218 UnlinkedExprOperation.invokeConstructor, 2192 UnlinkedExprOperation.invokeConstructor,
2219 ], ints: [ 2193 ], ints: [
2220 0, 2194 0,
2221 0 2195 0
2222 ], referenceValidators: [ 2196 ], referenceValidators: [
2223 (EntityRef r) => checkTypeRef(r, null, 'named', 2197 (EntityRef r) => checkTypeRef(r, null, 'named',
2224 expectedKind: ReferenceKind.constructor, 2198 expectedKind: ReferenceKind.constructor,
2225 prefixExpectations: [ 2199 prefixExpectations: [
2226 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 2200 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
2227 absoluteUri: absUri('/a.dart')) 2201 absoluteUri: absUri('/a.dart'))
2228 ]) 2202 ])
2229 ]); 2203 ]);
2230 } 2204 }
2231 2205
2232 test_constExpr_invokeConstructor_named_imported_withPrefix() { 2206 test_constExpr_invokeConstructor_named_imported_withPrefix() {
2233 addNamedSource( 2207 addNamedSource('/a.dart', '''
2234 '/a.dart',
2235 '''
2236 class C { 2208 class C {
2237 const C.named(); 2209 const C.named();
2238 } 2210 }
2239 '''); 2211 ''');
2240 UnlinkedVariable variable = serializeVariableText(''' 2212 UnlinkedVariable variable = serializeVariableText('''
2241 import 'a.dart' as p; 2213 import 'a.dart' as p;
2242 const v = const p.C.named(); 2214 const v = const p.C.named();
2243 '''); 2215 ''');
2244 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2216 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2245 UnlinkedExprOperation.invokeConstructor, 2217 UnlinkedExprOperation.invokeConstructor,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 'e', 2264 'e',
2293 'g', 2265 'g',
2294 'f' 2266 'f'
2295 ], referenceValidators: [ 2267 ], referenceValidators: [
2296 (EntityRef r) => 2268 (EntityRef r) =>
2297 checkTypeRef(r, null, 'C', expectedKind: ReferenceKind.classOrEnum) 2269 checkTypeRef(r, null, 'C', expectedKind: ReferenceKind.classOrEnum)
2298 ]); 2270 ]);
2299 } 2271 }
2300 2272
2301 test_constExpr_invokeConstructor_unnamed_imported() { 2273 test_constExpr_invokeConstructor_unnamed_imported() {
2302 addNamedSource( 2274 addNamedSource('/a.dart', '''
2303 '/a.dart',
2304 '''
2305 class C { 2275 class C {
2306 const C(); 2276 const C();
2307 } 2277 }
2308 '''); 2278 ''');
2309 UnlinkedVariable variable = serializeVariableText(''' 2279 UnlinkedVariable variable = serializeVariableText('''
2310 import 'a.dart'; 2280 import 'a.dart';
2311 const v = const C(); 2281 const v = const C();
2312 '''); 2282 ''');
2313 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2283 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2314 UnlinkedExprOperation.invokeConstructor, 2284 UnlinkedExprOperation.invokeConstructor,
2315 ], ints: [ 2285 ], ints: [
2316 0, 2286 0,
2317 0 2287 0
2318 ], referenceValidators: [ 2288 ], referenceValidators: [
2319 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C', 2289 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C',
2320 expectedKind: ReferenceKind.classOrEnum) 2290 expectedKind: ReferenceKind.classOrEnum)
2321 ]); 2291 ]);
2322 } 2292 }
2323 2293
2324 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() { 2294 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() {
2325 addNamedSource( 2295 addNamedSource('/a.dart', '''
2326 '/a.dart',
2327 '''
2328 class C { 2296 class C {
2329 const C(); 2297 const C();
2330 } 2298 }
2331 '''); 2299 ''');
2332 UnlinkedVariable variable = serializeVariableText(''' 2300 UnlinkedVariable variable = serializeVariableText('''
2333 import 'a.dart' as p; 2301 import 'a.dart' as p;
2334 const v = const p.C(); 2302 const v = const p.C();
2335 '''); 2303 ''');
2336 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2304 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2337 UnlinkedExprOperation.invokeConstructor, 2305 UnlinkedExprOperation.invokeConstructor,
2338 ], ints: [ 2306 ], ints: [
2339 0, 2307 0,
2340 0 2308 0
2341 ], referenceValidators: [ 2309 ], referenceValidators: [
2342 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C', 2310 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C',
2343 expectedKind: ReferenceKind.classOrEnum, 2311 expectedKind: ReferenceKind.classOrEnum,
2344 prefixExpectations: [ 2312 prefixExpectations: [
2345 new _PrefixExpectation(ReferenceKind.prefix, 'p') 2313 new _PrefixExpectation(ReferenceKind.prefix, 'p')
2346 ]) 2314 ])
2347 ]); 2315 ]);
2348 } 2316 }
2349 2317
2350 test_constExpr_invokeConstructor_unresolved_named() { 2318 test_constExpr_invokeConstructor_unresolved_named() {
2351 UnlinkedVariable variable = serializeVariableText( 2319 UnlinkedVariable variable = serializeVariableText('''
2352 '''
2353 class C {} 2320 class C {}
2354 const v = const C.foo(); 2321 const v = const C.foo();
2355 ''', 2322 ''', allowErrors: true);
2356 allowErrors: true);
2357 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2323 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2358 UnlinkedExprOperation.invokeConstructor, 2324 UnlinkedExprOperation.invokeConstructor,
2359 ], ints: [ 2325 ], ints: [
2360 0, 2326 0,
2361 0 2327 0
2362 ], referenceValidators: [ 2328 ], referenceValidators: [
2363 (EntityRef r) => checkTypeRef(r, null, 'foo', 2329 (EntityRef r) => checkTypeRef(r, null, 'foo',
2364 expectedKind: ReferenceKind.unresolved, 2330 expectedKind: ReferenceKind.unresolved,
2365 prefixExpectations: [ 2331 prefixExpectations: [
2366 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2332 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
2367 ]) 2333 ])
2368 ]); 2334 ]);
2369 } 2335 }
2370 2336
2371 test_constExpr_invokeConstructor_unresolved_named2() { 2337 test_constExpr_invokeConstructor_unresolved_named2() {
2372 UnlinkedVariable variable = serializeVariableText( 2338 UnlinkedVariable variable = serializeVariableText('''
2373 '''
2374 const v = const C.foo(); 2339 const v = const C.foo();
2375 ''', 2340 ''', allowErrors: true);
2376 allowErrors: true);
2377 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2341 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2378 UnlinkedExprOperation.invokeConstructor, 2342 UnlinkedExprOperation.invokeConstructor,
2379 ], ints: [ 2343 ], ints: [
2380 0, 2344 0,
2381 0 2345 0
2382 ], referenceValidators: [ 2346 ], referenceValidators: [
2383 (EntityRef r) => checkTypeRef(r, null, 'foo', 2347 (EntityRef r) => checkTypeRef(r, null, 'foo',
2384 expectedKind: ReferenceKind.unresolved, 2348 expectedKind: ReferenceKind.unresolved,
2385 prefixExpectations: [ 2349 prefixExpectations: [
2386 new _PrefixExpectation(ReferenceKind.unresolved, 'C') 2350 new _PrefixExpectation(ReferenceKind.unresolved, 'C')
2387 ]) 2351 ])
2388 ]); 2352 ]);
2389 } 2353 }
2390 2354
2391 test_constExpr_invokeConstructor_unresolved_named_prefixed() { 2355 test_constExpr_invokeConstructor_unresolved_named_prefixed() {
2392 addNamedSource( 2356 addNamedSource('/a.dart', '''
2393 '/a.dart',
2394 '''
2395 class C { 2357 class C {
2396 } 2358 }
2397 '''); 2359 ''');
2398 UnlinkedVariable variable = serializeVariableText( 2360 UnlinkedVariable variable = serializeVariableText('''
2399 '''
2400 import 'a.dart' as p; 2361 import 'a.dart' as p;
2401 const v = const p.C.foo(); 2362 const v = const p.C.foo();
2402 ''', 2363 ''', allowErrors: true);
2403 allowErrors: true);
2404 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2364 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2405 UnlinkedExprOperation.invokeConstructor, 2365 UnlinkedExprOperation.invokeConstructor,
2406 ], ints: [ 2366 ], ints: [
2407 0, 2367 0,
2408 0 2368 0
2409 ], referenceValidators: [ 2369 ], referenceValidators: [
2410 (EntityRef r) => checkTypeRef(r, null, 'foo', 2370 (EntityRef r) => checkTypeRef(r, null, 'foo',
2411 expectedKind: ReferenceKind.unresolved, 2371 expectedKind: ReferenceKind.unresolved,
2412 prefixExpectations: [ 2372 prefixExpectations: [
2413 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 2373 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
2414 absoluteUri: absUri('/a.dart')), 2374 absoluteUri: absUri('/a.dart')),
2415 new _PrefixExpectation(ReferenceKind.prefix, 'p') 2375 new _PrefixExpectation(ReferenceKind.prefix, 'p')
2416 ]) 2376 ])
2417 ]); 2377 ]);
2418 } 2378 }
2419 2379
2420 test_constExpr_invokeConstructor_unresolved_named_prefixed2() { 2380 test_constExpr_invokeConstructor_unresolved_named_prefixed2() {
2421 addNamedSource('/a.dart', ''); 2381 addNamedSource('/a.dart', '');
2422 UnlinkedVariable variable = serializeVariableText( 2382 UnlinkedVariable variable = serializeVariableText('''
2423 '''
2424 import 'a.dart' as p; 2383 import 'a.dart' as p;
2425 const v = const p.C.foo(); 2384 const v = const p.C.foo();
2426 ''', 2385 ''', allowErrors: true);
2427 allowErrors: true);
2428 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2386 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2429 UnlinkedExprOperation.invokeConstructor, 2387 UnlinkedExprOperation.invokeConstructor,
2430 ], ints: [ 2388 ], ints: [
2431 0, 2389 0,
2432 0 2390 0
2433 ], referenceValidators: [ 2391 ], referenceValidators: [
2434 (EntityRef r) => checkTypeRef(r, null, 'foo', 2392 (EntityRef r) => checkTypeRef(r, null, 'foo',
2435 expectedKind: ReferenceKind.unresolved, 2393 expectedKind: ReferenceKind.unresolved,
2436 prefixExpectations: [ 2394 prefixExpectations: [
2437 new _PrefixExpectation(ReferenceKind.unresolved, 'C'), 2395 new _PrefixExpectation(ReferenceKind.unresolved, 'C'),
2438 new _PrefixExpectation(ReferenceKind.prefix, 'p') 2396 new _PrefixExpectation(ReferenceKind.prefix, 'p')
2439 ]) 2397 ])
2440 ]); 2398 ]);
2441 } 2399 }
2442 2400
2443 test_constExpr_invokeConstructor_unresolved_unnamed() { 2401 test_constExpr_invokeConstructor_unresolved_unnamed() {
2444 UnlinkedVariable variable = serializeVariableText( 2402 UnlinkedVariable variable = serializeVariableText('''
2445 '''
2446 const v = const Foo(); 2403 const v = const Foo();
2447 ''', 2404 ''', allowErrors: true);
2448 allowErrors: true);
2449 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2405 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2450 UnlinkedExprOperation.invokeConstructor, 2406 UnlinkedExprOperation.invokeConstructor,
2451 ], ints: [ 2407 ], ints: [
2452 0, 2408 0,
2453 0 2409 0
2454 ], referenceValidators: [ 2410 ], referenceValidators: [
2455 (EntityRef r) => 2411 (EntityRef r) =>
2456 checkTypeRef(r, null, 'Foo', expectedKind: ReferenceKind.unresolved) 2412 checkTypeRef(r, null, 'Foo', expectedKind: ReferenceKind.unresolved)
2457 ]); 2413 ]);
2458 } 2414 }
(...skipping 30 matching lines...) Expand all
2489 ], referenceValidators: [ 2445 ], referenceValidators: [
2490 (EntityRef r) => checkTypeRef(r, null, 'length', 2446 (EntityRef r) => checkTypeRef(r, null, 'length',
2491 expectedKind: ReferenceKind.propertyAccessor, 2447 expectedKind: ReferenceKind.propertyAccessor,
2492 prefixExpectations: [ 2448 prefixExpectations: [
2493 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2449 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
2494 ]) 2450 ])
2495 ]); 2451 ]);
2496 } 2452 }
2497 2453
2498 test_constExpr_length_classConstField_imported_withPrefix() { 2454 test_constExpr_length_classConstField_imported_withPrefix() {
2499 addNamedSource( 2455 addNamedSource('/a.dart', '''
2500 '/a.dart',
2501 '''
2502 class C { 2456 class C {
2503 static const int length = 0; 2457 static const int length = 0;
2504 } 2458 }
2505 '''); 2459 ''');
2506 UnlinkedVariable variable = serializeVariableText(''' 2460 UnlinkedVariable variable = serializeVariableText('''
2507 import 'a.dart' as p; 2461 import 'a.dart' as p;
2508 const int v = p.C.length; 2462 const int v = p.C.length;
2509 '''); 2463 ''');
2510 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2464 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2511 UnlinkedExprOperation.pushReference 2465 UnlinkedExprOperation.pushReference
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 expectedKind: ReferenceKind.unresolved, 2506 expectedKind: ReferenceKind.unresolved,
2553 unresolvedHasName: true, 2507 unresolvedHasName: true,
2554 prefixExpectations: [ 2508 prefixExpectations: [
2555 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'), 2509 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'),
2556 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), 2510 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'),
2557 ]) 2511 ])
2558 ]); 2512 ]);
2559 } 2513 }
2560 2514
2561 test_constExpr_length_identifierTarget_imported() { 2515 test_constExpr_length_identifierTarget_imported() {
2562 addNamedSource( 2516 addNamedSource('/a.dart', '''
2563 '/a.dart',
2564 '''
2565 const String a = 'aaa'; 2517 const String a = 'aaa';
2566 '''); 2518 ''');
2567 UnlinkedVariable variable = serializeVariableText(''' 2519 UnlinkedVariable variable = serializeVariableText('''
2568 import 'a.dart'; 2520 import 'a.dart';
2569 const int v = a.length; 2521 const int v = a.length;
2570 '''); 2522 ''');
2571 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2523 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2572 UnlinkedExprOperation.pushReference 2524 UnlinkedExprOperation.pushReference
2573 ], referenceValidators: [ 2525 ], referenceValidators: [
2574 (EntityRef r) => checkTypeRef(r, null, 'length', 2526 (EntityRef r) => checkTypeRef(r, null, 'length',
2575 expectedKind: ReferenceKind.unresolved, 2527 expectedKind: ReferenceKind.unresolved,
2576 unresolvedHasName: true, 2528 unresolvedHasName: true,
2577 prefixExpectations: [ 2529 prefixExpectations: [
2578 new _PrefixExpectation( 2530 new _PrefixExpectation(
2579 ReferenceKind.topLevelPropertyAccessor, 'a', 2531 ReferenceKind.topLevelPropertyAccessor, 'a',
2580 absoluteUri: absUri('/a.dart')) 2532 absoluteUri: absUri('/a.dart'))
2581 ]) 2533 ])
2582 ]); 2534 ]);
2583 } 2535 }
2584 2536
2585 test_constExpr_length_identifierTarget_imported_withPrefix() { 2537 test_constExpr_length_identifierTarget_imported_withPrefix() {
2586 addNamedSource( 2538 addNamedSource('/a.dart', '''
2587 '/a.dart',
2588 '''
2589 const String a = 'aaa'; 2539 const String a = 'aaa';
2590 '''); 2540 ''');
2591 UnlinkedVariable variable = serializeVariableText(''' 2541 UnlinkedVariable variable = serializeVariableText('''
2592 import 'a.dart' as p; 2542 import 'a.dart' as p;
2593 const int v = p.a.length; 2543 const int v = p.a.length;
2594 '''); 2544 ''');
2595 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2545 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2596 UnlinkedExprOperation.pushReference 2546 UnlinkedExprOperation.pushReference
2597 ], referenceValidators: [ 2547 ], referenceValidators: [
2598 (EntityRef r) => checkTypeRef(r, null, 'length', 2548 (EntityRef r) => checkTypeRef(r, null, 'length',
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 ], referenceValidators: [ 2884 ], referenceValidators: [
2935 (EntityRef r) => checkTypeRef(r, null, 'V1', 2885 (EntityRef r) => checkTypeRef(r, null, 'V1',
2936 expectedKind: ReferenceKind.propertyAccessor, 2886 expectedKind: ReferenceKind.propertyAccessor,
2937 prefixExpectations: [ 2887 prefixExpectations: [
2938 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2888 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
2939 ]) 2889 ])
2940 ]); 2890 ]);
2941 } 2891 }
2942 2892
2943 test_constExpr_pushReference_enumValue_viaImport() { 2893 test_constExpr_pushReference_enumValue_viaImport() {
2944 addNamedSource( 2894 addNamedSource('/a.dart', '''
2945 '/a.dart',
2946 '''
2947 enum C {V1, V2, V3} 2895 enum C {V1, V2, V3}
2948 '''); 2896 ''');
2949 UnlinkedVariable variable = serializeVariableText(''' 2897 UnlinkedVariable variable = serializeVariableText('''
2950 import 'a.dart'; 2898 import 'a.dart';
2951 const v = C.V1; 2899 const v = C.V1;
2952 '''); 2900 ''');
2953 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2901 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2954 UnlinkedExprOperation.pushReference 2902 UnlinkedExprOperation.pushReference
2955 ], referenceValidators: [ 2903 ], referenceValidators: [
2956 (EntityRef r) => checkTypeRef(r, null, 'V1', 2904 (EntityRef r) => checkTypeRef(r, null, 'V1',
(...skipping 15 matching lines...) Expand all
2972 ], referenceValidators: [ 2920 ], referenceValidators: [
2973 (EntityRef r) => checkTypeRef(r, null, 'values', 2921 (EntityRef r) => checkTypeRef(r, null, 'values',
2974 expectedKind: ReferenceKind.propertyAccessor, 2922 expectedKind: ReferenceKind.propertyAccessor,
2975 prefixExpectations: [ 2923 prefixExpectations: [
2976 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2924 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
2977 ]) 2925 ])
2978 ]); 2926 ]);
2979 } 2927 }
2980 2928
2981 test_constExpr_pushReference_enumValues_viaImport() { 2929 test_constExpr_pushReference_enumValues_viaImport() {
2982 addNamedSource( 2930 addNamedSource('/a.dart', '''
2983 '/a.dart',
2984 '''
2985 enum C {V1, V2, V3} 2931 enum C {V1, V2, V3}
2986 '''); 2932 ''');
2987 UnlinkedVariable variable = serializeVariableText(''' 2933 UnlinkedVariable variable = serializeVariableText('''
2988 import 'a.dart'; 2934 import 'a.dart';
2989 const v = C.values; 2935 const v = C.values;
2990 '''); 2936 ''');
2991 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2937 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
2992 UnlinkedExprOperation.pushReference 2938 UnlinkedExprOperation.pushReference
2993 ], referenceValidators: [ 2939 ], referenceValidators: [
2994 (EntityRef r) => checkTypeRef(r, null, 'values', 2940 (EntityRef r) => checkTypeRef(r, null, 'values',
(...skipping 17 matching lines...) Expand all
3012 ], referenceValidators: [ 2958 ], referenceValidators: [
3013 (EntityRef r) => checkTypeRef(r, null, 'F', 2959 (EntityRef r) => checkTypeRef(r, null, 'F',
3014 expectedKind: ReferenceKind.propertyAccessor, 2960 expectedKind: ReferenceKind.propertyAccessor,
3015 prefixExpectations: [ 2961 prefixExpectations: [
3016 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 2962 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
3017 ]) 2963 ])
3018 ]); 2964 ]);
3019 } 2965 }
3020 2966
3021 test_constExpr_pushReference_field_imported() { 2967 test_constExpr_pushReference_field_imported() {
3022 addNamedSource( 2968 addNamedSource('/a.dart', '''
3023 '/a.dart',
3024 '''
3025 class C { 2969 class C {
3026 static const int F = 1; 2970 static const int F = 1;
3027 } 2971 }
3028 '''); 2972 ''');
3029 UnlinkedVariable variable = serializeVariableText(''' 2973 UnlinkedVariable variable = serializeVariableText('''
3030 import 'a.dart'; 2974 import 'a.dart';
3031 const v = C.F; 2975 const v = C.F;
3032 '''); 2976 ''');
3033 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2977 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3034 UnlinkedExprOperation.pushReference 2978 UnlinkedExprOperation.pushReference
3035 ], referenceValidators: [ 2979 ], referenceValidators: [
3036 (EntityRef r) => checkTypeRef(r, null, 'F', 2980 (EntityRef r) => checkTypeRef(r, null, 'F',
3037 expectedKind: ReferenceKind.propertyAccessor, 2981 expectedKind: ReferenceKind.propertyAccessor,
3038 prefixExpectations: [ 2982 prefixExpectations: [
3039 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 2983 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
3040 absoluteUri: absUri('/a.dart')) 2984 absoluteUri: absUri('/a.dart'))
3041 ]) 2985 ])
3042 ]); 2986 ]);
3043 } 2987 }
3044 2988
3045 test_constExpr_pushReference_field_imported_withPrefix() { 2989 test_constExpr_pushReference_field_imported_withPrefix() {
3046 addNamedSource( 2990 addNamedSource('/a.dart', '''
3047 '/a.dart',
3048 '''
3049 class C { 2991 class C {
3050 static const int F = 1; 2992 static const int F = 1;
3051 } 2993 }
3052 '''); 2994 ''');
3053 UnlinkedVariable variable = serializeVariableText(''' 2995 UnlinkedVariable variable = serializeVariableText('''
3054 import 'a.dart' as p; 2996 import 'a.dart' as p;
3055 const v = p.C.F; 2997 const v = p.C.F;
3056 '''); 2998 ''');
3057 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 2999 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3058 UnlinkedExprOperation.pushReference 3000 UnlinkedExprOperation.pushReference
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 ], referenceValidators: [ 3039 ], referenceValidators: [
3098 (EntityRef r) => checkTypeRef(r, null, 'x', 3040 (EntityRef r) => checkTypeRef(r, null, 'x',
3099 expectedKind: ReferenceKind.propertyAccessor, 3041 expectedKind: ReferenceKind.propertyAccessor,
3100 prefixExpectations: [ 3042 prefixExpectations: [
3101 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 3043 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
3102 ]) 3044 ])
3103 ]); 3045 ]);
3104 } 3046 }
3105 3047
3106 test_constExpr_pushReference_staticGetter_imported() { 3048 test_constExpr_pushReference_staticGetter_imported() {
3107 addNamedSource( 3049 addNamedSource('/a.dart', '''
3108 '/a.dart',
3109 '''
3110 class C { 3050 class C {
3111 static int get x => null; 3051 static int get x => null;
3112 } 3052 }
3113 '''); 3053 ''');
3114 UnlinkedVariable variable = serializeVariableText(''' 3054 UnlinkedVariable variable = serializeVariableText('''
3115 import 'a.dart'; 3055 import 'a.dart';
3116 const v = C.x; 3056 const v = C.x;
3117 '''); 3057 ''');
3118 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3058 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3119 UnlinkedExprOperation.pushReference 3059 UnlinkedExprOperation.pushReference
3120 ], referenceValidators: [ 3060 ], referenceValidators: [
3121 (EntityRef r) => checkTypeRef(r, null, 'x', 3061 (EntityRef r) => checkTypeRef(r, null, 'x',
3122 expectedKind: ReferenceKind.propertyAccessor, 3062 expectedKind: ReferenceKind.propertyAccessor,
3123 prefixExpectations: [ 3063 prefixExpectations: [
3124 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 3064 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
3125 absoluteUri: absUri('/a.dart')) 3065 absoluteUri: absUri('/a.dart'))
3126 ]) 3066 ])
3127 ]); 3067 ]);
3128 } 3068 }
3129 3069
3130 test_constExpr_pushReference_staticGetter_imported_withPrefix() { 3070 test_constExpr_pushReference_staticGetter_imported_withPrefix() {
3131 addNamedSource( 3071 addNamedSource('/a.dart', '''
3132 '/a.dart',
3133 '''
3134 class C { 3072 class C {
3135 static int get x => null; 3073 static int get x => null;
3136 } 3074 }
3137 '''); 3075 ''');
3138 UnlinkedVariable variable = serializeVariableText(''' 3076 UnlinkedVariable variable = serializeVariableText('''
3139 import 'a.dart' as p; 3077 import 'a.dart' as p;
3140 const v = p.C.x; 3078 const v = p.C.x;
3141 '''); 3079 ''');
3142 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3080 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3143 UnlinkedExprOperation.pushReference 3081 UnlinkedExprOperation.pushReference
(...skipping 20 matching lines...) Expand all
3164 ], referenceValidators: [ 3102 ], referenceValidators: [
3165 (EntityRef r) => checkTypeRef(r, null, 'm', 3103 (EntityRef r) => checkTypeRef(r, null, 'm',
3166 expectedKind: ReferenceKind.method, 3104 expectedKind: ReferenceKind.method,
3167 prefixExpectations: [ 3105 prefixExpectations: [
3168 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 3106 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
3169 ]) 3107 ])
3170 ]); 3108 ]);
3171 } 3109 }
3172 3110
3173 test_constExpr_pushReference_staticMethod_imported() { 3111 test_constExpr_pushReference_staticMethod_imported() {
3174 addNamedSource( 3112 addNamedSource('/a.dart', '''
3175 '/a.dart',
3176 '''
3177 class C { 3113 class C {
3178 static m() {} 3114 static m() {}
3179 } 3115 }
3180 '''); 3116 ''');
3181 UnlinkedVariable variable = serializeVariableText(''' 3117 UnlinkedVariable variable = serializeVariableText('''
3182 import 'a.dart'; 3118 import 'a.dart';
3183 const v = C.m; 3119 const v = C.m;
3184 '''); 3120 ''');
3185 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3121 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3186 UnlinkedExprOperation.pushReference 3122 UnlinkedExprOperation.pushReference
3187 ], referenceValidators: [ 3123 ], referenceValidators: [
3188 (EntityRef r) => checkTypeRef(r, null, 'm', 3124 (EntityRef r) => checkTypeRef(r, null, 'm',
3189 expectedKind: ReferenceKind.method, 3125 expectedKind: ReferenceKind.method,
3190 prefixExpectations: [ 3126 prefixExpectations: [
3191 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 3127 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
3192 absoluteUri: absUri('/a.dart')) 3128 absoluteUri: absUri('/a.dart'))
3193 ]) 3129 ])
3194 ]); 3130 ]);
3195 } 3131 }
3196 3132
3197 test_constExpr_pushReference_staticMethod_imported_withPrefix() { 3133 test_constExpr_pushReference_staticMethod_imported_withPrefix() {
3198 addNamedSource( 3134 addNamedSource('/a.dart', '''
3199 '/a.dart',
3200 '''
3201 class C { 3135 class C {
3202 static m() {} 3136 static m() {}
3203 } 3137 }
3204 '''); 3138 ''');
3205 UnlinkedVariable variable = serializeVariableText(''' 3139 UnlinkedVariable variable = serializeVariableText('''
3206 import 'a.dart' as p; 3140 import 'a.dart' as p;
3207 const v = p.C.m; 3141 const v = p.C.m;
3208 '''); 3142 ''');
3209 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3143 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3210 UnlinkedExprOperation.pushReference 3144 UnlinkedExprOperation.pushReference
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 '''); 3178 ''');
3245 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3179 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3246 UnlinkedExprOperation.pushReference 3180 UnlinkedExprOperation.pushReference
3247 ], referenceValidators: [ 3181 ], referenceValidators: [
3248 (EntityRef r) => checkTypeRef(r, null, 'f', 3182 (EntityRef r) => checkTypeRef(r, null, 'f',
3249 expectedKind: ReferenceKind.topLevelFunction) 3183 expectedKind: ReferenceKind.topLevelFunction)
3250 ]); 3184 ]);
3251 } 3185 }
3252 3186
3253 test_constExpr_pushReference_topLevelFunction_imported() { 3187 test_constExpr_pushReference_topLevelFunction_imported() {
3254 addNamedSource( 3188 addNamedSource('/a.dart', '''
3255 '/a.dart',
3256 '''
3257 f() {} 3189 f() {}
3258 '''); 3190 ''');
3259 UnlinkedVariable variable = serializeVariableText(''' 3191 UnlinkedVariable variable = serializeVariableText('''
3260 import 'a.dart'; 3192 import 'a.dart';
3261 const v = f; 3193 const v = f;
3262 '''); 3194 ''');
3263 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3195 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3264 UnlinkedExprOperation.pushReference 3196 UnlinkedExprOperation.pushReference
3265 ], referenceValidators: [ 3197 ], referenceValidators: [
3266 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f', 3198 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f',
3267 expectedKind: ReferenceKind.topLevelFunction) 3199 expectedKind: ReferenceKind.topLevelFunction)
3268 ]); 3200 ]);
3269 } 3201 }
3270 3202
3271 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() { 3203 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() {
3272 addNamedSource( 3204 addNamedSource('/a.dart', '''
3273 '/a.dart',
3274 '''
3275 f() {} 3205 f() {}
3276 '''); 3206 ''');
3277 UnlinkedVariable variable = serializeVariableText(''' 3207 UnlinkedVariable variable = serializeVariableText('''
3278 import 'a.dart' as p; 3208 import 'a.dart' as p;
3279 const v = p.f; 3209 const v = p.f;
3280 '''); 3210 ''');
3281 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3211 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3282 UnlinkedExprOperation.pushReference 3212 UnlinkedExprOperation.pushReference
3283 ], referenceValidators: [ 3213 ], referenceValidators: [
3284 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f', 3214 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f',
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3316 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3387 UnlinkedExprOperation.pushReference 3317 UnlinkedExprOperation.pushReference
3388 ], referenceValidators: [ 3318 ], referenceValidators: [
3389 (EntityRef r) { 3319 (EntityRef r) {
3390 return checkParamTypeRef(r, 1); 3320 return checkParamTypeRef(r, 1);
3391 } 3321 }
3392 ]); 3322 ]);
3393 } 3323 }
3394 3324
3395 test_constExpr_pushReference_unresolved_prefix0() { 3325 test_constExpr_pushReference_unresolved_prefix0() {
3396 UnlinkedVariable variable = serializeVariableText( 3326 UnlinkedVariable variable = serializeVariableText('''
3397 '''
3398 const v = foo; 3327 const v = foo;
3399 ''', 3328 ''', allowErrors: true);
3400 allowErrors: true);
3401 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3329 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3402 UnlinkedExprOperation.pushReference 3330 UnlinkedExprOperation.pushReference
3403 ], referenceValidators: [ 3331 ], referenceValidators: [
3404 (EntityRef r) => 3332 (EntityRef r) =>
3405 checkTypeRef(r, null, 'foo', expectedKind: ReferenceKind.unresolved) 3333 checkTypeRef(r, null, 'foo', expectedKind: ReferenceKind.unresolved)
3406 ]); 3334 ]);
3407 } 3335 }
3408 3336
3409 test_constExpr_pushReference_unresolved_prefix1() { 3337 test_constExpr_pushReference_unresolved_prefix1() {
3410 UnlinkedVariable variable = serializeVariableText( 3338 UnlinkedVariable variable = serializeVariableText('''
3411 '''
3412 class C {} 3339 class C {}
3413 const v = C.foo; 3340 const v = C.foo;
3414 ''', 3341 ''', allowErrors: true);
3415 allowErrors: true);
3416 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3342 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3417 UnlinkedExprOperation.pushReference 3343 UnlinkedExprOperation.pushReference
3418 ], referenceValidators: [ 3344 ], referenceValidators: [
3419 (EntityRef r) => checkTypeRef(r, null, 'foo', 3345 (EntityRef r) => checkTypeRef(r, null, 'foo',
3420 expectedKind: ReferenceKind.unresolved, 3346 expectedKind: ReferenceKind.unresolved,
3421 prefixExpectations: [ 3347 prefixExpectations: [
3422 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') 3348 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
3423 ]) 3349 ])
3424 ]); 3350 ]);
3425 } 3351 }
3426 3352
3427 test_constExpr_pushReference_unresolved_prefix2() { 3353 test_constExpr_pushReference_unresolved_prefix2() {
3428 addNamedSource( 3354 addNamedSource('/a.dart', '''
3429 '/a.dart',
3430 '''
3431 class C {} 3355 class C {}
3432 '''); 3356 ''');
3433 UnlinkedVariable variable = serializeVariableText( 3357 UnlinkedVariable variable = serializeVariableText('''
3434 '''
3435 import 'a.dart' as p; 3358 import 'a.dart' as p;
3436 const v = p.C.foo; 3359 const v = p.C.foo;
3437 ''', 3360 ''', allowErrors: true);
3438 allowErrors: true);
3439 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ 3361 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [
3440 UnlinkedExprOperation.pushReference 3362 UnlinkedExprOperation.pushReference
3441 ], referenceValidators: [ 3363 ], referenceValidators: [
3442 (EntityRef r) => checkTypeRef(r, null, 'foo', 3364 (EntityRef r) => checkTypeRef(r, null, 'foo',
3443 expectedKind: ReferenceKind.unresolved, 3365 expectedKind: ReferenceKind.unresolved,
3444 prefixExpectations: [ 3366 prefixExpectations: [
3445 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', 3367 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
3446 absoluteUri: absUri('/a.dart')), 3368 absoluteUri: absUri('/a.dart')),
3447 new _PrefixExpectation(ReferenceKind.prefix, 'p'), 3369 new _PrefixExpectation(ReferenceKind.prefix, 'p'),
3448 ]) 3370 ])
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
4109 prefixExpectations: [ 4031 prefixExpectations: [
4110 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', 4032 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D',
4111 numTypeParameters: 2) 4033 numTypeParameters: 2)
4112 ], 4034 ],
4113 numTypeArguments: 2); 4035 numTypeArguments: 2);
4114 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); 4036 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
4115 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); 4037 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
4116 } 4038 }
4117 4039
4118 test_constructor_redirected_factory_named_imported() { 4040 test_constructor_redirected_factory_named_imported() {
4119 addNamedSource( 4041 addNamedSource('/foo.dart', '''
4120 '/foo.dart',
4121 '''
4122 import 'test.dart'; 4042 import 'test.dart';
4123 class D extends C { 4043 class D extends C {
4124 D.named() : super._(); 4044 D.named() : super._();
4125 } 4045 }
4126 '''); 4046 ''');
4127 String text = ''' 4047 String text = '''
4128 import 'foo.dart'; 4048 import 'foo.dart';
4129 class C { 4049 class C {
4130 factory C() = D.named; 4050 factory C() = D.named;
4131 C._(); 4051 C._();
4132 } 4052 }
4133 '''; 4053 ''';
4134 UnlinkedExecutable executable = 4054 UnlinkedExecutable executable =
4135 serializeClassText(text, className: 'C').executables[0]; 4055 serializeClassText(text, className: 'C').executables[0];
4136 expect(executable.isRedirectedConstructor, isTrue); 4056 expect(executable.isRedirectedConstructor, isTrue);
4137 expect(executable.isFactory, isTrue); 4057 expect(executable.isFactory, isTrue);
4138 expect(executable.redirectedConstructorName, isEmpty); 4058 expect(executable.redirectedConstructorName, isEmpty);
4139 checkTypeRef(executable.redirectedConstructor, null, 'named', 4059 checkTypeRef(executable.redirectedConstructor, null, 'named',
4140 expectedKind: ReferenceKind.constructor, 4060 expectedKind: ReferenceKind.constructor,
4141 prefixExpectations: [ 4061 prefixExpectations: [
4142 new _PrefixExpectation( 4062 new _PrefixExpectation(
4143 ReferenceKind.classOrEnum, 4063 ReferenceKind.classOrEnum,
4144 'D', 4064 'D',
4145 absoluteUri: absUri('/foo.dart'), 4065 absoluteUri: absUri('/foo.dart'),
4146 ) 4066 )
4147 ]); 4067 ]);
4148 } 4068 }
4149 4069
4150 test_constructor_redirected_factory_named_imported_generic() { 4070 test_constructor_redirected_factory_named_imported_generic() {
4151 addNamedSource( 4071 addNamedSource('/foo.dart', '''
4152 '/foo.dart',
4153 '''
4154 import 'test.dart'; 4072 import 'test.dart';
4155 class D<T, U> extends C<U, T> { 4073 class D<T, U> extends C<U, T> {
4156 D.named() : super._(); 4074 D.named() : super._();
4157 } 4075 }
4158 '''); 4076 ''');
4159 String text = ''' 4077 String text = '''
4160 import 'foo.dart'; 4078 import 'foo.dart';
4161 class C<T, U> { 4079 class C<T, U> {
4162 factory C() = D<U, T>.named; 4080 factory C() = D<U, T>.named;
4163 C._(); 4081 C._();
(...skipping 13 matching lines...) Expand all
4177 numTypeParameters: 2, 4095 numTypeParameters: 2,
4178 absoluteUri: absUri('/foo.dart'), 4096 absoluteUri: absUri('/foo.dart'),
4179 ) 4097 )
4180 ], 4098 ],
4181 numTypeArguments: 2); 4099 numTypeArguments: 2);
4182 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); 4100 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
4183 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); 4101 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
4184 } 4102 }
4185 4103
4186 test_constructor_redirected_factory_named_prefixed() { 4104 test_constructor_redirected_factory_named_prefixed() {
4187 addNamedSource( 4105 addNamedSource('/foo.dart', '''
4188 '/foo.dart',
4189 '''
4190 import 'test.dart'; 4106 import 'test.dart';
4191 class D extends C { 4107 class D extends C {
4192 D.named() : super._(); 4108 D.named() : super._();
4193 } 4109 }
4194 '''); 4110 ''');
4195 String text = ''' 4111 String text = '''
4196 import 'foo.dart' as foo; 4112 import 'foo.dart' as foo;
4197 class C { 4113 class C {
4198 factory C() = foo.D.named; 4114 factory C() = foo.D.named;
4199 C._(); 4115 C._();
(...skipping 10 matching lines...) Expand all
4210 new _PrefixExpectation( 4126 new _PrefixExpectation(
4211 ReferenceKind.classOrEnum, 4127 ReferenceKind.classOrEnum,
4212 'D', 4128 'D',
4213 absoluteUri: absUri('/foo.dart'), 4129 absoluteUri: absUri('/foo.dart'),
4214 ), 4130 ),
4215 new _PrefixExpectation(ReferenceKind.prefix, 'foo') 4131 new _PrefixExpectation(ReferenceKind.prefix, 'foo')
4216 ]); 4132 ]);
4217 } 4133 }
4218 4134
4219 test_constructor_redirected_factory_named_prefixed_generic() { 4135 test_constructor_redirected_factory_named_prefixed_generic() {
4220 addNamedSource( 4136 addNamedSource('/foo.dart', '''
4221 '/foo.dart',
4222 '''
4223 import 'test.dart'; 4137 import 'test.dart';
4224 class D<T, U> extends C<U, T> { 4138 class D<T, U> extends C<U, T> {
4225 D.named() : super._(); 4139 D.named() : super._();
4226 } 4140 }
4227 '''); 4141 ''');
4228 String text = ''' 4142 String text = '''
4229 import 'foo.dart' as foo; 4143 import 'foo.dart' as foo;
4230 class C<T, U> { 4144 class C<T, U> {
4231 factory C() = foo.D<U, T>.named; 4145 factory C() = foo.D<U, T>.named;
4232 C._(); 4146 C._();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4286 expect(executable.isRedirectedConstructor, isTrue); 4200 expect(executable.isRedirectedConstructor, isTrue);
4287 expect(executable.isFactory, isTrue); 4201 expect(executable.isFactory, isTrue);
4288 expect(executable.redirectedConstructorName, isEmpty); 4202 expect(executable.redirectedConstructorName, isEmpty);
4289 checkTypeRef(executable.redirectedConstructor, null, 'D', 4203 checkTypeRef(executable.redirectedConstructor, null, 'D',
4290 numTypeParameters: 2, numTypeArguments: 2); 4204 numTypeParameters: 2, numTypeArguments: 2);
4291 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); 4205 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
4292 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); 4206 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
4293 } 4207 }
4294 4208
4295 test_constructor_redirected_factory_unnamed_imported() { 4209 test_constructor_redirected_factory_unnamed_imported() {
4296 addNamedSource( 4210 addNamedSource('/foo.dart', '''
4297 '/foo.dart',
4298 '''
4299 import 'test.dart'; 4211 import 'test.dart';
4300 class D extends C { 4212 class D extends C {
4301 D() : super._(); 4213 D() : super._();
4302 } 4214 }
4303 '''); 4215 ''');
4304 String text = ''' 4216 String text = '''
4305 import 'foo.dart'; 4217 import 'foo.dart';
4306 class C { 4218 class C {
4307 factory C() = D; 4219 factory C() = D;
4308 C._(); 4220 C._();
4309 } 4221 }
4310 '''; 4222 ''';
4311 UnlinkedExecutable executable = 4223 UnlinkedExecutable executable =
4312 serializeClassText(text, className: 'C').executables[0]; 4224 serializeClassText(text, className: 'C').executables[0];
4313 expect(executable.isRedirectedConstructor, isTrue); 4225 expect(executable.isRedirectedConstructor, isTrue);
4314 expect(executable.isFactory, isTrue); 4226 expect(executable.isFactory, isTrue);
4315 expect(executable.redirectedConstructorName, isEmpty); 4227 expect(executable.redirectedConstructorName, isEmpty);
4316 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D'); 4228 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D');
4317 } 4229 }
4318 4230
4319 test_constructor_redirected_factory_unnamed_imported_generic() { 4231 test_constructor_redirected_factory_unnamed_imported_generic() {
4320 addNamedSource( 4232 addNamedSource('/foo.dart', '''
4321 '/foo.dart',
4322 '''
4323 import 'test.dart'; 4233 import 'test.dart';
4324 class D<T, U> extends C<U, T> { 4234 class D<T, U> extends C<U, T> {
4325 D() : super._(); 4235 D() : super._();
4326 } 4236 }
4327 '''); 4237 ''');
4328 String text = ''' 4238 String text = '''
4329 import 'foo.dart'; 4239 import 'foo.dart';
4330 class C<T, U> { 4240 class C<T, U> {
4331 factory C() = D<U, T>; 4241 factory C() = D<U, T>;
4332 C._(); 4242 C._();
4333 } 4243 }
4334 '''; 4244 ''';
4335 UnlinkedExecutable executable = 4245 UnlinkedExecutable executable =
4336 serializeClassText(text, className: 'C').executables[0]; 4246 serializeClassText(text, className: 'C').executables[0];
4337 expect(executable.isRedirectedConstructor, isTrue); 4247 expect(executable.isRedirectedConstructor, isTrue);
4338 expect(executable.isFactory, isTrue); 4248 expect(executable.isFactory, isTrue);
4339 expect(executable.redirectedConstructorName, isEmpty); 4249 expect(executable.redirectedConstructorName, isEmpty);
4340 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D', 4250 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D',
4341 numTypeParameters: 2, numTypeArguments: 2); 4251 numTypeParameters: 2, numTypeArguments: 2);
4342 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); 4252 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
4343 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); 4253 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
4344 } 4254 }
4345 4255
4346 test_constructor_redirected_factory_unnamed_prefixed() { 4256 test_constructor_redirected_factory_unnamed_prefixed() {
4347 addNamedSource( 4257 addNamedSource('/foo.dart', '''
4348 '/foo.dart',
4349 '''
4350 import 'test.dart'; 4258 import 'test.dart';
4351 class D extends C { 4259 class D extends C {
4352 D() : super._(); 4260 D() : super._();
4353 } 4261 }
4354 '''); 4262 ''');
4355 String text = ''' 4263 String text = '''
4356 import 'foo.dart' as foo; 4264 import 'foo.dart' as foo;
4357 class C { 4265 class C {
4358 factory C() = foo.D; 4266 factory C() = foo.D;
4359 C._(); 4267 C._();
4360 } 4268 }
4361 '''; 4269 ''';
4362 UnlinkedExecutable executable = 4270 UnlinkedExecutable executable =
4363 serializeClassText(text, className: 'C').executables[0]; 4271 serializeClassText(text, className: 'C').executables[0];
4364 expect(executable.isRedirectedConstructor, isTrue); 4272 expect(executable.isRedirectedConstructor, isTrue);
4365 expect(executable.isFactory, isTrue); 4273 expect(executable.isFactory, isTrue);
4366 expect(executable.redirectedConstructorName, isEmpty); 4274 expect(executable.redirectedConstructorName, isEmpty);
4367 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D', 4275 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D',
4368 expectedPrefix: 'foo'); 4276 expectedPrefix: 'foo');
4369 } 4277 }
4370 4278
4371 test_constructor_redirected_factory_unnamed_prefixed_generic() { 4279 test_constructor_redirected_factory_unnamed_prefixed_generic() {
4372 addNamedSource( 4280 addNamedSource('/foo.dart', '''
4373 '/foo.dart',
4374 '''
4375 import 'test.dart'; 4281 import 'test.dart';
4376 class D<T, U> extends C<U, T> { 4282 class D<T, U> extends C<U, T> {
4377 D() : super._(); 4283 D() : super._();
4378 } 4284 }
4379 '''); 4285 ''');
4380 String text = ''' 4286 String text = '''
4381 import 'foo.dart' as foo; 4287 import 'foo.dart' as foo;
4382 class C<T, U> { 4288 class C<T, U> {
4383 factory C() = foo.D<U, T>; 4289 factory C() = foo.D<U, T>;
4384 C._(); 4290 C._();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4466 class D { 4372 class D {
4467 final x; 4373 final x;
4468 D() : x = new C(); 4374 D() : x = new C();
4469 } 4375 }
4470 '''); 4376 ''');
4471 expect(findClass('C').executables[0].constCycleSlot, 0); 4377 expect(findClass('C').executables[0].constCycleSlot, 0);
4472 expect(findClass('D').executables[0].constCycleSlot, 0); 4378 expect(findClass('D').executables[0].constCycleSlot, 0);
4473 } 4379 }
4474 4380
4475 test_constructorCycle_redirectToImplicitConstructor() { 4381 test_constructorCycle_redirectToImplicitConstructor() {
4476 serializeLibraryText( 4382 serializeLibraryText('''
4477 '''
4478 class C { 4383 class C {
4479 const factory C() = D; 4384 const factory C() = D;
4480 } 4385 }
4481 class D extends C {} 4386 class D extends C {}
4482 ''', 4387 ''', allowErrors: true);
4483 allowErrors: true);
4484 checkConstCycle('C', hasCycle: false); 4388 checkConstCycle('C', hasCycle: false);
4485 } 4389 }
4486 4390
4487 test_constructorCycle_redirectToNonConstConstructor() { 4391 test_constructorCycle_redirectToNonConstConstructor() {
4488 // It's not valid Dart but we need to make sure it doesn't crash 4392 // It's not valid Dart but we need to make sure it doesn't crash
4489 // summary generation. 4393 // summary generation.
4490 serializeLibraryText( 4394 serializeLibraryText('''
4491 '''
4492 class C { 4395 class C {
4493 const factory C() = D; 4396 const factory C() = D;
4494 } 4397 }
4495 class D extends C { 4398 class D extends C {
4496 D(); 4399 D();
4497 } 4400 }
4498 ''', 4401 ''', allowErrors: true);
4499 allowErrors: true);
4500 checkConstCycle('C', hasCycle: false); 4402 checkConstCycle('C', hasCycle: false);
4501 } 4403 }
4502 4404
4503 test_constructorCycle_redirectToSymbolConstructor() { 4405 test_constructorCycle_redirectToSymbolConstructor() {
4504 // The symbol constructor has some special case behaviors in analyzer. 4406 // The symbol constructor has some special case behaviors in analyzer.
4505 // Make sure those special case behaviors don't cause problems. 4407 // Make sure those special case behaviors don't cause problems.
4506 serializeLibraryText( 4408 serializeLibraryText('''
4507 '''
4508 class C { 4409 class C {
4509 const factory C(String name) = Symbol; 4410 const factory C(String name) = Symbol;
4510 } 4411 }
4511 ''', 4412 ''', allowErrors: true);
4512 allowErrors: true);
4513 checkConstCycle('C', hasCycle: false); 4413 checkConstCycle('C', hasCycle: false);
4514 } 4414 }
4515 4415
4516 test_constructorCycle_referenceToClass() { 4416 test_constructorCycle_referenceToClass() {
4517 serializeLibraryText(''' 4417 serializeLibraryText('''
4518 class C { 4418 class C {
4519 final x; 4419 final x;
4520 const C() : x = C; 4420 const C() : x = C;
4521 } 4421 }
4522 '''); 4422 ''');
(...skipping 29 matching lines...) Expand all
4552 final x; 4452 final x;
4553 const C() : x = E.values; 4453 const C() : x = E.values;
4554 } 4454 }
4555 '''); 4455 ''');
4556 checkConstCycle('C', hasCycle: false); 4456 checkConstCycle('C', hasCycle: false);
4557 } 4457 }
4558 4458
4559 test_constructorCycle_referenceToGenericParameter() { 4459 test_constructorCycle_referenceToGenericParameter() {
4560 // It's not valid Dart but we need to make sure it doesn't crash 4460 // It's not valid Dart but we need to make sure it doesn't crash
4561 // summary generation. 4461 // summary generation.
4562 serializeLibraryText( 4462 serializeLibraryText('''
4563 '''
4564 class C<T> { 4463 class C<T> {
4565 final x; 4464 final x;
4566 const C() : x = T; 4465 const C() : x = T;
4567 } 4466 }
4568 ''', 4467 ''', allowErrors: true);
4569 allowErrors: true);
4570 checkConstCycle('C', hasCycle: false); 4468 checkConstCycle('C', hasCycle: false);
4571 } 4469 }
4572 4470
4573 test_constructorCycle_referenceToGenericParameter_asSupertype() { 4471 test_constructorCycle_referenceToGenericParameter_asSupertype() {
4574 // It's not valid Dart but we need to make sure it doesn't crash 4472 // It's not valid Dart but we need to make sure it doesn't crash
4575 // summary generation. 4473 // summary generation.
4576 serializeLibraryText( 4474 serializeLibraryText('''
4577 '''
4578 class C<T> extends T { 4475 class C<T> extends T {
4579 const C(); 4476 const C();
4580 } 4477 }
4581 ''', 4478 ''', allowErrors: true);
4582 allowErrors: true);
4583 checkConstCycle('C', hasCycle: false); 4479 checkConstCycle('C', hasCycle: false);
4584 } 4480 }
4585 4481
4586 test_constructorCycle_referenceToStaticMethod_inOtherClass() { 4482 test_constructorCycle_referenceToStaticMethod_inOtherClass() {
4587 serializeLibraryText(''' 4483 serializeLibraryText('''
4588 class C { 4484 class C {
4589 final x; 4485 final x;
4590 const C() : x = D.f; 4486 const C() : x = D.f;
4591 } 4487 }
4592 class D { 4488 class D {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 final x; 4521 final x;
4626 const C() : x = F; 4522 const C() : x = F;
4627 } 4523 }
4628 '''); 4524 ''');
4629 checkConstCycle('C', hasCycle: false); 4525 checkConstCycle('C', hasCycle: false);
4630 } 4526 }
4631 4527
4632 test_constructorCycle_referenceToUndefinedName() { 4528 test_constructorCycle_referenceToUndefinedName() {
4633 // It's not valid Dart but we need to make sure it doesn't crash 4529 // It's not valid Dart but we need to make sure it doesn't crash
4634 // summary generation. 4530 // summary generation.
4635 serializeLibraryText( 4531 serializeLibraryText('''
4636 '''
4637 class C { 4532 class C {
4638 final x; 4533 final x;
4639 const C() : x = foo; 4534 const C() : x = foo;
4640 } 4535 }
4641 ''', 4536 ''', allowErrors: true);
4642 allowErrors: true);
4643 checkConstCycle('C', hasCycle: false); 4537 checkConstCycle('C', hasCycle: false);
4644 } 4538 }
4645 4539
4646 test_constructorCycle_referenceToUndefinedName_viaPrefix() { 4540 test_constructorCycle_referenceToUndefinedName_viaPrefix() {
4647 // It's not valid Dart but we need to make sure it doesn't crash 4541 // It's not valid Dart but we need to make sure it doesn't crash
4648 // summary generation. 4542 // summary generation.
4649 addNamedSource('/a.dart', ''); 4543 addNamedSource('/a.dart', '');
4650 serializeLibraryText( 4544 serializeLibraryText('''
4651 '''
4652 import 'a.dart' as a; 4545 import 'a.dart' as a;
4653 class C { 4546 class C {
4654 final x; 4547 final x;
4655 const C() : x = a.foo; 4548 const C() : x = a.foo;
4656 } 4549 }
4657 ''', 4550 ''', allowErrors: true);
4658 allowErrors: true);
4659 checkConstCycle('C', hasCycle: false); 4551 checkConstCycle('C', hasCycle: false);
4660 } 4552 }
4661 4553
4662 test_constructorCycle_referenceToUndefinedName_viaPrefix_nonExistentFile() { 4554 test_constructorCycle_referenceToUndefinedName_viaPrefix_nonExistentFile() {
4663 // It's not valid Dart but we need to make sure it doesn't crash 4555 // It's not valid Dart but we need to make sure it doesn't crash
4664 // summary generation. 4556 // summary generation.
4665 allowMissingFiles = true; 4557 allowMissingFiles = true;
4666 serializeLibraryText( 4558 serializeLibraryText('''
4667 '''
4668 import 'a.dart' as a; 4559 import 'a.dart' as a;
4669 class C { 4560 class C {
4670 final x; 4561 final x;
4671 const C() : x = a.foo; 4562 const C() : x = a.foo;
4672 } 4563 }
4673 ''', 4564 ''', allowErrors: true);
4674 allowErrors: true);
4675 checkConstCycle('C', hasCycle: false); 4565 checkConstCycle('C', hasCycle: false);
4676 } 4566 }
4677 4567
4678 test_constructorCycle_trivial() { 4568 test_constructorCycle_trivial() {
4679 serializeLibraryText( 4569 serializeLibraryText('''
4680 '''
4681 class C { 4570 class C {
4682 const C() : this(); 4571 const C() : this();
4683 } 4572 }
4684 ''', 4573 ''', allowErrors: true);
4685 allowErrors: true);
4686 checkConstCycle('C'); 4574 checkConstCycle('C');
4687 } 4575 }
4688 4576
4689 test_constructorCycle_viaFactoryRedirect() { 4577 test_constructorCycle_viaFactoryRedirect() {
4690 serializeLibraryText( 4578 serializeLibraryText('''
4691 '''
4692 class C { 4579 class C {
4693 const C(); 4580 const C();
4694 const factory C.named() = D; 4581 const factory C.named() = D;
4695 } 4582 }
4696 class D extends C { 4583 class D extends C {
4697 final x; 4584 final x;
4698 const D() : x = y; 4585 const D() : x = y;
4699 } 4586 }
4700 const y = const C.named(); 4587 const y = const C.named();
4701 ''', 4588 ''', allowErrors: true);
4702 allowErrors: true);
4703 checkConstCycle('C', hasCycle: false); 4589 checkConstCycle('C', hasCycle: false);
4704 checkConstCycle('C', name: 'named'); 4590 checkConstCycle('C', name: 'named');
4705 checkConstCycle('D'); 4591 checkConstCycle('D');
4706 } 4592 }
4707 4593
4708 test_constructorCycle_viaFinalField() { 4594 test_constructorCycle_viaFinalField() {
4709 serializeLibraryText( 4595 serializeLibraryText('''
4710 '''
4711 class C { 4596 class C {
4712 final x = const C(); 4597 final x = const C();
4713 const C(); 4598 const C();
4714 } 4599 }
4715 ''', 4600 ''', allowErrors: true);
4716 allowErrors: true);
4717 checkConstCycle('C'); 4601 checkConstCycle('C');
4718 } 4602 }
4719 4603
4720 test_constructorCycle_viaLength() { 4604 test_constructorCycle_viaLength() {
4721 // It's not valid Dart but we need to make sure it doesn't crash 4605 // It's not valid Dart but we need to make sure it doesn't crash
4722 // summary generation. 4606 // summary generation.
4723 serializeLibraryText( 4607 serializeLibraryText('''
4724 '''
4725 class C { 4608 class C {
4726 final x; 4609 final x;
4727 const C() : x = y.length; 4610 const C() : x = y.length;
4728 } 4611 }
4729 const y = const C(); 4612 const y = const C();
4730 ''', 4613 ''', allowErrors: true);
4731 allowErrors: true);
4732 checkConstCycle('C'); 4614 checkConstCycle('C');
4733 } 4615 }
4734 4616
4735 test_constructorCycle_viaNamedConstructor() { 4617 test_constructorCycle_viaNamedConstructor() {
4736 serializeLibraryText(''' 4618 serializeLibraryText('''
4737 class C { 4619 class C {
4738 final x; 4620 final x;
4739 const C() : x = const D.named(); 4621 const C() : x = const D.named();
4740 } 4622 }
4741 class D { 4623 class D {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4773 const C.named() : super.named(); 4655 const C.named() : super.named();
4774 } 4656 }
4775 '''); 4657 ''');
4776 checkConstCycle('B', hasCycle: false); 4658 checkConstCycle('B', hasCycle: false);
4777 checkConstCycle('B', name: 'named', hasCycle: false); 4659 checkConstCycle('B', name: 'named', hasCycle: false);
4778 checkConstCycle('C', hasCycle: false); 4660 checkConstCycle('C', hasCycle: false);
4779 checkConstCycle('C', name: 'named', hasCycle: false); 4661 checkConstCycle('C', name: 'named', hasCycle: false);
4780 } 4662 }
4781 4663
4782 test_constructorCycle_viaRedirectArgument() { 4664 test_constructorCycle_viaRedirectArgument() {
4783 serializeLibraryText( 4665 serializeLibraryText('''
4784 '''
4785 class C { 4666 class C {
4786 final x; 4667 final x;
4787 const C() : this.named(y); 4668 const C() : this.named(y);
4788 const C.named(this.x); 4669 const C.named(this.x);
4789 } 4670 }
4790 const y = const C(); 4671 const y = const C();
4791 ''', 4672 ''', allowErrors: true);
4792 allowErrors: true);
4793 checkConstCycle('C'); 4673 checkConstCycle('C');
4794 checkConstCycle('C', name: 'named', hasCycle: false); 4674 checkConstCycle('C', name: 'named', hasCycle: false);
4795 } 4675 }
4796 4676
4797 test_constructorCycle_viaStaticField_inOtherClass() { 4677 test_constructorCycle_viaStaticField_inOtherClass() {
4798 serializeLibraryText( 4678 serializeLibraryText('''
4799 '''
4800 class C { 4679 class C {
4801 final x; 4680 final x;
4802 const C() : x = D.y; 4681 const C() : x = D.y;
4803 } 4682 }
4804 class D { 4683 class D {
4805 static const y = const C(); 4684 static const y = const C();
4806 } 4685 }
4807 ''', 4686 ''', allowErrors: true);
4808 allowErrors: true);
4809 checkConstCycle('C'); 4687 checkConstCycle('C');
4810 } 4688 }
4811 4689
4812 test_constructorCycle_viaStaticField_inSameClass() { 4690 test_constructorCycle_viaStaticField_inSameClass() {
4813 serializeLibraryText( 4691 serializeLibraryText('''
4814 '''
4815 class C { 4692 class C {
4816 final x; 4693 final x;
4817 static const y = const C(); 4694 static const y = const C();
4818 const C() : x = y; 4695 const C() : x = y;
4819 } 4696 }
4820 ''', 4697 ''', allowErrors: true);
4821 allowErrors: true);
4822 checkConstCycle('C'); 4698 checkConstCycle('C');
4823 } 4699 }
4824 4700
4825 test_constructorCycle_viaSuperArgument() { 4701 test_constructorCycle_viaSuperArgument() {
4826 serializeLibraryText( 4702 serializeLibraryText('''
4827 '''
4828 class B { 4703 class B {
4829 final x; 4704 final x;
4830 const B(this.x); 4705 const B(this.x);
4831 } 4706 }
4832 class C extends B { 4707 class C extends B {
4833 const C() : super(y); 4708 const C() : super(y);
4834 } 4709 }
4835 const y = const C(); 4710 const y = const C();
4836 ''', 4711 ''', allowErrors: true);
4837 allowErrors: true);
4838 checkConstCycle('B', hasCycle: false); 4712 checkConstCycle('B', hasCycle: false);
4839 checkConstCycle('C'); 4713 checkConstCycle('C');
4840 } 4714 }
4841 4715
4842 test_constructorCycle_viaSupertype() { 4716 test_constructorCycle_viaSupertype() {
4843 serializeLibraryText(''' 4717 serializeLibraryText('''
4844 class C { 4718 class C {
4845 final x; 4719 final x;
4846 const C() : x = const D(); 4720 const C() : x = const D();
4847 } 4721 }
4848 class D extends C { 4722 class D extends C {
4849 const D(); 4723 const D();
4850 } 4724 }
4851 '''); 4725 ''');
4852 checkConstCycle('C'); 4726 checkConstCycle('C');
4853 checkConstCycle('D'); 4727 checkConstCycle('D');
4854 } 4728 }
4855 4729
4856 test_constructorCycle_viaSupertype_Enum() { 4730 test_constructorCycle_viaSupertype_Enum() {
4857 // It's not valid Dart but we need to make sure it doesn't crash 4731 // It's not valid Dart but we need to make sure it doesn't crash
4858 // summary generation. 4732 // summary generation.
4859 serializeLibraryText( 4733 serializeLibraryText('''
4860 '''
4861 enum E { v } 4734 enum E { v }
4862 class C extends E { 4735 class C extends E {
4863 const C(); 4736 const C();
4864 } 4737 }
4865 ''', 4738 ''', allowErrors: true);
4866 allowErrors: true);
4867 checkConstCycle('C', hasCycle: false); 4739 checkConstCycle('C', hasCycle: false);
4868 } 4740 }
4869 4741
4870 test_constructorCycle_viaSupertype_explicit() { 4742 test_constructorCycle_viaSupertype_explicit() {
4871 serializeLibraryText(''' 4743 serializeLibraryText('''
4872 class C { 4744 class C {
4873 final x; 4745 final x;
4874 const C() : x = const D(); 4746 const C() : x = const D();
4875 const C.named() : x = const D.named(); 4747 const C.named() : x = const D.named();
4876 } 4748 }
4877 class D extends C { 4749 class D extends C {
4878 const D() : super(); 4750 const D() : super();
4879 const D.named() : super.named(); 4751 const D.named() : super.named();
4880 } 4752 }
4881 '''); 4753 ''');
4882 checkConstCycle('C'); 4754 checkConstCycle('C');
4883 checkConstCycle('C', name: 'named'); 4755 checkConstCycle('C', name: 'named');
4884 checkConstCycle('D'); 4756 checkConstCycle('D');
4885 checkConstCycle('D', name: 'named'); 4757 checkConstCycle('D', name: 'named');
4886 } 4758 }
4887 4759
4888 test_constructorCycle_viaSupertype_explicit_undefined() { 4760 test_constructorCycle_viaSupertype_explicit_undefined() {
4889 // It's not valid Dart but we need to make sure it doesn't crash 4761 // It's not valid Dart but we need to make sure it doesn't crash
4890 // summary generation. 4762 // summary generation.
4891 serializeLibraryText( 4763 serializeLibraryText('''
4892 '''
4893 class C { 4764 class C {
4894 final x; 4765 final x;
4895 const C() : x = const D(); 4766 const C() : x = const D();
4896 } 4767 }
4897 class D extends C { 4768 class D extends C {
4898 const D() : super.named(); 4769 const D() : super.named();
4899 } 4770 }
4900 ''', 4771 ''', allowErrors: true);
4901 allowErrors: true);
4902 checkConstCycle('C', hasCycle: false); 4772 checkConstCycle('C', hasCycle: false);
4903 checkConstCycle('D', hasCycle: false); 4773 checkConstCycle('D', hasCycle: false);
4904 } 4774 }
4905 4775
4906 test_constructorCycle_viaSupertype_withDefaultTypeArgument() { 4776 test_constructorCycle_viaSupertype_withDefaultTypeArgument() {
4907 serializeLibraryText(''' 4777 serializeLibraryText('''
4908 class C<T> { 4778 class C<T> {
4909 final x; 4779 final x;
4910 const C() : x = const D(); 4780 const C() : x = const D();
4911 } 4781 }
(...skipping 13 matching lines...) Expand all
4925 } 4795 }
4926 class D extends C<int> { 4796 class D extends C<int> {
4927 const D(); 4797 const D();
4928 } 4798 }
4929 '''); 4799 ''');
4930 checkConstCycle('C'); 4800 checkConstCycle('C');
4931 checkConstCycle('D'); 4801 checkConstCycle('D');
4932 } 4802 }
4933 4803
4934 test_constructorCycle_viaTopLevelVariable() { 4804 test_constructorCycle_viaTopLevelVariable() {
4935 serializeLibraryText( 4805 serializeLibraryText('''
4936 '''
4937 class C { 4806 class C {
4938 final x; 4807 final x;
4939 const C() : x = y; 4808 const C() : x = y;
4940 } 4809 }
4941 const y = const C(); 4810 const y = const C();
4942 ''', 4811 ''', allowErrors: true);
4943 allowErrors: true);
4944 checkConstCycle('C'); 4812 checkConstCycle('C');
4945 } 4813 }
4946 4814
4947 test_constructorCycle_viaTopLevelVariable_imported() { 4815 test_constructorCycle_viaTopLevelVariable_imported() {
4948 addNamedSource( 4816 addNamedSource('/a.dart', '''
4949 '/a.dart',
4950 '''
4951 import 'test.dart'; 4817 import 'test.dart';
4952 const y = const C(); 4818 const y = const C();
4953 '''); 4819 ''');
4954 serializeLibraryText( 4820 serializeLibraryText('''
4955 '''
4956 import 'a.dart'; 4821 import 'a.dart';
4957 class C { 4822 class C {
4958 final x; 4823 final x;
4959 const C() : x = y; 4824 const C() : x = y;
4960 } 4825 }
4961 ''', 4826 ''', allowErrors: true);
4962 allowErrors: true);
4963 checkConstCycle('C'); 4827 checkConstCycle('C');
4964 } 4828 }
4965 4829
4966 test_constructorCycle_viaTopLevelVariable_importedViaPrefix() { 4830 test_constructorCycle_viaTopLevelVariable_importedViaPrefix() {
4967 addNamedSource( 4831 addNamedSource('/a.dart', '''
4968 '/a.dart',
4969 '''
4970 import 'test.dart'; 4832 import 'test.dart';
4971 const y = const C(); 4833 const y = const C();
4972 '''); 4834 ''');
4973 serializeLibraryText( 4835 serializeLibraryText('''
4974 '''
4975 import 'a.dart' as a; 4836 import 'a.dart' as a;
4976 class C { 4837 class C {
4977 final x; 4838 final x;
4978 const C() : x = a.y; 4839 const C() : x = a.y;
4979 } 4840 }
4980 ''', 4841 ''', allowErrors: true);
4981 allowErrors: true);
4982 checkConstCycle('C'); 4842 checkConstCycle('C');
4983 } 4843 }
4984 4844
4985 test_dependencies_export_to_export_unused() { 4845 test_dependencies_export_to_export_unused() {
4986 addNamedSource('/a.dart', 'export "b.dart";'); 4846 addNamedSource('/a.dart', 'export "b.dart";');
4987 addNamedSource('/b.dart', ''); 4847 addNamedSource('/b.dart', '');
4988 serializeLibraryText('export "a.dart";'); 4848 serializeLibraryText('export "a.dart";');
4989 // The main test library depends on b.dart, even though it doesn't 4849 // The main test library depends on b.dart, even though it doesn't
4990 // re-export any names defined in b.dart, because a change to b.dart might 4850 // re-export any names defined in b.dart, because a change to b.dart might
4991 // cause it to start exporting a name that the main test library *does* 4851 // cause it to start exporting a name that the main test library *does*
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 'library d; part "e/f.dart"; part "g/h.dart"; class D {}'); 4972 'library d; part "e/f.dart"; part "g/h.dart"; class D {}');
5113 addNamedSource('/a/c/e/f.dart', 'part of d;'); 4973 addNamedSource('/a/c/e/f.dart', 'part of d;');
5114 addNamedSource('/a/c/g/h.dart', 'part of d;'); 4974 addNamedSource('/a/c/g/h.dart', 'part of d;');
5115 serializeLibraryText('import "a/b.dart"; D d;'); 4975 serializeLibraryText('import "a/b.dart"; D d;');
5116 int dep = checkHasDependency(absUri('/a/c/d.dart')); 4976 int dep = checkHasDependency(absUri('/a/c/d.dart'));
5117 checkDependencyParts(linked.dependencies[dep], 4977 checkDependencyParts(linked.dependencies[dep],
5118 [absUri('/a/c/e/f.dart'), absUri('/a/c/g/h.dart')]); 4978 [absUri('/a/c/e/f.dart'), absUri('/a/c/g/h.dart')]);
5119 } 4979 }
5120 4980
5121 test_elements_in_part() { 4981 test_elements_in_part() {
5122 addNamedSource( 4982 addNamedSource('/part1.dart', '''
5123 '/part1.dart',
5124 '''
5125 part of my.lib; 4983 part of my.lib;
5126 4984
5127 class C {} 4985 class C {}
5128 enum E { v } 4986 enum E { v }
5129 var v; 4987 var v;
5130 f() {} 4988 f() {}
5131 typedef F(); 4989 typedef F();
5132 '''); 4990 ''');
5133 serializeLibraryText('library my.lib; part "part1.dart";'); 4991 serializeLibraryText('library my.lib; part "part1.dart";');
5134 UnlinkedUnit unit = unlinkedUnits[1]; 4992 UnlinkedUnit unit = unlinkedUnits[1];
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 referenceValidators: [ 6425 referenceValidators: [
6568 (EntityRef r) => checkTypeRef(r, null, 'a', 6426 (EntityRef r) => checkTypeRef(r, null, 'a',
6569 expectedKind: ReferenceKind.topLevelPropertyAccessor) 6427 expectedKind: ReferenceKind.topLevelPropertyAccessor)
6570 ]); 6428 ]);
6571 } 6429 }
6572 6430
6573 test_expr_assignToRef_topLevelVariable_imported() { 6431 test_expr_assignToRef_topLevelVariable_imported() {
6574 if (skipNonConstInitializers) { 6432 if (skipNonConstInitializers) {
6575 return; 6433 return;
6576 } 6434 }
6577 addNamedSource( 6435 addNamedSource('/a.dart', '''
6578 '/a.dart',
6579 '''
6580 int a = 0; 6436 int a = 0;
6581 '''); 6437 ''');
6582 UnlinkedVariable variable = serializeVariableText(''' 6438 UnlinkedVariable variable = serializeVariableText('''
6583 import 'a.dart'; 6439 import 'a.dart';
6584 final v = (a = 1); 6440 final v = (a = 1);
6585 '''); 6441 ''');
6586 assertUnlinkedConst(variable.initializer.bodyExpr, 6442 assertUnlinkedConst(variable.initializer.bodyExpr,
6587 isValidConst: false, 6443 isValidConst: false,
6588 operators: [ 6444 operators: [
6589 UnlinkedExprOperation.pushInt, 6445 UnlinkedExprOperation.pushInt,
6590 UnlinkedExprOperation.assignToRef, 6446 UnlinkedExprOperation.assignToRef,
6591 ], 6447 ],
6592 assignmentOperators: [ 6448 assignmentOperators: [
6593 (UnlinkedExprAssignOperator.assign) 6449 (UnlinkedExprAssignOperator.assign)
6594 ], 6450 ],
6595 ints: [ 6451 ints: [
6596 1, 6452 1,
6597 ], 6453 ],
6598 strings: [], 6454 strings: [],
6599 referenceValidators: [ 6455 referenceValidators: [
6600 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a', 6456 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a',
6601 expectedKind: ReferenceKind.topLevelPropertyAccessor) 6457 expectedKind: ReferenceKind.topLevelPropertyAccessor)
6602 ]); 6458 ]);
6603 } 6459 }
6604 6460
6605 test_expr_assignToRef_topLevelVariable_imported_withPrefix() { 6461 test_expr_assignToRef_topLevelVariable_imported_withPrefix() {
6606 if (skipNonConstInitializers) { 6462 if (skipNonConstInitializers) {
6607 return; 6463 return;
6608 } 6464 }
6609 addNamedSource( 6465 addNamedSource('/a.dart', '''
6610 '/a.dart',
6611 '''
6612 int a = 0; 6466 int a = 0;
6613 '''); 6467 ''');
6614 UnlinkedVariable variable = serializeVariableText(''' 6468 UnlinkedVariable variable = serializeVariableText('''
6615 import 'a.dart' as p; 6469 import 'a.dart' as p;
6616 final v = (p.a = 1); 6470 final v = (p.a = 1);
6617 '''); 6471 ''');
6618 assertUnlinkedConst(variable.initializer.bodyExpr, 6472 assertUnlinkedConst(variable.initializer.bodyExpr,
6619 isValidConst: false, 6473 isValidConst: false,
6620 operators: [ 6474 operators: [
6621 UnlinkedExprOperation.pushInt, 6475 UnlinkedExprOperation.pushInt,
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
7207 new _PrefixExpectation( 7061 new _PrefixExpectation(
7208 ReferenceKind.topLevelPropertyAccessor, 'a') 7062 ReferenceKind.topLevelPropertyAccessor, 'a')
7209 ]) 7063 ])
7210 ]); 7064 ]);
7211 } 7065 }
7212 7066
7213 test_expr_invokeMethodRef_static_importedWithPrefix() { 7067 test_expr_invokeMethodRef_static_importedWithPrefix() {
7214 if (skipNonConstInitializers) { 7068 if (skipNonConstInitializers) {
7215 return; 7069 return;
7216 } 7070 }
7217 addNamedSource( 7071 addNamedSource('/a.dart', '''
7218 '/a.dart',
7219 '''
7220 class C { 7072 class C {
7221 static int m() => 42; 7073 static int m() => 42;
7222 } 7074 }
7223 '''); 7075 ''');
7224 UnlinkedVariable variable = serializeVariableText(''' 7076 UnlinkedVariable variable = serializeVariableText('''
7225 import 'a.dart' as p; 7077 import 'a.dart' as p;
7226 final v = p.C.m(); 7078 final v = p.C.m();
7227 '''); 7079 ''');
7228 assertUnlinkedConst(variable.initializer.bodyExpr, 7080 assertUnlinkedConst(variable.initializer.bodyExpr,
7229 isValidConst: false, 7081 isValidConst: false,
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
8388 } 8240 }
8389 8241
8390 test_initializer_executable_with_return_type_from_closure_field() { 8242 test_initializer_executable_with_return_type_from_closure_field() {
8391 if (skipFullyLinkedData) { 8243 if (skipFullyLinkedData) {
8392 return; 8244 return;
8393 } 8245 }
8394 // The synthetic executable for `v` has type `() => () => int`, where the 8246 // The synthetic executable for `v` has type `() => () => int`, where the
8395 // `() => int` part refers to the closure declared inside the initializer 8247 // `() => int` part refers to the closure declared inside the initializer
8396 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, 8248 // for v. Note: `v` is mis-typed as `int` to prevent type propagation,
8397 // which would complicate the test. 8249 // which would complicate the test.
8398 UnlinkedClass cls = serializeClassText( 8250 UnlinkedClass cls = serializeClassText('''
8399 '''
8400 class C { 8251 class C {
8401 int v = () => 0; 8252 int v = () => 0;
8402 } 8253 }
8403 ''', 8254 ''', allowErrors: true);
8404 allowErrors: true);
8405 UnlinkedVariable variable = cls.fields[0]; 8255 UnlinkedVariable variable = cls.fields[0];
8406 EntityRef closureType = 8256 EntityRef closureType =
8407 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); 8257 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot);
8408 checkLinkedTypeRef(closureType, null, '', 8258 checkLinkedTypeRef(closureType, null, '',
8409 expectedKind: ReferenceKind.function); 8259 expectedKind: ReferenceKind.function);
8410 int initializerIndex = 8260 int initializerIndex =
8411 definingUnit.references[closureType.reference].containingReference; 8261 definingUnit.references[closureType.reference].containingReference;
8412 checkReferenceIndex(initializerIndex, null, '', 8262 checkReferenceIndex(initializerIndex, null, '',
8413 expectedKind: ReferenceKind.function); 8263 expectedKind: ReferenceKind.function);
8414 int variableIndex = 8264 int variableIndex =
(...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after
10299 */ 10149 */
10300 class _PrefixExpectation { 10150 class _PrefixExpectation {
10301 final ReferenceKind kind; 10151 final ReferenceKind kind;
10302 final String name; 10152 final String name;
10303 final String absoluteUri; 10153 final String absoluteUri;
10304 final int numTypeParameters; 10154 final int numTypeParameters;
10305 10155
10306 _PrefixExpectation(this.kind, this.name, 10156 _PrefixExpectation(this.kind, this.name,
10307 {this.absoluteUri, this.numTypeParameters: 0}); 10157 {this.absoluteUri, this.numTypeParameters: 0});
10308 } 10158 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_common.dart ('k') | pkg/analyzer/test/src/summary/top_level_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698