Ensure that __context__ is set up for provider overrides

This fixes #4417.