You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An extension type on Future that implements Future can be assigned to FutureOr, as far as the analyzer is concerned, but not as far as the compiler is concerned:
import"dart:async";
voidmain() async {
// analyzer is ok with assigning a `Foo` to `FutureOr<int>`;// compilers (compileDDC, dart2js) give an error herefinalFutureOr<int> x =Foo(Future(() =>123));
// use itprint(x isFuture<int> ? (await x) : x);
}
extension typeFoo(Future<int> rep) implementsFuture<int> {}
Personally, I would prefer it be allowed, if it isn't too much trouble.
The text was updated successfully, but these errors were encountered:
@sgrekhov, I think it would be useful to take a look at this and see why we don't have a test that catches this case. I noticed that the other union type does not get the same treatment:
// ignore_for_file: unused_local_variablevoidmain() async {
finalint? iq =Bar(42);
int j = iq isint? iq :24; // OK.
}
extension typeBar(int _) implementsint {}
An extension type on Future that implements Future can be assigned to FutureOr, as far as the analyzer is concerned, but not as far as the compiler is concerned:
Personally, I would prefer it be allowed, if it isn't too much trouble.
The text was updated successfully, but these errors were encountered: