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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 787753005: Fix crash in typechecker (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 class TypeCheckerTask extends CompilerTask { 7 class TypeCheckerTask extends CompilerTask {
8 TypeCheckerTask(Compiler compiler) : super(compiler); 8 TypeCheckerTask(Compiler compiler) : super(compiler);
9 String get name => "Type checker"; 9 String get name => "Type checker";
10 10
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 receiverType = superType; 1097 receiverType = superType;
1098 } else { 1098 } else {
1099 assert(node.selector.isThis()); 1099 assert(node.selector.isThis());
1100 receiverType = thisType; 1100 receiverType = thisType;
1101 } 1101 }
1102 DartType constructorType = computeConstructorType(element, receiverType); 1102 DartType constructorType = computeConstructorType(element, receiverType);
1103 analyzeArguments(node, element, constructorType); 1103 analyzeArguments(node, element, constructorType);
1104 return const DynamicType(); 1104 return const DynamicType();
1105 } 1105 }
1106 1106
1107 Identifier selector = node.selector.asIdentifier();
1107 if (Elements.isClosureSend(node, element)) { 1108 if (Elements.isClosureSend(node, element)) {
1108 if (element != null) { 1109 if (element != null) {
1109 // foo() where foo is a local or a parameter. 1110 // foo() where foo is a local or a parameter.
1110 return analyzeInvocation(node, createPromotedAccess(element)); 1111 return analyzeInvocation(node, createPromotedAccess(element));
1111 } else { 1112 } else {
1112 // exp() where exp is some complex expression like (o) or foo(). 1113 // exp() where exp is some complex expression like (o) or foo().
1113 DartType type = analyze(node.selector); 1114 DartType type = analyze(node.selector);
1114 return analyzeInvocation(node, new TypeAccess(type)); 1115 return analyzeInvocation(node, new TypeAccess(type));
1115 } 1116 }
1117 } else if (Elements.isErroneousElement(element) && selector == null) {
1118 // exp() where exp is an erroneous construct like `new Unresolved()`.
1119 DartType type = analyze(node.selector);
1120 return analyzeInvocation(node, new TypeAccess(type));
1116 } 1121 }
1117 1122
1118 Identifier selector = node.selector.asIdentifier();
1119 String name = selector.source; 1123 String name = selector.source;
1120 1124
1121 if (node.isOperator && identical(name, 'is')) { 1125 if (node.isOperator && identical(name, 'is')) {
1122 analyze(node.receiver); 1126 analyze(node.receiver);
1123 if (!node.isIsNotCheck) { 1127 if (!node.isIsNotCheck) {
1124 Element variable = elements[node.receiver]; 1128 Element variable = elements[node.receiver];
1125 if (variable == null) { 1129 if (variable == null) {
1126 // Look for the variable element within parenthesized expressions. 1130 // Look for the variable element within parenthesized expressions.
1127 ParenthesizedExpression parentheses = 1131 ParenthesizedExpression parentheses =
1128 node.receiver.asParenthesizedExpression(); 1132 node.receiver.asParenthesizedExpression();
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1824
1821 visitTypedef(Typedef node) { 1825 visitTypedef(Typedef node) {
1822 // Do not typecheck [Typedef] nodes. 1826 // Do not typecheck [Typedef] nodes.
1823 } 1827 }
1824 1828
1825 visitNode(Node node) { 1829 visitNode(Node node) {
1826 compiler.internalError(node, 1830 compiler.internalError(node,
1827 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1831 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1828 } 1832 }
1829 } 1833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698