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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10920089: Generate a warning and a runtime error for calls to nonexistent static calls, getters and setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 61fe59aa980548d3547f7374c519d610b0ead379..04ec67b18188a8c45c54836989043956fd1c4a4a 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -295,7 +295,8 @@ class Element implements Hashable {
bool get isPatched => false;
- static bool isInvalid(Element e) => e == null || e.isErroneous();
+ static bool isUnresolved(Element e) => e == null || e.isErroneous();
+ static bool isErroneousElement(Element e) => e != null && e.isErroneous();
ngeoffray 2012/09/07 08:12:46 Why aren't these methods on Element*s* class?
karlklose 2012/09/07 09:24:01 Done, moved. I thought it reads better, but it is
}
/**
@@ -317,8 +318,9 @@ class Element implements Hashable {
*/
class ErroneousElement extends Element {
final Message errorMessage;
+ final SourceString targetName;
- ErroneousElement(this.errorMessage, Element enclosing)
+ ErroneousElement(this.errorMessage, this.targetName, Element enclosing)
: super(const SourceString('erroneous element'), null, enclosing);
isErroneous() => true;
@@ -330,12 +332,15 @@ class ErroneousElement extends Element {
SourceString get name => unsupported();
ElementKind get kind => unsupported();
Link<MetadataAnnotation> get metadata => unsupported();
+
+ getLibrary() => enclosingElement.getLibrary();
}
class ErroneousFunctionElement extends ErroneousElement
implements FunctionElement {
- ErroneousFunctionElement(errorMessage, Element enclosing)
- : super(errorMessage, enclosing);
+ ErroneousFunctionElement(Message errorMessage, SourceString targetName,
+ Element enclosing)
+ : super(errorMessage, targetName, enclosing);
get type => unsupported();
get cachedNode => unsupported();
@@ -348,8 +353,6 @@ class ErroneousFunctionElement extends ErroneousElement
requiredParameterCount(compiler) => unsupported();
optionalParameterCount(compiler) => unsupported();
parameterCount(copmiler) => unsupported();
-
- getLibrary() => enclosingElement.getLibrary();
}
class ContainerElement extends Element {
@@ -1386,7 +1389,7 @@ class ClassElement extends ScopeContainerElement
class Elements {
static bool isLocal(Element element) {
- return !Element.isInvalid(element)
+ return !Element.isUnresolved(element)
&& !element.isInstanceMember()
&& !isStaticOrTopLevelField(element)
&& !isStaticOrTopLevelFunction(element)
@@ -1396,7 +1399,7 @@ class Elements {
}
static bool isInstanceField(Element element) {
- return !Element.isInvalid(element)
+ return !Element.isUnresolved(element)
&& element.isInstanceMember()
&& (element.kind === ElementKind.FIELD
|| element.kind === ElementKind.GETTER
@@ -1406,12 +1409,12 @@ class Elements {
static bool isStaticOrTopLevel(Element element) {
// TODO(ager): This should not be necessary when patch support has
// been reworked.
- if (!Element.isInvalid(element)
+ if (!Element.isUnresolved(element)
&& element.modifiers != null
&& element.modifiers.isStatic()) {
return true;
}
- return !Element.isInvalid(element)
+ return !Element.isUnresolved(element)
&& !element.isInstanceMember()
&& !element.isPrefix()
&& element.enclosingElement !== null
@@ -1433,7 +1436,7 @@ class Elements {
}
static bool isInstanceMethod(Element element) {
- return !Element.isInvalid(element)
+ return !Element.isUnresolved(element)
&& element.isInstanceMember()
&& (element.kind === ElementKind.FUNCTION);
}

Powered by Google App Engine
This is Rietveld 408576698