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 c8c184fa1388d9982998daa415a5941f87f6daa2..4f93069d9642525c687d9e003229882c8b1c3244 100644 |
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
@@ -1745,52 +1745,55 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
String name = pop(); |
List<DartType> typeArguments = pop(); |
var type = pop(); |
- constantExpressionRequired = pop(); |
- |
- if (arguments == null) { |
- push(buildCompileTimeError("No arguments.", nameToken.charOffset)); |
- return; |
- } |
+ bool savedConstantExpressionRequired = pop(); |
+ () { |
+ if (arguments == null) { |
+ push(buildCompileTimeError("No arguments.", nameToken.charOffset)); |
+ return; |
+ } |
- if (typeArguments != null) { |
- assert(arguments.types.isEmpty); |
- arguments.types.addAll(typeArguments); |
- } |
+ if (typeArguments != null) { |
+ assert(arguments.types.isEmpty); |
+ arguments.types.addAll(typeArguments); |
+ } |
- String errorName; |
- if (type is ClassBuilder) { |
- Builder b = type.findConstructorOrFactory(name); |
- Member target; |
- if (b == null) { |
- // Not found. Reported below. |
- } else if (b.isConstructor) { |
- if (type.isAbstract) { |
- // TODO(ahe): Generate abstract instantiation error. |
- } else { |
- target = b.target; |
+ String errorName; |
+ if (type is ClassBuilder) { |
+ Builder b = type.findConstructorOrFactory(name); |
+ Member target; |
+ if (b == null) { |
+ // Not found. Reported below. |
+ } else if (b.isConstructor) { |
+ if (type.isAbstract) { |
+ // TODO(ahe): Generate abstract instantiation error. |
+ } else { |
+ target = b.target; |
+ } |
+ } else if (b.isFactory) { |
+ target = getRedirectionTarget(b.target); |
+ if (target == null) { |
+ push(buildCompileTimeError( |
+ "Cyclic definition of factory '${name}'.", |
+ nameToken.charOffset)); |
+ return; |
+ } |
} |
- } else if (b.isFactory) { |
- target = getRedirectionTarget(b.target); |
- if (target == null) { |
- push(buildCompileTimeError( |
- "Cyclic definition of factory '${name}'.", nameToken.charOffset)); |
+ if (target is Constructor || |
+ (target is Procedure && target.kind == ProcedureKind.Factory)) { |
+ push(buildStaticInvocation(target, arguments, |
+ isConst: optional("const", token), |
+ charOffset: nameToken.charOffset)); |
return; |
+ } else { |
+ errorName = debugName(type.name, name); |
} |
- } |
- if (target is Constructor || |
- (target is Procedure && target.kind == ProcedureKind.Factory)) { |
- push(buildStaticInvocation(target, arguments, |
- isConst: optional("const", token), |
- charOffset: nameToken.charOffset)); |
- return; |
} else { |
- errorName = debugName(type.name, name); |
+ errorName = debugName(getNodeName(type), name); |
} |
- } else { |
- errorName = debugName(getNodeName(type), name); |
- } |
- errorName ??= name; |
- push(throwNoSuchMethodError(errorName, arguments, nameToken.charOffset)); |
+ errorName ??= name; |
+ push(throwNoSuchMethodError(errorName, arguments, nameToken.charOffset)); |
+ }(); |
+ constantExpressionRequired = savedConstantExpressionRequired; |
} |
@override |