Skip to content

DottyDoc fails on valid overloaded constructor with js.UndefOr[_] #12215

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
russwyte opened this issue Apr 25, 2021 · 4 comments
Closed

DottyDoc fails on valid overloaded constructor with js.UndefOr[_] #12215

russwyte opened this issue Apr 25, 2021 · 4 comments

Comments

@russwyte
Copy link

russwyte commented Apr 25, 2021

Compiler version 3.0.0-RC3

Minimized example

import scala.scalajs.js

class Foo(a: String, b: js.UndefOr[String]):
  def this(b: js.UndefOr[String]) = this("default", b)

Output

[error] -- Error: src/main/scala/Main.scala:4:41 ---------------------------------------
[error] 4 |  def this(b: js.UndefOr[String]) = this("default", b)
[error]   |                                         ^^^^^^^^^^^^^
[error]   |undefined: this # -1: TermRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),class Foo)),<init>) at readTasty
[warn] one warning found
[error] one error found

Expectation

This code compiles correctly - so it seems DottyDoc should handle it correctly.

@russwyte
Copy link
Author

russwyte commented Apr 25, 2021

@sjrd Interestingly - this similar code presents no issues with DottyDoc:

class Foo(a: String, b: Option[String]):
  def this(b: Option[String]) = this("default", b)

@griggt
Copy link
Contributor

griggt commented Apr 25, 2021

Looks like a duplicate of #11943

@russwyte
Copy link
Author

russwyte commented Apr 25, 2021

This also works fine - which seems really odd to me because it's exactly the equivalent type of js.UndefOr :)

import scala.annotation.unchecked.uncheckedVariance
type UO[+A] = (A @uncheckedVariance) | Unit
class Foo(a: String, b: UO[String]):
  def this(b: UO[String]) = this("default", b)

@griggt
Copy link
Contributor

griggt commented Jul 9, 2021

Closing since this is fixed in Scala 3.0.1-RC1 / sbt 1.5.3

@griggt griggt closed this as completed Jul 9, 2021
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

3 participants