File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ class FunctionExpressionResolver {
69
69
if (_flowAnalysis.flow != null && ! isFunctionDeclaration) {
70
70
var bodyContext = BodyInferenceContext .of (node.body);
71
71
_resolver.checkForBodyMayCompleteNormally (
72
- returnType: bodyContext.contextType,
72
+ returnType: bodyContext? .contextType,
73
73
body: body,
74
74
errorNode: body,
75
75
);
Original file line number Diff line number Diff line change @@ -1166,8 +1166,8 @@ class ResolverVisitor extends ScopedVisitor {
1166
1166
super .visitConstructorDeclaration (node);
1167
1167
1168
1168
if (_flowAnalysis != null ) {
1169
- var bodyContext = BodyInferenceContext .of (node.body);
1170
1169
if (node.factoryKeyword != null ) {
1170
+ var bodyContext = BodyInferenceContext .of (node.body);
1171
1171
checkForBodyMayCompleteNormally (
1172
1172
returnType: bodyContext? .contextType,
1173
1173
body: node.body,
Original file line number Diff line number Diff line change @@ -389,6 +389,12 @@ class B {
389
389
@reflectiveTest
390
390
class InvalidCodeWithNullSafetyTest extends PubPackageResolutionTest
391
391
with WithNullSafetyMixin {
392
+ test_functionExpression_emptyBody () async {
393
+ await _assertCanBeAnalyzed (r'''
394
+ var v = <T>();
395
+ ''' );
396
+ }
397
+
392
398
test_issue_40837 () async {
393
399
await _assertCanBeAnalyzed ('''
394
400
class A {
You can’t perform that action at this time.
0 commit comments