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 4660299dcd3ca2e7f282454ef644d7b559905ae6..50513f74be7c9b4b34d9a864b80799d318001ad6 100644 |
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart |
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart |
@@ -962,6 +962,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> { |
_checkForMismatchedAccessorTypes(node, methodName); |
} |
if (node.isGetter) { |
+ _checkForVoidReturnType(node); |
_checkForConflictingStaticGetterAndInstanceSetter(node); |
} else if (node.isSetter) { |
_checkForInvalidModifierOnBody( |
@@ -6039,6 +6040,19 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> { |
// } |
} |
+ /** |
+ * Verify that the given [getter] does not have a return type of 'void'. |
+ * |
+ * See [StaticWarningCode.VOID_RETURN_FOR_GETTER]. |
+ */ |
+ void _checkForVoidReturnType(MethodDeclaration getter) { |
+ TypeAnnotation returnType = getter.returnType; |
+ if (returnType is TypeName && returnType.name.name == "void") { |
+ _errorReporter.reportErrorForNode( |
+ StaticWarningCode.VOID_RETURN_FOR_GETTER, returnType); |
+ } |
+ } |
+ |
/** |
* Verify the given operator-method [declaration], has correct number of |
* parameters. |