| 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..6e144abda6e8467c7f6164c78454116a846bf409 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,13 @@ 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.
|
| + // TODO(paulberry): in the long run, we would prefer to implement this by having the analysis
|
| + // engine output a new type of error that means "error if run in checked mode", rather than
|
| + // having the analysis engine choose whether to issue the error based on whether checked mode
|
| + // is enabled.
|
| errorReporter.reportTypeErrorForNode(
|
| CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE,
|
| expression,
|
|
|