The problem (as you've correctly identified) is that because the left hand side argument is of type T, when you pass an optional into it T will be inferred to be Optional<Whatever>. Because the right hand side argument is T? (and because types can be freely promoted to optionals), it will infer the type to be Optional<Optional<Whatever>>, leading to the confusing double wrapping you're observing.

The solution is to add an overload to deal with the situation when the left hand side argument is also an optional.

Now if you use this operator with an optional as the left handed argument, Swift will use the overloaded version instead of the original version, as it'll always favour the more type-specific signature. This means that the right hand side won't get wrapped in a double optional, as it's now of the exact same type as the left hand side argument.

Note that this is similar to what the ?? does, it has two definitions to deal with one side being optional, one side being non-optional & both sides being optional in order to avoid the generation of double wrapped optionals: