Skip to content

"Double definition: final def ...$$outer" when compiling with Scala.js (but not with the JVM backend) #10177

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
smarter opened this issue Nov 5, 2020 · 2 comments

Comments

@smarter
Copy link
Member

smarter commented Nov 5, 2020

This is not minimized but can be reproduced in the scalacheck repo, I'm hoping @sjrd can figure out what this is anyway 😅 :

git clone https://github.com/smarter/scalacheck/ -b 3.0.0-M1-and-scalajs
cd scalacheck
sbt "++3.0.0-M1 js/compile"

Output

[...]
[error] -- [E120] Naming Error: /home/smarter/opt/scalacheck/src/main/scala/org/scalacheck/commands/Commands.scala:98:8
[error] 98 |  trait Command {
[error]    |        ^
[error]    |Double definition:
[error]    |final def org$scalacheck$commands$Commands$Command$$$outer
[error]    |  (): org.scalacheck.commands.Commands in class CommandSequence at line 98 and
[error]    |final def org$scalacheck$commands$Commands$Command$$$outer
[error]    |  (): org.scalacheck.commands.Commands in class CommandSequence at line 98
[error]    |have the same type after erasure.
[error] -- [E120] Naming Error: /home/smarter/opt/scalacheck/src/main/scala/org/scalacheck/commands/Commands.scala:137:8
[error] 137 |  trait SuccessCommand extends Command {
[error]     |        ^
[error]     |Double definition:
[error]     |final def org$scalacheck$commands$Commands$SuccessCommand$$$outer
[error]     |  (): org.scalacheck.commands.Commands in class CommandSequence at line 137 and
[error]     |final def org$scalacheck$commands$Commands$SuccessCommand$$$outer
[error]     |  (): org.scalacheck.commands.Commands in class CommandSequence at line 137
[error]     |have the same type after erasure.
@sjrd
Copy link
Member

sjrd commented Nov 5, 2020

Ouch, that does not look good :(

Workaround, since ScalaCheck does not have any non-native JS type anyway: add the following to the settings of the js project:

scalacOptions ++= if (scalaVersion.value == "3.0.0-M1") Seq("-Yskip:explicitJSClasses") else Nil,

@sjrd
Copy link
Member

sjrd commented Nov 5, 2020

Here is a minimization:

class OuterClass { // can also be trait
  trait ParentTrait { // must be trait, can be private
    def concreteMethod(x: Int): Int = x // must have a concrete method
  }

  private class ChildClass extends ParentTrait // must be class *and* private
}

It requires a private class extending a trait with a concrete method, both in an enclosing class or trait.

@sjrd sjrd added this to the 3.0.0-M2 milestone Nov 5, 2020
@sjrd sjrd closed this as completed in 03b06cd Nov 5, 2020
sjrd added a commit that referenced this issue Nov 5, 2020
…n-of-outer-pointer

Fix #10177: Test `@JSType` in `isJSType` instead of using time travel.
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 5, 2020
Testing the Scala.js support is a good idea since if we had done it
before we would have caught scala#10177 sooner.
smarter added a commit to smarter/dotty that referenced this issue Nov 25, 2020
Testing the Scala.js support is a good idea since if we had done it
before we would have caught scala#10177 sooner.
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