Skip to content
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

Closed
peter-ahe-google opened this issue Jun 27, 2013 · 6 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-mirrors type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@peter-ahe-google
Copy link
Contributor

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:]

@gbracha
Copy link
Contributor

gbracha commented Jun 27, 2013

Added Accepted label.

@lrhn
Copy link
Member

lrhn commented Jun 28, 2013

On a similar note: Where is Null defined?
(VM seems to say that "null" is just a dart.core.Object)

@gbracha
Copy link
Contributor

gbracha commented Jul 1, 2013

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.

@peter-ahe-google
Copy link
Contributor Author

@mezoni:

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.

@lrhn
Copy link
Member

lrhn commented Dec 2, 2013

Just for the record, we have already changed our mind about null since Gilad's comment from July.
The null object is an instance of the Null class, which is defined in dart:core, and which extends Object. It's the only instance of Null (the class has no generative constructor, and user code cannot implement the Null class).

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.

@peter-ahe-google
Copy link
Contributor Author

Deleted comment #­5, #­8, and #­9 as they belong in a different forum.

@peter-ahe-google peter-ahe-google added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-mirrors labels Dec 3, 2013
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-mirrors type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants