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
classA {}
classBimplementsA {}
// Works fine...listOf<A>(A()).minus(listOf<A>(B()));
// _TypeError (type 'A' is not a subtype of type 'B' of 'element')listOf<A>(A()).minus(listOf<B>(B()));
// Not sure why but this one will throw as well.listOf<A>(A()).minus(listOf<B>(B()).cast<A>());
// This one works, though.// ignore: unnecessary_castlistOf<A>(A()).minus(listOf<B>(B()).map((element) => element asA));
Shouldn't all of these work?
Relevant stack trace:
The reason why I'm asking is actually Dart's type inference. Depending on how the type is inferred, seemingly similar code might or might not work.
Type inferred from the
minus()
signature - works fine:Type inferred from the
listOf()
signature - won't work:I tried to find what exactly is going on but honestly, I'm lost :). I can write a test if needed, though. I'm on Dart 2.18.2.
The text was updated successfully, but these errors were encountered: