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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1640813002: Support for static method references in constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 24beee1ed26e8fac69652b6b74eeae3ab34da6d0..66f31eccc32aa9a32d76243990c2072ce029eda4 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -43,6 +43,8 @@ ReferenceKind _getReferenceKind(Element element) {
return ReferenceKind.constField;
}
return ReferenceKind.topLevelPropertyAccessor;
+ } else if (element is MethodElement) {
+ return ReferenceKind.staticMethod;
} else {
throw new Exception('Unexpected element kind: ${element.runtimeType}');
}
@@ -799,6 +801,9 @@ class _CompilationUnitSerializer {
if (element is ConstructorElement && element.displayName.isEmpty) {
return _getElementReferenceId(element.enclosingElement, linked: linked);
}
+ if (element is MethodElement && !element.isStatic) {
+ throw new StateError('Only static methods can be serialized.');
+ }
if (element is PropertyAccessorElement) {
Element enclosing = element.enclosingElement;
if (!(enclosing is CompilationUnitElement || element.isStatic)) {
@@ -909,7 +914,8 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
assert(element != null);
// The only supported instance property accessor - `length`.
Expression target = access.target;
- if (target is Identifier && element is PropertyAccessorElement &&
+ if (target is Identifier &&
+ element is PropertyAccessorElement &&
!element.isStatic) {
assert(element.name == 'length');
Element prefixElement = target.staticElement;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698