Skip to content

Generated bridge clashes with member of trait in Scala.js under Scala 3 #13127

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
Rich2 opened this issue Jul 22, 2021 · 5 comments
Closed

Generated bridge clashes with member of trait in Scala.js under Scala 3 #13127

Rich2 opened this issue Jul 22, 2021 · 5 comments

Comments

@Rich2
Copy link

Rich2 commented Jul 22, 2021

Scala 3.0.2-RC1 (And Scala 2.13.6)

I've attempted to minimise the code, but haven't been able to reproduce the bug in simplified code. I have therefore created a cut down repository here from my main repository with the minimum 2 modules required to produce the errors.

The code compiles for Jvm but is failing for Scala.js. There are 2 modules Util and Graphics. Util compiles under all 4 combinations of Js and jvm targets and Scala 2.13.6 and Scala 3.0.2-RC1. The graphics module fails for Scala.js on Scala 3 implicit lookup succeeds for JVM but fails for Js. In Sbt:

graphicsJvm2/compile //compiles
graphicsJvm3/compile //compiles
graphicsJs2/compile //compiles
graphicsJs3/compile //gives the following errors
sbt:jvmjs> graphicsJs3/compile
[info] compiling 177 Scala sources to /Common/jvmjs/graphicsJs3/target/scala-3.0.2-RC1/classes ...
[error] -- Error: /Common/jvmjs/srcGraphics/Trans/ProlignMatrix.scala:48:50 ------------
[error] 48 |    (arrA : Arr[A], prolignMatrix: ProlignMatrix) => arrA.map(a => ev.prolignObj(a, prolignMatrix))
[error]    |                                                  ^
[error]    |bridge generated for member method prolignObj(arrA: ostrat.Arr[A], prolignMatrix: ostrat.geom.ProlignMatrix): ostrat.Arr[A] in anonymous class Object with ostrat.geom.Prolign {...}
[error]    |which overrides method prolignObj(obj: A, prolignMatrix: ostrat.geom.ProlignMatrix): A in trait Prolign
[error]    |clashes with definition of the member itself; both have erased type (arrA: Object, prolignMatrix: ostrat.geom.ProlignMatrix): Object."
[error] -- Error: /Common/jvmjs/srcGraphics/Trans/Slate.scala:28:84 --------------------
[error] 28 |  implicit def arrImplicit[A](implicit ev: Slate[A]): Slate[Arr[A]] = (obj, dx, dy) => obj.smap(ev.SlateXYT(_, dx, dy))
[error]    |                                                                                    ^
[error]    |bridge generated for member method SlateXYT(obj: ostrat.Arr[A], dx: Double, dy: Double): ostrat.Arr[A] in anonymous class Object with ostrat.geom.Slate {...}
[error]    |which overrides method SlateXYT(obj: T, xDelta: Double, yDelta: Double): T in trait Slate
[error]    |clashes with definition of the member itself; both have erased type (obj: Object, dx: Double, dy: Double): Object."
[error] two errors found
[error] two errors found
[error] (graphicsJs3 / Compile / compileIncremental) Compilation failed
[error] Total time: 19 s, completed 22 Jul 2021, 09:13:01

Expectation is that the compile phase will be the same for Jvm and Js and also what compiles for Scala 2 will compile for Scala 3.

@Kordyjan Kordyjan changed the title Implicit lookup failing for Scala.js under Scala 3 Generated bridge clashes with member of triat in Scala.js under Scala 3 Jul 22, 2021
@Kordyjan Kordyjan changed the title Generated bridge clashes with member of triat in Scala.js under Scala 3 Generated bridge clashes with member of trait in Scala.js under Scala 3 Jul 22, 2021
@Kordyjan

This comment has been minimized.

@Kordyjan Kordyjan removed the stat:needs minimization Needs a self contained minimization label Jul 22, 2021
@Kordyjan
Copy link
Contributor

Kordyjan commented Jul 22, 2021

Minimal example, that passes when compiled to jvm but fails with js:

trait A[T]:
  def doA(arg1: T): T

class B[T](val arr: Array[T]) extends AnyVal

def a[T]: A[B[T]] =
  (arg1: B[T]) => null.asInstanceOf[B[T]]

It is worth noting that extends AnyVal is necessary here.

@sjrd
Copy link
Member

sjrd commented Jul 22, 2021

I'm on mobile right now, so I can't test. But I'm pretty sure this is not directly related to Scala.js, but rather to the fact that the SAM type is not a platform SAM type. I guess it can be reproduced on the JVM by using a SAM type that is not a JVM SAM type. For example:

class C

trait A[T] extends C:
// The rest as before

@smarter
Copy link
Member

smarter commented Jul 22, 2021

In which this is likely a duplicate of #11264

@Kordyjan
Copy link
Contributor

I'm on mobile right now, so I can't test. But I'm pretty sure this is not directly related to Scala.js, but rather to the fact that the SAM type is not a platform SAM type. I guess it can be reproduced on the JVM by using a SAM type that is not a JVM SAM type. For example:

class C

trait A[T] extends C:
// The rest as before

Confirmed, so it is unrelated to js.

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

4 participants