| OLD | NEW |
| 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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 | 1415 |
| 1416 DartType visitConditional(Conditional node) { | 1416 DartType visitConditional(Conditional node) { |
| 1417 Expression condition = node.condition; | 1417 Expression condition = node.condition; |
| 1418 Expression thenExpression = node.thenExpression; | 1418 Expression thenExpression = node.thenExpression; |
| 1419 | 1419 |
| 1420 checkCondition(condition); | 1420 checkCondition(condition); |
| 1421 | 1421 |
| 1422 DartType thenType = analyzeInPromotedContext(condition, thenExpression); | 1422 DartType thenType = analyzeInPromotedContext(condition, thenExpression); |
| 1423 | 1423 |
| 1424 DartType elseType = analyzeNonVoid(node.elseExpression); | 1424 DartType elseType = analyzeNonVoid(node.elseExpression); |
| 1425 if (types.isSubtype(thenType, elseType)) { | 1425 return compiler.types.computeLeastUpperBound(thenType, elseType); |
| 1426 return thenType; | |
| 1427 } else if (types.isSubtype(elseType, thenType)) { | |
| 1428 return elseType; | |
| 1429 } else { | |
| 1430 return objectType; | |
| 1431 } | |
| 1432 } | 1426 } |
| 1433 | 1427 |
| 1434 visitStringInterpolation(StringInterpolation node) { | 1428 visitStringInterpolation(StringInterpolation node) { |
| 1435 node.visitChildren(this); | 1429 node.visitChildren(this); |
| 1436 return stringType; | 1430 return stringType; |
| 1437 } | 1431 } |
| 1438 | 1432 |
| 1439 visitStringInterpolationPart(StringInterpolationPart node) { | 1433 visitStringInterpolationPart(StringInterpolationPart node) { |
| 1440 node.visitChildren(this); | 1434 node.visitChildren(this); |
| 1441 return stringType; | 1435 return stringType; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 visitTypedef(Typedef node) { | 1572 visitTypedef(Typedef node) { |
| 1579 // Do not typecheck [Typedef] nodes. | 1573 // Do not typecheck [Typedef] nodes. |
| 1580 } | 1574 } |
| 1581 | 1575 |
| 1582 visitNode(Node node) { | 1576 visitNode(Node node) { |
| 1583 compiler.internalError( | 1577 compiler.internalError( |
| 1584 'Unexpected node ${node.getObjectDescription()} in the type checker.', | 1578 'Unexpected node ${node.getObjectDescription()} in the type checker.', |
| 1585 node: node); | 1579 node: node); |
| 1586 } | 1580 } |
| 1587 } | 1581 } |
| OLD | NEW |