replace cast in window() by ascription

see https://issues.scala-lang.org/browse/SI-7818 for details