scala / scala3

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

doc fails to read scala.scalajs.js.Promise.then symbol #20476

Open MartinHH opened 4 months ago

MartinHH commented 4 months ago

This seems similar to #14143, but the affected scala versions are much newer and the bug does not occur when downgrading to scala 3.3.1:

Compiler version

scala 3.3.3 ; 3.4.0 ; 3.4.1 ; 3.4.2

scala-js 1.16.0 sbt 1.10.0

Minimized code

package demo

import scala.scalajs.js

def bar: js.Promise[Int] = js.Promise.resolve(()).`then`(_ => 1)
# plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
# build.sbt
ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "3.3.3" // or any of 3.4.0 to 3.4.2

lazy val root = (project in file("."))
  .enablePlugins(ScalaJSPlugin)
  .settings(
    name := "doc_bug_report"
  )

Output

[IJ]doc
[info] compiling 1 Scala source to /redacted/doc_bug_report/target/scala-3.3.3/classes ...
[info] done compiling
[info] Main Scala API documentation to /redacted/doc_bug_report/target/scala-3.3.3/api...
-- Error: src/main/scala/demo/demo.scala:5:27 ----------------------------------
5 |def bar: js.Promise[Int] = js.Promise.resolve(()).`then`(_ => 1)
  |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |undefined: $1$.then # -1: TermRef(TermRef(NoPrefix,val $1$),then) at readTasty
1 error found
[info] Main Scala API documentation successful.
[success] Total time: 0 s, completed 27.05.2024, 10:08:40

Expectation

No error occurs (as with scala 3.3.1).

Gedochao commented 4 months ago

Reproduction with Scala CLI:

//> using platform js
//> using scala 3.3.2
import scala.scalajs.js
def bar: js.Promise[Int] = js.Promise.resolve(()).`then`(_ => 1)
scala-cli doc repro.scala      
# Starting compilation server
# Compiling project (Scala 3.3.2, Scala.js 1.16.0)
# Compiled project (Scala 3.3.2, Scala.js 1.16.0)
# -- Error: repro.scala:4:27 -----------------------------------------------------
# 4 |def bar: js.Promise[Int] = js.Promise.resolve(()).`then`(_ => 1)
#   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#   |undefined: $1$.then # -1: TermRef(TermRef(NoPrefix,val $1$),then) at readTasty
# 1 error found

Last good stable version: 3.3.1 First breaking stable version: 3.3.2

Florian3k commented 5 days ago

Bisect: Last good release: 3.3.2-RC1-bin-20230615-916d4e7-NIGHTLY First bad release: 3.3.2-RC1-bin-20230619-a68568c-NIGHTLY

Reverting https://github.com/scala/scala3/pull/18989 seems to fix this (on LTS branch at least)