- Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Milestone
Description
Compiler version
3.4.1
Minimized code
import java.time.OffsetDateTime import scala.concurrent.duration.* val dateTime = OffsetDateTime.now() implicit class DateTimeOps(val dateTime: OffsetDateTime) extends AnyVal { def plus(amount: FiniteDuration): OffsetDateTime = dateTime } dateTime plus Duration.Zero // ok dateTime plus (if (true) Duration.Zero else Duration.Zero) // not ok
Scastie: https://scastie.scala-lang.org/YNoWvmUYTHSWmgpHzWwj9A
Output
Found: (scala.concurrent.duration.Duration.Zero : scala.concurrent.duration.FiniteDuration) Required: java.time.temporal.TemporalAmount
Expectation
The same code compiles well with Scala 2: https://scastie.scala-lang.org/lfVKMgn4RRWpelXheh5rjQ
I tried using extension
but the result is the same.
Note that this happens when there is already a method of the same name defined on the class (plus
in my example exists in OffsetDateTime
with different parameters).