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..2364cee6ad90b33f3cbef31eb3f0689a3259d132 100644 |
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart |
@@ -2975,24 +2975,30 @@ 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> link = node.formals.nodes; |
karlklose
2013/05/27 12:43:54
link -> formalsToProcess? formalsLink?
|
+ if (link.isEmpty) { |
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 = link.head; |
+ link = link.tail; |
+ if (!link.isEmpty) { |
+ stackTraceDefinition = link.head; |
+ link = link.tail; |
+ if (!link.isEmpty) { |
+ for (Node extra in link) { |
+ 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 |
// modifiers or type. |
- for (Link<Node> link = node.formals.nodes; |
- !link.isEmpty; |
- link = link.tail) { |
+ for (link = node.formals.nodes; !link.isEmpty; link = link.tail) { |
// If the formal parameter is a node list, it means that it is a |
// sequence of optional parameters. |
NodeList nodeList = link.head.asNodeList(); |
@@ -3021,6 +3027,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) { |