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>
13621362 DecoratedType visitReturnStatement (ReturnStatement node) {
13631363 DecoratedType returnType = _currentFunctionType.returnType;
13641364 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;
13661371 if (returnValue == null ) {
13671372 var target =
13681373 NullabilityNodeTarget .text ('implicit null return' ).withCodeRef (node);
Original file line number Diff line number Diff line change @@ -6836,6 +6836,26 @@ int f() {
68366836 expect (edge.sourceNode.displayName, 'implicit null return (test.dart:2:3)' );
68376837 }
68386838
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+
68396859 Future <void > test_return_null () async {
68406860 await analyze ('''
68416861int f() {
You can’t perform that action at this time.
0 commit comments