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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 12220011: Handle malformed types in catch-on. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New implementation + test. Created 7 years, 10 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | tests/language/language.status » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index f7221d0fbf250d5e7037acb57bcb6e359d2505ce..7c6c57fafff4f6b796d670a9b3f4d96c82e7c99c 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -4474,12 +4474,18 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
if (catchBlock.onKeyword != null) {
DartType type = elements.getType(catchBlock.type);
if (type == null) {
- compiler.cancel('On with unresolved type',
- node: catchBlock.type);
+ compiler.cancel('On with no type', node: catchBlock.type);
ngeoffray 2013/02/18 15:48:35 cancel -> internalError ?
Johnni Winther 2013/02/19 07:08:54 Done.
+ }
+ if (type.isMalformed) {
+ // TODO(johnniwinther): Handle malformed types in [HIs] instead.
+ HInstruction condition =
+ graph.addConstantBool(true, constantSystem);
+ stack.add(condition);
+ } else {
+ HInstruction condition =
+ new HIs(type, <HInstruction>[unwrappedException]);
+ push(condition);
}
- HInstruction condition =
- new HIs(type, <HInstruction>[unwrappedException]);
- push(condition);
}
else {
ngeoffray 2013/02/18 15:48:35 Move else one line above.
Johnni Winther 2013/02/19 07:08:54 Done.
VariableDefinitions declaration = catchBlock.formals.nodes.head;
@@ -4506,6 +4512,21 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
void visitThen() {
CatchBlock catchBlock = link.head;
link = link.tail;
+
+ if (compiler.enableTypeAssertions) {
+ // In checked mode: Throw a type error if the on-catch type is
ngeoffray 2013/02/18 15:48:35 Throw -> throw
Johnni Winther 2013/02/19 07:08:54 Done.
+ // malformed.
+ if (catchBlock.onKeyword != null) {
+ DartType type = elements.getType(catchBlock.type);
+ if (type != null && type.isMalformed) {
+ String reasons = Types.fetchReasonsFromMalformedType(type);
+ generateMalformedSubtypeError(node,
+ unwrappedException, type, reasons);
+ pop();
+ return;
+ }
+ }
+ }
if (catchBlock.exception != null) {
localsHandler.updateLocal(elements[catchBlock.exception],
unwrappedException);
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | tests/language/language.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698