@@ -178,7 +178,9 @@ private[concurrent] object Promise {
178
178
* DefaultPromises, and `linkedRootOf` is currently only designed to be called
179
179
* by Future.flatMap.
180
180
*/
181
- final class DefaultPromise [T ] extends AtomicReference [AnyRef ](Nil ) with Promise [T ] {
181
+ // Left non-final to enable addition of extra fields by Java/Scala converters
182
+ // in scala-java8-compat.
183
+ class DefaultPromise [T ] extends AtomicReference [AnyRef ](Nil ) with Promise [T ] {
182
184
183
185
/** Get the root promise for this promise, compressing the link chain to that
184
186
* promise if necessary.
@@ -248,12 +250,12 @@ private[concurrent] object Promise {
248
250
249
251
@ throws(classOf [TimeoutException ])
250
252
@ throws(classOf [InterruptedException ])
251
- def ready (atMost : Duration )(implicit permit : CanAwait ): this .type =
253
+ final def ready (atMost : Duration )(implicit permit : CanAwait ): this .type =
252
254
if (tryAwait(atMost)) this
253
255
else throw new TimeoutException (" Futures timed out after [" + atMost + " ]" )
254
256
255
257
@ throws(classOf [Exception ])
256
- def result (atMost : Duration )(implicit permit : CanAwait ): T =
258
+ final def result (atMost : Duration )(implicit permit : CanAwait ): T =
257
259
ready(atMost).value.get.get // ready throws TimeoutException if timeout so value.get is safe here
258
260
259
261
def value : Option [Try [T ]] = value0
@@ -265,7 +267,7 @@ private[concurrent] object Promise {
265
267
case _ => None
266
268
}
267
269
268
- override def isCompleted : Boolean = isCompleted0
270
+ override final def isCompleted : Boolean = isCompleted0
269
271
270
272
@ tailrec
271
273
private def isCompleted0 : Boolean = get() match {
@@ -274,7 +276,7 @@ private[concurrent] object Promise {
274
276
case _ => false
275
277
}
276
278
277
- def tryComplete (value : Try [T ]): Boolean = {
279
+ final def tryComplete (value : Try [T ]): Boolean = {
278
280
val resolved = resolveTry(value)
279
281
tryCompleteAndGetListeners(resolved) match {
280
282
case null => false
@@ -297,7 +299,7 @@ private[concurrent] object Promise {
297
299
}
298
300
}
299
301
300
- def onComplete [U ](func : Try [T ] => U )(implicit executor : ExecutionContext ): Unit =
302
+ final def onComplete [U ](func : Try [T ] => U )(implicit executor : ExecutionContext ): Unit =
301
303
dispatchOrAddCallback(new CallbackRunnable [T ](executor.prepare(), func))
302
304
303
305
/** Tries to add the callback, if already completed, it dispatches the callback to be executed.
0 commit comments