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

Unified Diff: lib/compiler/implementation/resolver.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/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 4b6a8f49fdbe5ed61d7e91227689569694408830..fc20a07a00c19d8911fd13fa18c724c0495ba371 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1024,7 +1024,12 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
} else {
Element element = lookup(node, node.source);
if (element === null) {
- if (!inInstanceContext) error(node, MessageKind.CANNOT_RESOLVE, [node]);
+ if (!inInstanceContext) {
+ ResolutionWarning warning =
+ new ResolutionWarning(MessageKind.CANNOT_RESOLVE, [node]);
+ compiler.reportWarning(node, warning);
+ element = new ErroneousElement(warning.message, enclosingElement);
+ }
} else {
if ((element.kind.category & allowedCategory) == 0) {
// TODO(ahe): Improve error message. Need UX input.
@@ -1336,9 +1341,12 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
&& target.kind == ElementKind.ABSTRACT_FIELD) {
AbstractFieldElement field = target;
target = field.getter;
- if (Element.isInvalid(target) && !inInstanceContext) {
- // TODO(karlklose): make this a runtime error.
- error(node.selector, MessageKind.CANNOT_RESOLVE_GETTER);
+ if (target == null && !inInstanceContext) {
+ ResolutionWarning warning =
+ new ResolutionWarning(MessageKind.CANNOT_RESOLVE_GETTER,
+ [node.selector]);
+ compiler.reportWarning(node.selector, warning);
+ target = new ErroneousElement(warning.message, enclosingElement);
}
}
@@ -1402,17 +1410,24 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
Element getter = target;
String source = node.assignmentOperator.source.stringValue;
bool isComplex = source !== '=';
- if (target != null && target.kind == ElementKind.ABSTRACT_FIELD) {
+ if (!Element.isInvalid(target)
+ && target.kind == ElementKind.ABSTRACT_FIELD) {
AbstractFieldElement field = target;
setter = field.setter;
getter = field.getter;
- if (Element.isInvalid(setter) && !inInstanceContext) {
- // TODO(karlklose): make this a runtime error.
- error(node.selector, MessageKind.CANNOT_RESOLVE_SETTER);
- }
- if (isComplex && Element.isInvalid(getter) && !inInstanceContext) {
- // TODO(karlklose): make this a runtime error.
- error(node.selector, MessageKind.CANNOT_RESOLVE_GETTER);
+ if (setter == null && !inInstanceContext) {
+ ResolutionWarning warning =
kasperl 2012/09/05 09:29:45 This looks ripe for refactoring. Couldn't we share
karlklose 2012/09/05 11:10:47 Done.
+ new ResolutionWarning(MessageKind.CANNOT_RESOLVE_GETTER,
+ [node.selector]);
+ compiler.reportWarning(node.selector, warning);
+ setter = new ErroneousElement(warning.message, enclosingElement);
+ }
+ if (isComplex && getter == null && !inInstanceContext) {
+ ResolutionWarning warning =
+ new ResolutionWarning(MessageKind.CANNOT_RESOLVE_GETTER,
+ [node.selector]);
+ compiler.reportWarning(node.selector, warning);
+ getter = new ErroneousElement(warning.message, enclosingElement);
}
}

Powered by Google App Engine
This is Rietveld 408576698