Skip to content

Handle instanceof of entire classes #1108

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

Merged
merged 1 commit into from
Feb 14, 2020
Merged

Handle instanceof of entire classes #1108

merged 1 commit into from
Feb 14, 2020

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Feb 12, 2020

This is an initial implementation of instanceof CLASS checks like

a instanceof Array
a instanceof Map
a instanceof Set

Does static checks where possible, except in upcast cases like

class Parent<T> {}
class Child<T> extends Parent<T> {}

var a: Parent<i32> = new Child<i32>();
if (a instanceof Child) {
  ...
}

where an internal helper, here named Child~instanceof, is generated and called, that checks against all possible concrete instance ids. For example, if there's a Child<i32> and a Child<f32> present in the module, both are valid according to the dynamic check. Dynamic checks are potentially costly if there are lots of instances of a generic class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant