| 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 class TypeCheckerTask extends CompilerTask { | 5 class TypeCheckerTask extends CompilerTask { |
| 6 TypeCheckerTask(Compiler compiler) : super(compiler); | 6 TypeCheckerTask(Compiler compiler) : super(compiler); |
| 7 String get name() => "Type checker"; | 7 String get name() => "Type checker"; |
| 8 | 8 |
| 9 static final bool LOG_FAILURES = false; | 9 static final bool LOG_FAILURES = false; |
| 10 | 10 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 594 } |
| 595 return type; | 595 return type; |
| 596 } | 596 } |
| 597 | 597 |
| 598 Type visitOperator(Operator node) { | 598 Type visitOperator(Operator node) { |
| 599 fail(node, 'internal error'); | 599 fail(node, 'internal error'); |
| 600 } | 600 } |
| 601 | 601 |
| 602 /** Dart Programming Language Specification: 11.10 Return */ | 602 /** Dart Programming Language Specification: 11.10 Return */ |
| 603 Type visitReturn(Return node) { | 603 Type visitReturn(Return node) { |
| 604 if (node.getBeginToken().stringValue === 'native') { |
| 605 return StatementType.RETURNING; |
| 606 } |
| 607 |
| 604 final expression = node.expression; | 608 final expression = node.expression; |
| 605 final isVoidFunction = (expectedReturnType === types.voidType); | 609 final isVoidFunction = (expectedReturnType === types.voidType); |
| 606 | 610 |
| 607 // Executing a return statement return e; [...] It is a static type warning | 611 // Executing a return statement return e; [...] It is a static type warning |
| 608 // if the type of e may not be assigned to the declared return type of the | 612 // if the type of e may not be assigned to the declared return type of the |
| 609 // immediately enclosing function. | 613 // immediately enclosing function. |
| 610 if (expression !== null) { | 614 if (expression !== null) { |
| 611 final expressionType = analyze(expression); | 615 final expressionType = analyze(expression); |
| 612 if (isVoidFunction | 616 if (isVoidFunction |
| 613 && !types.isAssignable(expressionType, types.voidType)) { | 617 && !types.isAssignable(expressionType, types.voidType)) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 772 } |
| 769 | 773 |
| 770 visitCatchBlock(CatchBlock node) { | 774 visitCatchBlock(CatchBlock node) { |
| 771 return unhandledStatement(); | 775 return unhandledStatement(); |
| 772 } | 776 } |
| 773 | 777 |
| 774 visitTypedef(Typedef node) { | 778 visitTypedef(Typedef node) { |
| 775 return unhandledStatement(); | 779 return unhandledStatement(); |
| 776 } | 780 } |
| 777 } | 781 } |
| OLD | NEW |