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
It is an error to call the default List constructor with a length argument and a type argument which is potentially non-nullable.
There are two conditions conbined with AND. It looks strange for me. Please consider the following code.
classA {}
classC<XextendsA?> {
X x;
C(this.x);
test() {
List l1 =newList<X>(); // type X is potentially non-nullable but no length argument specified. No error?List l2 =newList<X>(0); // type X is potentially non-nullable, argument specified. Is this an error then?List l3 =<X>[]; // what about this?var l4 =<X>[x]; // and this?
}
main() {
A? a =newA();
C<A?> c =newC<A?>(a);
c.test();
}
The text was updated successfully, but these errors were encountered:
Cf. discussions at the meeting yesterday: The problem is that the length argument implies that the new list should have that many elements, but a potentially non-nullable type argument does not allow for any values to be used (can't use null, and no other values can be used as a natural default value for an unknown type like X extends Object).
Also, List<X>(0) is an error even though it is safe, because the error check does not bother to discover that this particular argument value is safe; List<X>(1)must be an error because we can't obtain a value of type X out of the blue.
List<X>() is OK following the spec text on the error.
Finally, list literals are irrelevant, because this error is only concerned with explicit invocations of that particular List constructor.
Uh oh!
There was an error while loading. Please reload this page.
According to the NNBD spec
There are two conditions conbined with AND. It looks strange for me. Please consider the following code.
The text was updated successfully, but these errors were encountered: