There are two types of types in Dart.
- Type of execution
- Static type
Here's the proof in the Dart Language Specification :
static type from null is lower.
- Execution Type
null - null - Static type
null - bottom
This means that objects in Dart can have two types of types.
One real type, called static and one virtual , which is called runtime .
That is, the null runtime type is not bottom , but a regular null class.
class Null { factory Null._uninstantiable() { throw new UnsupportedError('class Null cannot be instantiated'); } /** Returns the string `"null"`. */ String toString() => "null"; }
But at the same time, a value with this regular runtime type null can be assigned to any other type, because the real (static) type null is the bottom type.
What is the name of this method in Dart?
Type substitution or something else?
PS
This question is about static value types , but not about static variable types declared by type annotations.
This is because null not a variable, but value with a static type from bottom .
PS
A very interesting case (at least for me).
void main() { Null _null; String s = _null; }
I get a warning:
A value of type 'Null' cannot be assigned to a variable of type 'String'
This is absolutely correct. But at the same time it works.
Unusual thing with type replacement (static and runtime).