Handle conflicting import of items declared in the same module

Fixes #19498