Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| index 69016805c2221f0f439ca0648c8f67f0935dc8db..75857c316dd3272af8d3ff852ca3b292b61424dc 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
| @@ -2975,17 +2975,25 @@ class ResolverVisitor extends MappingVisitor<Element> { |
| compiler.backend.registerCatchStatement(world, mapping); |
| // Check that if catch part is present, then |
| // it has one or two formal parameters. |
| + VariableDefinitions exceptionDefinition; |
| + VariableDefinitions stackTraceDefinition; |
| if (node.formals != null) { |
| - if (node.formals.isEmpty) { |
| + Link<Node> formalToProcess = node.formals.nodes; |
| + if (formalToProcess.isEmpty) { |
|
karlklose
2013/05/27 12:43:54
I think the plural reads better with property acce
|
| error(node, MessageKind.EMPTY_CATCH_DECLARATION); |
| - } |
| - if (!node.formals.nodes.tail.isEmpty) { |
| - if (!node.formals.nodes.tail.tail.isEmpty) { |
| - for (Node extra in node.formals.nodes.tail.tail) { |
| - error(extra, MessageKind.EXTRA_CATCH_DECLARATION); |
| + } else { |
| + exceptionDefinition = formalToProcess.head; |
| + formalToProcess = formalToProcess.tail; |
| + if (!formalToProcess.isEmpty) { |
| + stackTraceDefinition = formalToProcess.head; |
| + formalToProcess = formalToProcess.tail; |
| + if (!formalToProcess.isEmpty) { |
| + for (Node extra in formalToProcess) { |
| + error(extra, MessageKind.EXTRA_CATCH_DECLARATION); |
| + } |
| } |
| + compiler.backend.registerStackTraceInCatch(mapping); |
| } |
| - compiler.backend.registerStackTraceInCatch(mapping); |
| } |
| // Check that the formals aren't optional and that they have no |
| @@ -3021,6 +3029,19 @@ class ResolverVisitor extends MappingVisitor<Element> { |
| inCatchBlock = true; |
| visitIn(node.block, blockScope); |
| inCatchBlock = oldInCatchBlock; |
| + |
| + if (node.type != null && exceptionDefinition != null) { |
| + DartType exceptionType = mapping.getType(node.type); |
| + Node exceptionVariable = exceptionDefinition.definitions.nodes.head; |
| + VariableElementX exceptionElement = mapping[exceptionVariable]; |
| + exceptionElement.variables.type = exceptionType; |
| + } |
| + if (stackTraceDefinition != null) { |
| + Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; |
| + VariableElementX stackTraceElement = mapping[stackTraceVariable]; |
| + world.registerInstantiatedClass(compiler.stackTraceClass, mapping); |
| + stackTraceElement.variables.type = compiler.stackTraceClass.rawType; |
| + } |
| } |
| visitTypedef(Typedef node) { |