Once we have NNBD, will the type signature of Object.toString() to be changed to enforce that all implementations must return a non-null String?
Or is it considered a desired feature that this method can indeed return null?
I would think it should be non-null, if only because of the behavior of string interpolation:
class Foo {
toString() => null;
}
void main() { print('${Foo(}'); }
Uncaught exception:
Invalid argument: Instance of 'Foo'
Ahh, I see you've referenced that in a similar issue
Yes. The return type of Object.toString will almost certainly be String (non-nullable).
(I can't imagine any issue that would change that, but then, you never know).
Great, thanks for clarifying!
Most helpful comment
Yes. The return type of
Object.toStringwill almost certainly beString(non-nullable).(I can't imagine any issue that would change that, but then, you never know).