Skip to content

nnbd: function?.call() must be null-checked #40482

Closed
@sortie

Description

@sortie

The analyzer doesn't appear to correctly handle a null checked call on a Function? in the following program:

Function? foo;

main() {
  foo?.call();
}

It produces the following analyzer errors:

Analyzing test.dart...
  error • The expression is nullable and must be null-checked before it can be used. • test.dart:3:3 • unchecked_use_of_nullable_value
1 error found.

These calls are supposed to work after talking to @lrhn and @eernstg.

The issue occurs for me at 43b69d4.

This issue blocks getting dart:_http clean of analyzer errors in NNBD mode as it has two such calls.

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD ReleaseP1A high priority bug; for example, a single project is unusable or has many test failureslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions