| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.src.generated.error_verifier; | 5 library analyzer.src.generated.error_verifier; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 3437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3448 * respectively. If not, report the error using [returnType]. | 3448 * respectively. If not, report the error using [returnType]. |
| 3449 */ | 3449 */ |
| 3450 void _checkForIllegalReturnType(TypeName returnType) { | 3450 void _checkForIllegalReturnType(TypeName returnType) { |
| 3451 if (returnType == null) { | 3451 if (returnType == null) { |
| 3452 // No declared return type, so the return type must be dynamic, which is | 3452 // No declared return type, so the return type must be dynamic, which is |
| 3453 // assignable to everything. | 3453 // assignable to everything. |
| 3454 return; | 3454 return; |
| 3455 } | 3455 } |
| 3456 if (_enclosingFunction.isAsynchronous) { | 3456 if (_enclosingFunction.isAsynchronous) { |
| 3457 if (_enclosingFunction.isGenerator) { | 3457 if (_enclosingFunction.isGenerator) { |
| 3458 if (!_typeSystem.isAssignableTo( | 3458 if (_options.strongMode) { |
| 3459 if (_enclosingFunction.returnType.element != |
| 3460 _typeProvider.streamType.element) { |
| 3461 _errorReporter.reportErrorForNode( |
| 3462 StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, |
| 3463 returnType); |
| 3464 } |
| 3465 } else if (!_typeSystem.isAssignableTo( |
| 3459 _enclosingFunction.returnType, _typeProvider.streamDynamicType)) { | 3466 _enclosingFunction.returnType, _typeProvider.streamDynamicType)) { |
| 3460 _errorReporter.reportErrorForNode( | 3467 _errorReporter.reportErrorForNode( |
| 3461 StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, | 3468 StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, |
| 3462 returnType); | 3469 returnType); |
| 3463 } | 3470 } |
| 3464 } else { | 3471 } else { |
| 3465 if (!_typeSystem.isAssignableTo( | 3472 if (_options.strongMode) { |
| 3473 if (_enclosingFunction.returnType.element != |
| 3474 _typeProvider.futureType.element) { |
| 3475 _errorReporter.reportErrorForNode( |
| 3476 StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType); |
| 3477 } |
| 3478 } else if (!_typeSystem.isAssignableTo( |
| 3466 _enclosingFunction.returnType, _typeProvider.futureDynamicType)) { | 3479 _enclosingFunction.returnType, _typeProvider.futureDynamicType)) { |
| 3467 _errorReporter.reportErrorForNode( | 3480 _errorReporter.reportErrorForNode( |
| 3468 StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType); | 3481 StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType); |
| 3469 } | 3482 } |
| 3470 } | 3483 } |
| 3471 } else if (_enclosingFunction.isGenerator) { | 3484 } else if (_enclosingFunction.isGenerator) { |
| 3472 if (!_typeSystem.isAssignableTo( | 3485 if (!_typeSystem.isAssignableTo( |
| 3473 _enclosingFunction.returnType, _typeProvider.iterableDynamicType)) { | 3486 _enclosingFunction.returnType, _typeProvider.iterableDynamicType)) { |
| 3474 _errorReporter.reportErrorForNode( | 3487 _errorReporter.reportErrorForNode( |
| 3475 StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, | 3488 StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, |
| (...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6162 class _InvocationCollector extends RecursiveAstVisitor { | 6175 class _InvocationCollector extends RecursiveAstVisitor { |
| 6163 final List<String> superCalls = <String>[]; | 6176 final List<String> superCalls = <String>[]; |
| 6164 | 6177 |
| 6165 @override | 6178 @override |
| 6166 visitMethodInvocation(MethodInvocation node) { | 6179 visitMethodInvocation(MethodInvocation node) { |
| 6167 if (node.target is SuperExpression) { | 6180 if (node.target is SuperExpression) { |
| 6168 superCalls.add(node.methodName.name); | 6181 superCalls.add(node.methodName.name); |
| 6169 } | 6182 } |
| 6170 } | 6183 } |
| 6171 } | 6184 } |
| OLD | NEW |