This repository was archived by the owner on Nov 20, 2024. It is now read-only.
File tree 1 file changed +17
-4
lines changed 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,18 @@ class _Visitor extends SimpleAstVisitor<void> {
71
71
return false ;
72
72
}
73
73
74
+ bool isTypeAcceptableWhenExpectingFutureOrVoid (DartType type) {
75
+ if (type.isDynamic) return true ;
76
+ if (isTypeAcceptableWhenExpectingVoid (type)) return true ;
77
+ if (type.isDartAsyncFutureOr &&
78
+ type is InterfaceType &&
79
+ isTypeAcceptableWhenExpectingFutureOrVoid (type.typeArguments.first)) {
80
+ return true ;
81
+ }
82
+
83
+ return false ;
84
+ }
85
+
74
86
@override
75
87
void visitAssignmentExpression (AssignmentExpression node) {
76
88
final type = node.writeType;
@@ -133,10 +145,11 @@ class _Visitor extends SimpleAstVisitor<void> {
133
145
if (expectedType == null || type == null ) {
134
146
return ;
135
147
}
136
- if (expectedType.isVoid && ! isTypeAcceptableWhenExpectingVoid (type) ||
137
- expectedType.isDartAsyncFutureOr &&
138
- (expectedType as InterfaceType ).typeArguments.first.isVoid &&
139
- ! typeSystem.isAssignableTo (type, _futureDynamicType)) {
148
+ if (expectedType.isVoid && ! isTypeAcceptableWhenExpectingVoid (type)) {
149
+ rule.reportLint (node);
150
+ } else if (expectedType.isDartAsyncFutureOr &&
151
+ (expectedType as InterfaceType ).typeArguments.first.isVoid &&
152
+ ! isTypeAcceptableWhenExpectingFutureOrVoid (type)) {
140
153
rule.reportLint (node);
141
154
} else if (checkedNode is FunctionExpression &&
142
155
checkedNode.body is ! ExpressionFunctionBody &&
You can’t perform that action at this time.
0 commit comments