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

Unified Diff: dart/pkg/compiler/lib/src/compile_time_constants.dart

Issue 791263003: Remove Compiler.reportFatalError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: One more crash revealed. Created 6 years 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: dart/pkg/compiler/lib/src/compile_time_constants.dart
diff --git a/dart/pkg/compiler/lib/src/compile_time_constants.dart b/dart/pkg/compiler/lib/src/compile_time_constants.dart
index 31eb5b3f8f5cbed50befbb0882e1530aba71553f..2e42f9d702c47714b9b41ad633ede86debb93d85 100644
--- a/dart/pkg/compiler/lib/src/compile_time_constants.dart
+++ b/dart/pkg/compiler/lib/src/compile_time_constants.dart
@@ -133,8 +133,9 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
Node node = element.node;
if (pendingVariables.contains(element)) {
if (isConst) {
- compiler.reportFatalError(
+ compiler.reportError(
node, MessageKind.CYCLIC_COMPILE_TIME_CONSTANTS);
+ throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Insert a TODO. This should only mark the currently
ahe 2015/01/07 12:55:24 Done.
}
return null;
}
@@ -155,7 +156,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
if (elementType.isMalformed && !value.value.isNull) {
if (isConst) {
ErroneousElement element = elementType.element;
- compiler.reportFatalError(
+ compiler.reportError(
node, element.messageKind, element.messageArguments);
} else {
// We need to throw an exception at runtime.
@@ -166,7 +167,7 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
if (!constantSystem.isSubtype(compiler.types,
constantType, elementType)) {
if (isConst) {
- compiler.reportFatalError(
+ compiler.reportError(
node, MessageKind.NOT_ASSIGNABLE,
{'fromType': constantType, 'toType': elementType});
} else {
@@ -605,7 +606,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
} else if (!condition.value.isBool) {
DartType conditionType = condition.value.getType(compiler.coreTypes);
if (isEvaluatingConstant) {
- compiler.reportFatalError(
+ compiler.reportError(
node.condition, MessageKind.NOT_ASSIGNABLE,
{'fromType': conditionType, 'toType': compiler.boolClass.rawType});
}
@@ -655,10 +656,11 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (!selector.applies(target, compiler.world)) {
String name = Elements.constructorNameForDiagnostics(
target.enclosingClass.name, target.name);
- compiler.reportFatalError(
+ compiler.reportError(
node,
MessageKind.INVALID_CONSTRUCTOR_ARGUMENTS,
{'constructorName': name});
+ throw new CompilerCancelledException(null);
Johnni Winther 2015/01/06 08:12:04 Ditto.
ahe 2015/01/07 12:55:24 Done.
}
return selector.makeArgumentsList2(arguments,
target,
@@ -728,14 +730,14 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
ConstantValue defaultValue = normalizedArguments[1].value;
if (firstArgument.isNull) {
- compiler.reportFatalError(
+ compiler.reportError(
send.arguments.head, MessageKind.NULL_NOT_ALLOWED);
return null;
}
if (!firstArgument.isString) {
DartType type = defaultValue.getType(compiler.coreTypes);
- compiler.reportFatalError(
+ compiler.reportError(
send.arguments.head, MessageKind.NOT_ASSIGNABLE,
{'fromType': type, 'toType': compiler.stringClass.rawType});
return null;
@@ -744,7 +746,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (constructor == compiler.intEnvironment &&
!(defaultValue.isNull || defaultValue.isInt)) {
DartType type = defaultValue.getType(compiler.coreTypes);
- compiler.reportFatalError(
+ compiler.reportError(
send.arguments.tail.head, MessageKind.NOT_ASSIGNABLE,
{'fromType': type, 'toType': compiler.intClass.rawType});
return null;
@@ -753,7 +755,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (constructor == compiler.boolEnvironment &&
!(defaultValue.isNull || defaultValue.isBool)) {
DartType type = defaultValue.getType(compiler.coreTypes);
- compiler.reportFatalError(
+ compiler.reportError(
send.arguments.tail.head, MessageKind.NOT_ASSIGNABLE,
{'fromType': type, 'toType': compiler.boolClass.rawType});
return null;
@@ -762,7 +764,7 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
if (constructor == compiler.stringEnvironment &&
!(defaultValue.isNull || defaultValue.isString)) {
DartType type = defaultValue.getType(compiler.coreTypes);
- compiler.reportFatalError(
+ compiler.reportError(
send.arguments.tail.head, MessageKind.NOT_ASSIGNABLE,
{'fromType': type, 'toType': compiler.stringClass.rawType});
return null;
@@ -850,13 +852,16 @@ class CompileTimeConstantEvaluator extends Visitor<AstConstant> {
error(Node node, MessageKind message) {
// TODO(floitsch): get the list of constants that are currently compiled
// and present some kind of stack-trace.
- compiler.reportFatalError(node, message);
+ compiler.reportError(node, message);
}
AstConstant signalNotCompileTimeConstant(Node node,
{MessageKind message: MessageKind.NOT_A_COMPILE_TIME_CONSTANT}) {
if (isEvaluatingConstant) {
error(node, message);
+
+ return new AstConstant(
+ null, node, new PrimitiveConstantExpression(new NullConstantValue()));
}
// Else we don't need to do anything. The final handler is only
// optimistically trying to compile constants. So it is normal that we
@@ -913,7 +918,7 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator {
if (!constantSystem.isSubtype(compiler.types,
constantType, elementType)) {
compiler.withCurrentElement(constant.element, () {
- compiler.reportFatalError(
+ compiler.reportError(
constant.node, MessageKind.NOT_ASSIGNABLE,
{'fromType': constantType, 'toType': elementType});
});

Powered by Google App Engine
This is Rietveld 408576698