Similar to https://github.com/scala/scala/pull/6093 but should be done in a mini-phase if possible.