-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Description
DurationBuilder is a leaky abstraction. Many methods will return a DurationBuilder, yet it is private. This makes adding any sugar on Duration and Period difficult (impossible?).
For example:
private val adapt = ((_:Any) match {
case interval: Interval => interval.toDuration
case period: Period => period.toStandardDuration
case other => other
})
def haveTheSameDurationAs(expected: Duration) = be_==(expected) ^^ adapt
def haveTheSameDurationAs(expected: Period) = be_==(expected.toStandardDuration) ^^ adapt
abutting.period must haveTheSameDurationAs(15.hours + 30.minutes) // compile errorBecause 15.hours + 30.minutes is a DuratonBuilder. What I need to define is:
def haveTheSameDurationAs(expected: DurationBuilder) = be_==(expected: Duration) ^^ adaptBut I cannot because DurationBuilder is private.
Another example of leaking:
val x = 10.hours + 5.hours
// What type is x? If we let IDEA tell us, we get
val x: DurationBuilder = 10.hours + 5.hours
// Which of course will not compileMetadata
Metadata
Assignees
Labels
No labels