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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 14985013: Report CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweak Created 7 years, 7 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: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
index ab69d17a64973804be7a11ba42e7529d41c44aa0..c0d167591fce7cb3f3a4a7ecac6f007895132e85 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
@@ -427,6 +427,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
if (type instanceof InterfaceType) {
InterfaceType interfaceType = (InterfaceType) type;
checkForConstWithNonConst(node);
+ checkForConstWithUndefinedConstructor(node);
Brian Wilkerson 2013/05/13 13:58:02 There are two methods so far that both check for '
scheglov 2013/05/13 16:23:43 Done.
checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
// TODO(jwren) Email Luke to make this determination: Should we always call all checks, if not,
// which order should they be called in?
@@ -1219,6 +1220,42 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies that if the passed instance creation expression is 'const', then it is being
+ * invoked on the resolved constructor.
+ *
+ * @param node the instance creation expression to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR
+ * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT
+ */
+ private boolean checkForConstWithUndefinedConstructor(InstanceCreationExpression node) {
+ if (!node.isConst()) {
+ return false;
+ }
+ if (node.getElement() != null) {
+ return false;
+ }
+ ConstructorName constructorName = node.getConstructorName();
+ if (constructorName == null) {
+ return false;
+ }
+ SimpleIdentifier name = constructorName.getName();
+ if (name != null) {
+ errorReporter.reportError(
+ CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR,
+ node,
+ constructorName.getType(),
+ name);
+ } else {
+ errorReporter.reportError(
+ CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT,
+ node,
+ constructorName.getType());
+ }
+ return true;
+ }
+
+ /**
* This verifies that there are no default parameters in the passed function type alias.
*
* @param node the function type alias to evaluate

Powered by Google App Engine
This is Rietveld 408576698