SI-6863 root cause fixed using factory of scala.runtime.*Ref

This PR supercedes https://github.com/scala/scala/pull/2460

review by @JamesIry or @retronym