You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjava.time.OffsetDateTimeimportscala.concurrent.duration.*valdateTime=OffsetDateTime.now()
implicitclassDateTimeOps(valdateTime:OffsetDateTime) extendsAnyVal {
defplus(amount: FiniteDuration):OffsetDateTime=
dateTime
}
dateTime plus Duration.Zero// ok
dateTime plus (if (true) Duration.ZeroelseDuration.Zero) // not ok
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).
The text was updated successfully, but these errors were encountered:
ghostdogpr
changed the title
Extension method not picked up when parameter is conditional
Extension method overload not picked up when parameter is conditional
May 5, 2024
Compiler version
3.4.1
Minimized code
Scastie: https://scastie.scala-lang.org/YNoWvmUYTHSWmgpHzWwj9A
Output
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 inOffsetDateTime
with different parameters).The text was updated successfully, but these errors were encountered: