scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.81k stars 1.05k forks source link

Scaladoc shows "shadowed implicit member" #15853

Open som-snytt opened 2 years ago

som-snytt commented 2 years ago

Compiler version

3.2.1-RC1-bin-20220805-e560c2d-NIGHTLY

Problem

def [<<](https://dotty.epfl.ch/api/scala/Long.html#%3C%3C-fffff788)(x: [Long](https://dotty.epfl.ch/api/scala/Long.html)): [Long](https://dotty.epfl.ch/api/scala/Long.html)
Implicitly added by [int2long](https://dotty.epfl.ch/api/scala/Int$.html#int2long-fffff0ab)

or

def <<(x: Long): Long Implicitly added by int2long

Expectation

Scaladoc 2 puts the "shadowed implicit" in a separate section and shows "int << long" as deprecated.

Scaladoc 3 does the reverse: puts the deprecated member in the deprecated section and shows the "shadowed implicit" in the list of member, with a note that it is added by implicit conversion.

This is especially confusing because of the combination of deprecation and shadowing. Ideally, perhaps, both are filtered out by default.

(I'm adding deprecation reporting while constant folding, so I know the situation, but I was still confused by the scaladoc.)

KacperFKorban commented 2 years ago

Could you add the exact declarations with the current scaladoc output and expected scaladoc output (or Scala 2 output vs Scala 3 output)?

som-snytt commented 2 years ago

The source text is https://github.com/scala/scala/blob/v2.13.8/src/library/scala/Int.scala#L58-L63

(That is generated by https://github.com/scala/scala/blob/2.13.x/project/GenerateAnyVals.scala)

The deprecated member returns an Int https://www.scala-lang.org/api/current/scala/Int.html#%3C%3C(x:Long):Int The shadowed member returns a Long https://www.scala-lang.org/api/current/scala/Int.html#%3C%3C(x:Long):Long

I can't seem to copy the chainlink icon in Scala3 at https://www.scala-lang.org/api/3.1.3/scala/Int.html

image

I think the confusing part is that Scala 3 suggests that there is an OK form, but actually you really select the deprecated form. (Hopefully, soon it will warn with deprecation in Scala 3.)