SI-6913 Reapplies a lost fix by @viktorklang

https://issues.scala-lang.org/browse/SI-6913

This somehow got lost. Thanks to @rkuhn for pointing it out.