New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeMirror.isTopLevel and TypeMirror.owner for dynamic and void #11569
Comments
Added Accepted label. |
On a similar note: Where is Null defined? |
I think for dynamic and void having a null owner is a plausible answer, as these are rather special constructs. And so the spec for isTopLevel might have to be adjusted. Regarding comment #2 (which seems to be a very different topic) - null is not an instance of Object, even if the VM exposes its implementation by saying so! I believe we want to hide Null from users so they cannot write x is Null, allowing some optimizations to be undetectable by user code. And so Null might in practice be implemented as a private class, or even kept entirely hidden inside the implementation of the VM or dart2js. We still need to decide how to safely expose it in the mirror system. |
A class is not a good model for a function type, and consequently you cannot get rid of TypeMirror. However, I agree that it unfortunate that we do not model null as a regular object. It seems like an unfortunate special case. But please do not spam our bug database with questions that belong on our user forums. When used as an expression, "dynamic" is a type literal that evaluates to an object that implements Type. This object is an instance of Object, but not an instance of String. |
Just for the record, we have already changed our mind about null since Gilad's comment from July. You can write "x is Null" and it will only succeed for the null object (but then you could, and should, just write "x == null" anyway). The only leftover special-casing is the inability to throw null. Maybe it'll go away in 2.0 :) The void and dynamic types are special types. There are no objects that are instances of them - they are not classes, just types - and they are not declared in any library. |
Deleted comment #5, #8, and #9 as they belong in a different forum. |
What is the owner of dynamic and void?
The VM says null, but also say that they are isTopLevel. But isTopLevel is specified as:
* This is defined to be equivalent to:
* [:mirror.owner != null && mirror.owner is LibraryMirror:]
The text was updated successfully, but these errors were encountered: