Skip to content

Extend type test expression to accept instance of Type in addition to type name #8184

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

Closed
scheglov opened this issue Jan 29, 2013 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@scheglov
Copy link
Contributor

I.e. now this works:
print(v is MyObject);

But this - not.
Type t = MyObject;
print(v is t);

v.runtimeType == MyObject is not enough, I'd like to check also subclasses of MyObject.

@gbracha
Copy link
Contributor

gbracha commented Jan 29, 2013

We are considering this for constant variables.


Added Accepted label.

@scheglov
Copy link
Contributor Author

Hm... Constant variables is too restrictive for my needs.
I need it to make work code like this:

  Element getAncestor(Type elementType) {
    Element ancestor = enclosingElement;
    while (ancestor != null && ancestor is! elementType) {
      ancestor = ancestor.enclosingElement;
    }
    return ancestor;
  }

Where "elementType" is something like "MethodElement" and actual types of "ancestor" and "enclosingElement" are "MethodElementImpl", "CompilationUnitImpl", etc.

@lrhn
Copy link
Member

lrhn commented Aug 26, 2013

Removed Type-Defect label.
Added Type-Enhancement label.

@scheglov scheglov added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 26, 2013
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@munificent
Copy link
Member

Marking this as a dupe of the newer bug (#27680) since that one has a little more discussion.

@munificent munificent added the closed-duplicate Closed in favor of an existing report label Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants