Adjust orphan rules to consider all input types, not just self type.

Adjust orphan rules to consider all input types, not just self type.

Fixes #18222.

r? @pcwalton