Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
index 8097c4baf12a2cd514e3f577b63d069b735bff23..e0db0d2d00c55ae1a3b1d8ed02dc8dfd01c2200b 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
@@ -124,6 +124,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
CloneVisitor cloner; |
+ bool constantExpressionRequired = false; |
+ |
BodyBuilder( |
KernelLibraryBuilder library, |
this.member, |
@@ -1657,12 +1659,30 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
} |
@override |
+ void beginNewExpression(Token token) { |
+ debugEvent("beginNewExpression"); |
+ super.push(constantExpressionRequired); |
+ if (constantExpressionRequired) { |
+ addCompileTimeError(token.charOffset, "Not a constant expression."); |
+ } |
+ constantExpressionRequired = false; |
+ } |
+ |
+ @override |
+ void beginConstExpression(Token token) { |
+ debugEvent("beginConstExpression"); |
+ super.push(constantExpressionRequired); |
+ constantExpressionRequired = true; |
+ } |
+ |
+ @override |
void endNewExpression(Token token) { |
debugEvent("NewExpression"); |
Arguments arguments = pop(); |
String name = pop(); |
List<DartType> typeArguments = pop(); |
var type = pop(); |
+ constantExpressionRequired = pop(); |
if (arguments == null) { |
push(buildCompileTimeError("No arguments.", token.charOffset)); |