Skip to content

instanceof check for interfaces is static, not dynamic #2577

Closed
@CountBleck

Description

@CountBleck

Compare and contrast the following two snippets of code: <Object> instanceof <class> and <Object> instanceof <interface>

The former snippet works as expected: the hiya export calls an instanceof helper, which then checks the ID at runtime.
The latter snippet does not work as expected: the hiya export returns false, because the instanceof is incorrectly checked at compile-time.

To fix this bug, the latter snippet should also perform the check at runtime. In other words, <type> instanceof <interface> with a <type> that doesn't implement <interface> should be checked at runtime, because its subclasses can implement it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions