| 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 ca3b4ed4d07b3e91a73e354240ccfffbb98c2c34..489a6bc10bddd4c2a254bd0045ac6a38a1a31b50 100644
|
| --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
|
| +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
|
| @@ -85,6 +85,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
|
|
| bool inCatchClause = false;
|
|
|
| + bool inCatchBlock = false;
|
| +
|
| int functionNestingLevel = 0;
|
|
|
| Statement compileTimeErrorInTry;
|
| @@ -1518,12 +1520,15 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| void endCatchClause(Token token) {
|
| debugEvent("CatchClause");
|
| inCatchClause = false;
|
| + push(inCatchBlock);
|
| + inCatchBlock = true;
|
| }
|
|
|
| @override
|
| void handleCatchBlock(Token onKeyword, Token catchKeyword) {
|
| debugEvent("CatchBlock");
|
| Block body = pop();
|
| + inCatchBlock = pop();
|
| if (catchKeyword != null) {
|
| exitLocalScope();
|
| }
|
| @@ -1910,11 +1915,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| functionNestingLevel++;
|
| push(switchScope ?? NullValue.SwitchScope);
|
| switchScope = null;
|
| + push(inCatchBlock);
|
| + inCatchBlock = false;
|
| }
|
|
|
| void exitFunction() {
|
| debugEvent("exitFunction");
|
| functionNestingLevel--;
|
| + inCatchBlock = pop();
|
| switchScope = pop();
|
| }
|
|
|
| @@ -2100,8 +2108,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
|
| @override
|
| void endRethrowStatement(Token throwToken, Token endToken) {
|
| debugEvent("RethrowStatement");
|
| - push(new ExpressionStatement(
|
| - new Rethrow()..fileOffset = throwToken.charOffset));
|
| + if (inCatchBlock) {
|
| + push(new ExpressionStatement(
|
| + new Rethrow()..fileOffset = throwToken.charOffset));
|
| + } else {
|
| + push(buildCompileTimeErrorStatement(
|
| + "'rethrow' can only be used in catch clauses.",
|
| + throwToken.charOffset));
|
| + }
|
| }
|
|
|
| @override
|
|
|