diff options
Diffstat (limited to 'src/library/scala/ref/SoftReference.scala')
-rw-r--r-- | src/library/scala/ref/SoftReference.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/library/scala/ref/SoftReference.scala b/src/library/scala/ref/SoftReference.scala index 5d4d470c6a..1026a85023 100644 --- a/src/library/scala/ref/SoftReference.scala +++ b/src/library/scala/ref/SoftReference.scala @@ -16,8 +16,11 @@ package scala.ref class SoftReference[+T <: AnyRef](value : T, queue : ReferenceQueue[T]) extends ReferenceWrapper[T] { def this(value : T) = this(value, null); val underlying: java.lang.ref.SoftReference[_ <: T] = - if (queue == null) new java.lang.ref.SoftReference[T](value); - else new java.lang.ref.SoftReference[T](value, queue.underlying.asInstanceOf[java.lang.ref.ReferenceQueue[T]]) - if (queue != null) - queue.register(this) + new SoftReferenceWithWrapper[T](value, queue, this) } + +/** + * @author Philipp Haller + */ +private class SoftReferenceWithWrapper[T <: AnyRef](value: T, queue: ReferenceQueue[T], val wrapper: SoftReference[T]) + extends java.lang.ref.SoftReference[T](value, if (queue == null) null else queue.underlying.asInstanceOf[java.lang.ref.ReferenceQueue[T]]) with ReferenceWithWrapper[T] |