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

Unified 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: Move the 'no staticType check' comment. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index 9d90ee7061e184e12ab6e6957a9037ff74935ba6..07b7bc0a10c96e7c0911fa293a503e8251420fd4 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -236,16 +236,15 @@ class ResynthTest extends ResolverTestCase {
expect(r, isNull, reason: desc);
} else {
expect(r, isNotNull, reason: desc);
- compareTypes(r.staticType, o.staticType, desc);
+ // ConstantAstCloner does not copy static types, and constant values
+ // computer does not use static types. So, we don't set them during
+ // resynthesis and should not check them here.
if (o is ParenthesizedExpression) {
// We don't resynthesize parenthesis, so just ignore it.
compareConstantExpressions(r, o.expression, desc);
} else if (o is SimpleIdentifier && r is SimpleIdentifier) {
expect(r.name, o.name);
compareElements(r.staticElement, o.staticElement, desc);
- // ConstantAstCloner does not copy static types, and constant values
- // computer does not use static types. So, we don't set them during
- // resynthesis and should not check them.
} else if (o is PrefixedIdentifier && r is SimpleIdentifier) {
// We don't resynthesize prefixed identifiers.
// We use simple identifiers with correct elements.
@@ -1054,6 +1053,46 @@ const V = p.C.F;
''');
}
+ test_const_reference_staticMethod() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ static int m(int a, String b) => 42;
+}
+const V = C.m;
+''');
+ }
+
+ test_const_reference_staticMethod_imported() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ static int m(int a, String b) => 42;
+}
+''');
+ checkLibrary(r'''
+import 'a.dart';
+const V = C.m;
+''');
+ }
+
+ test_const_reference_staticMethod_imported_withPrefix() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ static int m(int a, String b) => 42;
+}
+''');
+ checkLibrary(r'''
+import 'a.dart' as p;
+const V = p.C.m;
+''');
+ }
+
test_const_reference_topLevelVariable() {
shouldCompareConstValues = true;
checkLibrary(r'''
« 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