[backport] Fix SI-6637 (misoptimization in erasure)

commit f9ef5300ab561628e53c654df9000c75f488d74a
Author: Jan Niehusmann <jan@gondor.com>
Date:   Fri Nov 9 15:05:58 2012 +0100

    Fix SI-6637 (misoptimization in erasure)

    Move the optimization one level deeper so the expression
    being tested with isInstanceOf is always evaluated.
    (cherry picked from commit b540aaee4ba30e2dd980456a44e8c6d732222df1)
Merge pull request #1952 from retronym/backport/1599

[backport] Fix SI-6637 (misoptimization in erasure)