Generic function that requires the generic type to be non-optional

Yes, I thought of that too with 2 overloads. But that leads to another inconsistent behavior between non-generic function and generic function. Let me explain:

Say we have 2 strings, one optional, one non-optional:

let string: String = "Non-Optional String"
let optionalString: String? = "Optional String"

And a normal function func foo1:

func foo1(string: String) {
    print("Non-Optional String: \(string)")

Naturally, you can only pass string to foo1, and an error will prompt if you pass optionalString to it:

foo1(string: string) 
// prints the expected value

foo1(string: optionalString) 
// error: Value of optional type 'String?' must be unwrapped to a value of type 'String'

However, we can easily have another function foo2 to accept an Optional<String>:

func foo2(string: String?) {
    print("Optional String: \(string as Any)")

Apparently we can pass both to this function:

foo2(string: string) 
// prints the expected value

foo2(string: optionalString) 
// prints the unwrapped value or nil

So we can come up with a conclusion for a normal function that takes an Optional parameter: unlike other non-generic functions only accept a parameter of the type it requires, it accept 2 types, the Optional type and the type it wraps.

However for generic functions, this logic does not exist:

func bar1<Value>(value: Value) {
    print("value: \(value)")

func bar2<Value>(value: Value?) {
    print("value: \(value as Any)")

bar1(value: string) // correct
bar2(value: string) // correct, same as previous

bar1(value: optionalString) // correct
bar2(value: optionalString) // correct, same as previous

In the examples above, function bar1 and bar2 are the same thing with a different (or is it?) implementation.

So it is clear for us to see, when it comes to generic type, Value and Value? represent the same thing, which is any type including Optional. And I can understand that, the Optional is just an another type after all, it only makes sense to make it a generic target type. But humbly I have to ask, is it correct?

First, it brings redundancy and ambiguity as the example given above shows where function bar1 and bar2 are the same expression.

Second, it breaks the consistency that we have learnt and got used to from the normal function, which is, when we see a parameter has a type without a "?" suffix, we know the parameter has to be unwrapped before being passed to the function; on the other hand, when we do see the "?" suffix, we know it accept 2 types, the Optional type and the type it wraps.

Finally, it omits the possibility to perform the delicate control over the generic type requirement. For a normal function, we can easily require the parameter to be non-optional, but we can not do such thing for generic function, because a generic type almost always include Optional.