File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1362,7 +1362,12 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
1362
1362
DecoratedType visitReturnStatement (ReturnStatement node) {
1363
1363
DecoratedType returnType = _currentFunctionType.returnType;
1364
1364
Expression returnValue = node.expression;
1365
- final isAsync = node.thisOrAncestorOfType <FunctionBody >().isAsynchronous;
1365
+ var functionBody = node.thisOrAncestorOfType <FunctionBody >();
1366
+ if (functionBody.isGenerator) {
1367
+ // Do not connect the return value to the return type.
1368
+ return _dispatch (returnValue);
1369
+ }
1370
+ final isAsync = functionBody.isAsynchronous;
1366
1371
if (returnValue == null ) {
1367
1372
var target =
1368
1373
NullabilityNodeTarget .text ('implicit null return' ).withCodeRef (node);
Original file line number Diff line number Diff line change @@ -6836,6 +6836,26 @@ int f() {
6836
6836
expect (edge.sourceNode.displayName, 'implicit null return (test.dart:2:3)' );
6837
6837
}
6838
6838
6839
+ Future <void > test_return_in_asyncStar () async {
6840
+ await analyze ('''
6841
+ Stream<int> f() async* {
6842
+ yield 1;
6843
+ return;
6844
+ }
6845
+ ''' );
6846
+ assertNoUpstreamNullability (decoratedTypeAnnotation ('Stream<int>' ).node);
6847
+ }
6848
+
6849
+ Future <void > test_return_in_syncStar () async {
6850
+ await analyze ('''
6851
+ Iterable<int> f() sync* {
6852
+ yield 1;
6853
+ return;
6854
+ }
6855
+ ''' );
6856
+ assertNoUpstreamNullability (decoratedTypeAnnotation ('Iterable<int>' ).node);
6857
+ }
6858
+
6839
6859
Future <void > test_return_null () async {
6840
6860
await analyze ('''
6841
6861
int f() {
You can’t perform that action at this time.
0 commit comments