-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releaselegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Milestone
Description
The CFE currently allows an implicit call method tear-off even when the receiver of the implicit tear-off is a nullable type:
class C {
int call() => 0;
}
void main() {
int Function() c0 = (null as C?); // Should be an error
int Function()? c1 = (null as C?); // Should be an error
print(c0);
print(c1);
}Note that the first line is simply unsound. Both statements seem to evaluate to null.
For reference, I am proposing the following addition to the NNBD spec to cover this:
The implicit tear-off conversion which converts uses of instances of classes
with call methods to the tear-off of their `.call` method when the context type
is a function type is performed when the context type is a function type, or the
nullable version of a function type.
Implicit tear-off conversion is *not* performed on objects of nullable type,
regardless of the context type.
Metadata
Metadata
Assignees
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releaselegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.