| 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 return type; | 571 return type; |
| 572 } | 572 } |
| 573 | 573 |
| 574 Type visitOperator(Operator node) { | 574 Type visitOperator(Operator node) { |
| 575 fail(node, 'internal error'); | 575 fail(node, 'internal error'); |
| 576 } | 576 } |
| 577 | 577 |
| 578 /** Dart Programming Language Specification: 11.10 Return */ | 578 /** Dart Programming Language Specification: 11.10 Return */ |
| 579 Type visitReturn(Return node) { | 579 Type visitReturn(Return node) { |
| 580 final expression = node.expression; | 580 final expression = node.expression; |
| 581 final isVoidFunction = (expectedReturnType === types.voidType); | 581 final isVoidFunction = |
| 582 (expectedReturnType.element === compiler.types.voidType.element); |
| 582 | 583 |
| 583 // Executing a return statement return e; [...] It is a static type warning | 584 // Executing a return statement return e; [...] It is a static type warning |
| 584 // if the type of e may not be assigned to the declared return type of the | 585 // if the type of e may not be assigned to the declared return type of the |
| 585 // immediately enclosing function. | 586 // immediately enclosing function. |
| 586 if (expression !== null) { | 587 if (expression !== null) { |
| 587 final expressionType = analyze(expression); | 588 final expressionType = analyze(expression); |
| 588 if (isVoidFunction | 589 if (isVoidFunction |
| 589 && !types.isAssignable(expressionType, types.voidType)) { | 590 && !types.isAssignable(expressionType, types.voidType)) { |
| 590 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID, | 591 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID, |
| 591 [expressionType]); | 592 [expressionType]); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 729 } |
| 729 | 730 |
| 730 visitCatchBlock(CatchBlock node) { | 731 visitCatchBlock(CatchBlock node) { |
| 731 fail(node); | 732 fail(node); |
| 732 } | 733 } |
| 733 | 734 |
| 734 visitTypedef(Typedef node) { | 735 visitTypedef(Typedef node) { |
| 735 fail(node); | 736 fail(node); |
| 736 } | 737 } |
| 737 } | 738 } |
| OLD | NEW |