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

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

Issue 610863004: Start implementing checked mode compile time errors in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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: 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 2adc8e05b9a075050e35eb187922b984b68f8f09..9731d7e0165c5a2d1cc864e9e149adbe89116eb9 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
@@ -99,6 +99,7 @@ import com.google.dart.engine.ast.WhileStatement;
import com.google.dart.engine.ast.WithClause;
import com.google.dart.engine.ast.YieldStatement;
import com.google.dart.engine.ast.visitor.RecursiveAstVisitor;
+import com.google.dart.engine.context.AnalysisOptions;
import com.google.dart.engine.element.ClassElement;
import com.google.dart.engine.element.ConstructorElement;
import com.google.dart.engine.element.Element;
@@ -420,6 +421,12 @@ public class ErrorVerifier extends RecursiveAstVisitor<Void> {
private final InterfaceType[] DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT;
/**
+ * A flag indicating whether we should generate errors when there are type errors in the
+ * evaluation of constants.
+ */
+ private boolean enableTypeChecks;
+
+ /**
* Static final string with value {@code "getter "} used in the construction of the
* {@link StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE}, and similar, error
* code messages.
@@ -448,6 +455,8 @@ public class ErrorVerifier extends RecursiveAstVisitor<Void> {
this.hasExtUri = currentLibrary.hasExtUri();
this.typeProvider = typeProvider;
this.inheritanceManager = inheritanceManager;
+ AnalysisOptions options = currentLibrary.getContext().getAnalysisOptions();
+ this.enableTypeChecks = options.getEnableTypeChecks();
isEnclosingConstructorConst = false;
isInCatchClause = false;
isInStaticVariableDeclaration = false;
@@ -3414,7 +3423,9 @@ public class ErrorVerifier extends RecursiveAstVisitor<Void> {
return false;
}
// report problem
- if (isEnclosingConstructorConst) {
+ if (isEnclosingConstructorConst && enableTypeChecks) {
+ // TODO(paulberry): this error should be based on the actual type of the constant, not the
+ // static type. See dartbug.com/21119.
Paul Berry 2014/09/29 17:42:23 After some in-person discussion, I've expanded thi
errorReporter.reportTypeErrorForNode(
CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
expression,

Powered by Google App Engine
This is Rietveld 408576698