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

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

Issue 1658723005: Resynthesize static method references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } else { 229 } else {
230 fail('$desc Incompatible item types: ' 230 fail('$desc Incompatible item types: '
231 '${rItem.runtimeType} vs. ${oItem.runtimeType}'); 231 '${rItem.runtimeType} vs. ${oItem.runtimeType}');
232 } 232 }
233 } 233 }
234 } 234 }
235 if (o == null) { 235 if (o == null) {
236 expect(r, isNull, reason: desc); 236 expect(r, isNull, reason: desc);
237 } else { 237 } else {
238 expect(r, isNotNull, reason: desc); 238 expect(r, isNotNull, reason: desc);
239 compareTypes(r.staticType, o.staticType, desc);
Paul Berry 2016/02/01 20:48:47 Why is it ok to delete this check?
scheglov 2016/02/01 20:52:45 By the same reason why we did this for SimpleIdent
240 if (o is ParenthesizedExpression) { 239 if (o is ParenthesizedExpression) {
241 // We don't resynthesize parenthesis, so just ignore it. 240 // We don't resynthesize parenthesis, so just ignore it.
242 compareConstantExpressions(r, o.expression, desc); 241 compareConstantExpressions(r, o.expression, desc);
243 } else if (o is SimpleIdentifier && r is SimpleIdentifier) { 242 } else if (o is SimpleIdentifier && r is SimpleIdentifier) {
244 expect(r.name, o.name); 243 expect(r.name, o.name);
245 compareElements(r.staticElement, o.staticElement, desc); 244 compareElements(r.staticElement, o.staticElement, desc);
246 // ConstantAstCloner does not copy static types, and constant values 245 // ConstantAstCloner does not copy static types, and constant values
247 // computer does not use static types. So, we don't set them during 246 // computer does not use static types. So, we don't set them during
248 // resynthesis and should not check them. 247 // resynthesis and should not check them.
249 } else if (o is PrefixedIdentifier && r is SimpleIdentifier) { 248 } else if (o is PrefixedIdentifier && r is SimpleIdentifier) {
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 class C { 1046 class C {
1048 static const int F = 42; 1047 static const int F = 42;
1049 } 1048 }
1050 '''); 1049 ''');
1051 checkLibrary(r''' 1050 checkLibrary(r'''
1052 import 'a.dart' as p; 1051 import 'a.dart' as p;
1053 const V = p.C.F; 1052 const V = p.C.F;
1054 '''); 1053 ''');
1055 } 1054 }
1056 1055
1056 test_const_reference_staticMethod() {
1057 shouldCompareConstValues = true;
1058 checkLibrary(r'''
1059 class C {
1060 static int m(int a, String b) => 42;
1061 }
1062 const V = C.m;
1063 ''');
1064 }
1065
1066 test_const_reference_staticMethod_imported() {
1067 shouldCompareConstValues = true;
1068 addLibrarySource(
1069 '/a.dart',
1070 r'''
1071 class C {
1072 static int m(int a, String b) => 42;
1073 }
1074 ''');
1075 checkLibrary(r'''
1076 import 'a.dart';
1077 const V = C.m;
1078 ''');
1079 }
1080
1081 test_const_reference_staticMethod_imported_withPrefix() {
1082 shouldCompareConstValues = true;
1083 addLibrarySource(
1084 '/a.dart',
1085 r'''
1086 class C {
1087 static int m(int a, String b) => 42;
1088 }
1089 ''');
1090 checkLibrary(r'''
1091 import 'a.dart' as p;
1092 const V = p.C.m;
1093 ''');
1094 }
1095
1057 test_const_reference_topLevelVariable() { 1096 test_const_reference_topLevelVariable() {
1058 shouldCompareConstValues = true; 1097 shouldCompareConstValues = true;
1059 checkLibrary(r''' 1098 checkLibrary(r'''
1060 const A = 1; 1099 const A = 1;
1061 const B = A + 2; 1100 const B = A + 2;
1062 '''); 1101 ''');
1063 } 1102 }
1064 1103
1065 test_const_reference_topLevelVariable_imported() { 1104 test_const_reference_topLevelVariable_imported() {
1066 shouldCompareConstValues = true; 1105 shouldCompareConstValues = true;
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 fail('Unexpectedly tried to get unlinked summary for $uri'); 2250 fail('Unexpectedly tried to get unlinked summary for $uri');
2212 } 2251 }
2213 return serializedUnit; 2252 return serializedUnit;
2214 } 2253 }
2215 2254
2216 @override 2255 @override
2217 bool hasLibrarySummary(String uri) { 2256 bool hasLibrarySummary(String uri) {
2218 return true; 2257 return true;
2219 } 2258 }
2220 } 2259 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698