You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as a suggested type signature, which may led the user into thinking that the function accepts existential protocol types instead of a unique type "T: Comparable" in both the arguments and result (see attached image, P1 and P2 are protocols, C1 is a class).
It may be more useful to show
max<T: Comparable>(_ x: T, _ y: T)-> T
as suggested type signature, although less readable.
We have the same issue when typing in the function body:
protocolSomeProtocol{}classSomeClass{}func foo<T:Collection>(_ x:T){
x // suggested as "x: Collection" instead of "x: T"}func bar<T:SomeClass&SomeProtocol>(_ x:T){
x // suggested as "x: SomeProtocol" instead of "x: T" }
The text was updated successfully, but these errors were encountered:
Fwiw, I agree with your point; the two types are different and conflating them is not the way to go. Maybe it looks cleaner, but it's conceptually incorrect, which is a negative for something that is presented frequently to a developer.
The link above describes a real-world situation in which the current behavior actively misled a user to believe that they were using an existential type when they were not. Given the pervasive misunderstanding of existentials and generics, this sort of mixup is, arguably, actively confusing users and steering them into the wrong path.
Attachment: Download
Additional Detail from JIRA
md5: 082a2c11b6e53a2c078c70bdfa52294a
Issue Description:
Currently, when typing
max
you getas a suggested type signature, which may led the user into thinking that the function accepts existential protocol types instead of a unique type "
T: Comparable"
in both the arguments and result (see attached image,P1
andP2
are protocols,C1
is a class).It may be more useful to show
as suggested type signature, although less readable.
We have the same issue when typing in the function body:
The text was updated successfully, but these errors were encountered: