Runtime part of issue 10023.

Depends on https://github.com/D-Programming-Language/dmd/pull/2271.