Skip to content

Scaladoc: reported type of Map#map #14511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmgimeno opened this issue Feb 18, 2022 · 4 comments · Fixed by #14565
Closed

Scaladoc: reported type of Map#map #14511

jmgimeno opened this issue Feb 18, 2022 · 4 comments · Fixed by #14565
Assignees
Milestone

Comments

@jmgimeno
Copy link

The type reported for Map#map in the docs accessible from https://scala-lang.org/api/3.x/scala/collection/immutable/Map.html#map-fffffcb7 is

def map[K2, V2](f: (K, V) => (K2, V2)): Map[K2, V2]

but, if we go to its definition in the linked source file https://github.com/scala/scala/blob/v2.13.6/src/library/scala/collection/Map.scala#L299 we find that the real type is

def map[K2, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2]

which, at least, I find it very confusing.

If I understand untupling correctly, the magic that allows calling a function which receives a tuple with a function with various parameters occurs at the call-site, so the documented type of the method should not change (or maybe this issue in the documentation has nothing to do with it).

@jmgimeno jmgimeno added the stat:needs triage Every issue needs to have an "area" and "itype" label label Feb 18, 2022
@pikinier20
Copy link
Contributor

The map method is defined in trait MapOps which takes a type parameter named CC. The docs that you provided lead to scala.collection.immutable.Map which mixins MapOps and applies type Map[K, V] in place of CC. Therefore, I think the shown type is ok.

Scaladoc 2 does the same: Map.map

@jmgimeno
Copy link
Author

I know there is another version of map but the problem I report is that the shown type in the documentation does not match the type in the implementation. The type of the parameter changes.

@griggt
Copy link
Contributor

griggt commented Feb 18, 2022

def map[K2, V2](f:  (K, V)  => (K2, V2)): Map[K2, V2]
def map[K2, V2](f: ((K, V)) => (K2, V2)): CC[K2, V2]
                   ^^^^^^^^

@pikinier20
Copy link
Contributor

pikinier20 commented Feb 18, 2022

Oh, sorry. I missed that. Now I found a place in Scaladoc where we omit brackets if the type matches some criteria. Probably it's the source of bug.

@pikinier20 pikinier20 added area:doctool itype:bug and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 18, 2022
@pikinier20 pikinier20 self-assigned this Feb 25, 2022
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants