You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scala.js: Remove spurious js.AsInstanceOf around js.LinkTimeIf.
When B <: A and C <: A, `linkTimeIf[A](cond) { B }{ C }` would
generate an `.asInstanceOf[A]` that casts the resulting value to a
supertype. However, this cast is redundant, as the linker will
prune one branch at link time, and the remaining expression is
already known to be a compatible type.
This commit eliminates the surrounding `.asInstanceOf` around the
`linkTimeIf[T]` when both `thenp` and `elsep` are known to be
subtypes of `T`. The optimizer already routinely performs this
optimization. However, that comes too late for the module instance
field alias analysis performed by `IncOptimizer`. In that case,
while the desugarer removes the `LinkTimeIf`, the extra
`AsInstanceOf` prevents aliasing the field. Removing the cast ahead
of time in the compiler allows field aliases to be recognized in
the presence of `LinkTimeIf`s.
This commit is a forward port of the Scala.js commit
scala-js/scala-js@9bb267c
0 commit comments