I think you're running into this limitation of SE-0352: Implicitly Opened Existentials:
When
T
or aT
-rooted associated type appears in a non-covariant position in the result type,T
cannot be bound to the underlying type of an existential value because there would be no way to represent the type-erased result. This is essentially the same property as descibed for the parameter types that prevents opening of existentials, as described above. For example:func cannotOpen7<T: P>(_ value: T) -> X<T> { /*...*/ }
In your example, L
appears in non-covariant position in the function's return type (generic parameters in Swift aren't covariant, with a few hardcoded exceptions such as Array
), so this limitation applies.