Chromium Code Reviews| 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..1e034529bf260b3f24d8dd24b0060cf783703d59 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,56 @@ 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(); |
| + try { |
| + if (arguments == null) { |
|
karlklose
2017/03/24 08:54:08
Could you move this code into a local function ins
ahe
2017/03/24 12:47:58
Done.
|
| + 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)); |
| + } finally { |
| + constantExpressionRequired = savedConstantExpressionRequired; |
| } |
| - errorName ??= name; |
| - push(throwNoSuchMethodError(errorName, arguments, nameToken.charOffset)); |
| } |
| @override |