scala / scala3

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

False double definition when using queries with Slick 3.5.0-M4 #18176

Closed mdedetrich closed 1 year ago

mdedetrich commented 1 year ago

Compiler version

Scala 3.3.0

Minimized code

Minimizing this is going to take quite a lot of time so I am reporting it now incase it gives someone initial ideas as to what may be causing the problem but this is the smallest snippet of code producing the issue so far https://github.com/mdedetrich/incubator-pekko-persistence-jdbc/blob/112d67b765c59c36e2e39a8ce21ca410441b17c5/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/scaladsl/JdbcDurableStateStore.scala#L202-L203, i.e.

private[jdbc] def maxStateStoreOffset(): Future[Long] =
  db.run(queries.maxOffsetQuery.result)

Output

When adding Scala 3 support to pekko-persistence-jdbc (see https://github.com/apache/incubator-pekko-persistence-jdbc/pull/44) using the newly release Slick Scala 3.5.0-M4 milestone which has Scala 3 support, any usage of Slick query (i.e. db.run(...) causes Scala 3 compiler to produce

[error] -- [E120] Naming Error: /Users/mdedetrich/github/incubator-pekko-persistence-jdbc/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/scaladsl/JdbcDurableStateStore.scala:201:20 
[error] 201 |  private[jdbc] def maxStateStoreOffset(): Future[Long] =
[error]     |                    ^
[error]     |Double definition:
[error]     |private[jdbc] def maxStateStoreOffset(): concurrent.Future[Long] in class JdbcDurableStateStore at line 201 and
[error]     |private[jdbc] def maxStateStoreOffset(): concurrent.Future[Long] in class JdbcDurableStateStore at line 201
[error]     |have the same type after erasure.
[error]     |
[error]     |Consider adding a @targetName annotation to one of the conflicting definitions
[error]     |for disambiguation.

As you can see in the source code there is clearly only a single definition and both claimed double definitions in the error message also report to the same single line.

It seems that Scala 3 in this case is somehow creating duplicated symbols which is giving the false error?

Expectation

For it to compile without errors

mdedetrich commented 1 year ago

@nafg Pinging you here since its Slick related

mdedetrich commented 1 year ago

This error is a red herring, its in fact a result of another compiler bug that has been created at https://github.com/lampepfl/dotty/issues/18441