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

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: Updated cf. comments. 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') | no next file with comments »
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 6d6000fb985e0ec6cff93984ea53cd956c5ffaa5..c9044d84f20282df999c7566fff4fa9b7b7bc14d 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -4474,14 +4474,19 @@ 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.internalError('On with no type', node: catchBlock.type);
}
- HInstruction condition =
- new HIs(type, <HInstruction>[unwrappedException]);
- push(condition);
- }
- else {
+ 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);
+ }
+ } else {
VariableDefinitions declaration = catchBlock.formals.nodes.head;
HInstruction condition = null;
if (declaration.type == null) {
@@ -4506,6 +4511,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
+ // 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698