-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
In advance: I didn't write this code and I'm not a confident user of the scala compiler. But this behaviour was perplexing for me.
Compiler version
3.3.1
Minimized code
trait Accumulator[T <: BigInt | BigDecimal] {
def observe(n:T):Accumulator[T]
def observe(bi: BigInt): Accumulator[T]
}
class DiscreteAccumulator extends Accumulator[BigInt] {
override def observe(bi:BigInt):DiscreteAccumulator = ???
}
Output (click arrow to expand)
As part of the sbt project. I see this.
sbt:slash> compile
[info] compiling 56 Scala sources to /Users/simon/Code/vector/slash/js/target/scala-3.3.1/classes ...
[info] compiling 56 Scala sources to /Users/simon/Code/vector/slash/native/target/scala-3.3.1/classes ...
[info] compiling 58 Scala sources to /Users/simon/Code/vector/slash/jvm/target/scala-3.3.1/classes ...
unhandled exception while running extractSemanticDB on /Users/simon/Code/vector/slash/shared/src/main/scala/slash/accumulation/Accumulator.scala
An unhandled exception was thrown in the compiler.
Please file a crash report here:
https://github.com/lampepfl/dotty/issues/new/choose
while compiling: <no file>
during phase: <no phase>
mode: Mode(ImplicitsEnabled,ReadPositions)
library version: version 2.13.10
compiler version: version 3.3.1
When I minimise with scala-cli, I get this - which I believe to be the same thing.
If this code is copied into a file named "acc.scala"
scala-cli compile acc.scala
- success
scala-cli compile /Users/simon/Code/vector/slash/shared/src/main/scala/slash/accumulation/Accumulator.scala -O semantic-db
- compiles fine, which makes me doubt whether or not this is really a compiler bug.
scala-cli compile acc.scala --semantic-db
- error
Error compiling project (Scala 3.3.1, JVM (21))
Error: Unexpected error when compiling accumulation_09379ba6b4-4d2c52f5ef: 'Failure to disambiguate overloaded reference with
method observe in trait Accumulator: (bi: BigInt): slash.accumulation.Accumulator[T] and
method observe in trait Accumulator: (n: T): slash.accumulation.Accumulator[T]'
Compilation failed
tanishiking