Skip to content
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

Dottydoc fails to read scala.scalajs.js.Promise.then symbol in 3.1.0 and 3.0.2 #14143

Closed
raquo opened this issue Dec 20, 2021 · 5 comments
Closed

Comments

@raquo
Copy link
Contributor

raquo commented Dec 20, 2021

This seems similar to #11943 but that issue was closed a while ago saying that "this should be fixed in 3.0.1-RC1 / sbt 1.5.3". I use higher versions than those, but I'm still running into it (or a separate, similar issue).

Compiler version

Scala 3.0.2
Scala.js 1.8.0
sbt 1.5.3, 1.5.7, 1.6.0-RC2

Minimized example

def p: js.Promise[A] = ???
def onFulfilled: js.Function1[A, Unit | js.Thenable[Unit]] = ???
def onRejected: js.Function1[Any, Unit | scala.scalajs.js.Thenable[Unit]] = ???

p.`then`[Unit](
  onFulfilled,
  js.defined(onRejected)
)

Output

sbt doc:

[info] Setting Scala version to 3.0.2 on 1 projects.
[info] Reapplying settings...
[info] set current project to Airstream (in build file:/.../airstream/)
[info] compiling 1 Scala source to /.../airstream/target/scala-3.0.2/classes ...
[info] Main Scala API documentation to /.../airstream/target/scala-3.0.2/api...
[info] Skipping unused scalacOptions: -language, -scalajs-mapSourceURI
[error] -- Error: src/main/scala/com/raquo/airstream/timing/JsPromiseEventStream.scala:57:6
[error] 57 |      p.`then`[Unit](
[error]    |      ^^^^^^^^^^^^^
[error]    |undefined: p.then # -1: TermRef(AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scalajs)),object js),class Promise),List(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class airstream)),object timing),class JsPromiseEventStream)),type A))),then) at readTasty
[error] one error found
[error] (Compile / doc) DottyDoc Compilation Failed
[error] Total time: 2 s, completed Dec. 20, 2021, 12:17:22 a.m.

Expectation

Since the code compiles, it should be doc-ed without error. Scala 2.13.7 produces no error.

EDIT: original text of the issue had a bit of mismatch between two test runs, I fixed it now.

@pikinier20
Copy link
Contributor

pikinier20 commented Dec 20, 2021

Yes, we had a problem with documenting scala.js projects on 3.0.2.
Take a look at unused options: there's the -scalajs flag which we didn't support.

Could you please check if the problem remains on 3.1.0? IIRC in this version we added the support for scala.js then.

@raquo
Copy link
Contributor Author

raquo commented Dec 21, 2021

3.1.0 seems to be the same:

[info] Setting Scala version to 3.1.0 on 1 projects.
[info] Reapplying settings...
[info] set current project to Airstream (in build file:/.../airstream/)
[info] compiling 110 Scala sources to /.../airstream/target/scala-3.1.0/classes ...
[info] Main Scala API documentation to /.../airstream/target/scala-3.1.0/api...
[info] Skipping unused scalacOptions: -language, -scalajs-mapSourceURI
[error] -- Error: src/main/scala/com/raquo/airstream/timing/JsPromiseEventStream.scala:57:6
[error] 57 |      p.`then`[Unit](
[error]    |      ^^^^^^^^^^^^^
[error]    |undefined: p.then # -1: TermRef(AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scalajs)),object js),class Promise),List(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class airstream)),object timing),class JsPromiseEventStream)),type A))),then) at readTasty
[error] one error found
[error] (Compile / doc) DottyDoc Compilation Failed
[error] Total time: 21 s, completed Dec. 20, 2021, 4:44:10 p.m.

@raquo raquo changed the title Dottydoc fails to read scala.scalajs.js.Promise.then symbol in 3.0.2 Dottydoc fails to read scala.scalajs.js.Promise.then symbol in 3.1.0 and 3.0.2 Dec 21, 2021
@pikinier20
Copy link
Contributor

I've done some debugging and it seems that this problem is not directly related to Scaladoc. The error comes from -from-tasty compilation which is ran by Scaladoc. I've already created another bug report #14178.

@pikinier20
Copy link
Contributor

I would like to mention here that I found solution for this issue. You just need to bump sbt to at least 1.5.3 and Scala to at least 3.1.0. The code snippet that you pasted compiles successfully with this configuration.

@raquo
Copy link
Contributor Author

raquo commented Dec 28, 2021

Thanks for looking at this, @pikinier20, and sorry it turned out to be a non-issue.

From what you've said about the scalac options, I was able to piece together what's wrong with my code: a few months ago, back when 3.0.0 was first released, dottydoc did not support scala.js, so I used the workaroud suggested here which removed unsupported options from the doc command, including -scalajs (duh...). Adding it back solves the error on scala 3.1.0 / sbt 1.5.3+

That lack of scalajs option didn't really register with me as something that would cause a problem because everything was apparently working fine without it (I didn't actually look at the output of doc, it's only called incidentally when publishing, so I don't know, maybe it was messed up somehow).

The error I reported only started recently, when I started using the js.Promise.then method. I'm not sure what's special about that particular method to have triggered the error, I'm using many other scalajs types and methods such as js.Array and js.UndefOr without issue, and none of them trigger the error even when the -scalajs option is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants