Closed
Description
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.