@@ -182,6 +182,7 @@ object Duration {
182
182
def compare (other : Duration ) = if (other eq this ) 0 else 1
183
183
def unary_- : Duration = this
184
184
def toUnit (unit : TimeUnit ): Double = Double .NaN
185
+ private def readResolve (): AnyRef = Undefined // Instructs deserialization to use this same instance
185
186
}
186
187
187
188
sealed abstract class Infinite extends Duration {
@@ -230,7 +231,7 @@ object Duration {
230
231
* but itself. This value closely corresponds to Double.PositiveInfinity,
231
232
* matching its semantics in arithmetic operations.
232
233
*/
233
- val Inf : Infinite = new Infinite {
234
+ val Inf : Infinite = new Infinite {
234
235
override def toString = " Duration.Inf"
235
236
def compare (other : Duration ) = other match {
236
237
case x if x eq Undefined => - 1 // Undefined != Undefined
@@ -239,6 +240,7 @@ object Duration {
239
240
}
240
241
def unary_- : Duration = MinusInf
241
242
def toUnit (unit : TimeUnit ): Double = Double .PositiveInfinity
243
+ private def readResolve (): AnyRef = Inf // Instructs deserialization to use this same instance
242
244
}
243
245
244
246
/**
@@ -251,6 +253,7 @@ object Duration {
251
253
def compare (other : Duration ) = if (other eq this ) 0 else - 1
252
254
def unary_- : Duration = Inf
253
255
def toUnit (unit : TimeUnit ): Double = Double .NegativeInfinity
256
+ private def readResolve (): AnyRef = MinusInf // Instructs deserialization to use this same instance
254
257
}
255
258
256
259
// Java Factories
0 commit comments