The following program resolves an extension on T? to an int? receiver, which should result in T being resolved to int, and hence the return type of foo being int:
extension Test<T> on T? {
T get foo => this!;
}
void main() {
int? a;
a.foo.isEven;
}
The analyzer currently emits an incorrect error on this indicating that the return type of foo is nullable.
leafp-macbookpro:tmp leafp$ /Users/leafp/src/dart-repo/sdk/xcodebuild/ReleaseX64NNBD/dart-sdk/bin/dartanalyzer --enable-experiment=non-nullable ~/tmp/test4.dart
Analyzing /Users/leafp/tmp/test4.dart...
error • The expression is nullable and must be null-checked before it can be used. • test4.dart:26:3 • unchecked_use_of_nullable_value
The following program resolves an extension on
T?
to anint?
receiver, which should result inT
being resolved toint
, and hence the return type offoo
beingint
:The analyzer currently emits an incorrect error on this indicating that the return type of
foo
is nullable.cc @scheglov