Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2530)

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 15689009: Type check try statements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename variable. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..173330335a7fdb907d76d3b95e735c2d6ce4e9c8 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> formalsToProcess = node.formals.nodes;
+ if (formalsToProcess.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 = formalsToProcess.head;
+ formalsToProcess = formalsToProcess.tail;
+ if (!formalsToProcess.isEmpty) {
+ stackTraceDefinition = formalsToProcess.head;
+ formalsToProcess = formalsToProcess.tail;
+ if (!formalsToProcess.isEmpty) {
+ for (Node extra in formalsToProcess) {
+ 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) {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698