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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1910033002: Add warnings when async and async* functions declare a subtype of Future or Stream respectively (is… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 389a025040c6f690cdcf0b3954da4f9ff1008b6a..f85c6fd060c12fc64155b9eb9b88340053d59253 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -3455,14 +3455,27 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
if (_enclosingFunction.isAsynchronous) {
if (_enclosingFunction.isGenerator) {
- if (!_typeSystem.isAssignableTo(
+ if (_options.strongMode) {
+ if (_enclosingFunction.returnType.element !=
+ _typeProvider.streamType.element) {
+ _errorReporter.reportErrorForNode(
+ StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE,
+ returnType);
+ }
+ } else if (!_typeSystem.isAssignableTo(
_enclosingFunction.returnType, _typeProvider.streamDynamicType)) {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE,
returnType);
}
} else {
- if (!_typeSystem.isAssignableTo(
+ if (_options.strongMode) {
+ if (_enclosingFunction.returnType.element !=
+ _typeProvider.futureType.element) {
+ _errorReporter.reportErrorForNode(
+ StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType);
+ }
+ } else if (!_typeSystem.isAssignableTo(
_enclosingFunction.returnType, _typeProvider.futureDynamicType)) {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType);
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698