diff options
Diffstat (limited to 'src')
7 files changed, 16 insertions, 45 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 0198529ef7..90ac1f466d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1511,7 +1511,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans sym.isSourceMethod && sym.isCase && sym.name == nme.apply && - isClassTypeAccessible(tree) + isClassTypeAccessible(tree) && + !tree.tpe.resultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol) if (doTransform) { tree foreach { diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala index 9f9732c62f..e829a0215b 100644 --- a/src/library/scala/collection/convert/Wrappers.scala +++ b/src/library/scala/collection/convert/Wrappers.scala @@ -265,17 +265,11 @@ private[collection] trait Wrappers { def +=(kv: (A, B)): this.type = { underlying.put(kv._1, kv._2); this } def -=(key: A): this.type = { underlying remove key; this } - override def put(k: A, v: B): Option[B] = { - val r = underlying.put(k, v) - if (r != null) Some(r) else None - } + override def put(k: A, v: B): Option[B] = Option(underlying.put(k, v)) override def update(k: A, v: B) { underlying.put(k, v) } - override def remove(k: A): Option[B] = { - val r = underlying remove k - if (r != null) Some(r) else None - } + override def remove(k: A): Option[B] = Option(underlying remove k) def iterator: Iterator[(A, B)] = new AbstractIterator[(A, B)] { val ui = underlying.entrySet.iterator @@ -326,25 +320,15 @@ private[collection] trait Wrappers { * are not guaranteed to be atomic. */ case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] { - override def get(k: A) = { - val v = underlying get k - if (v != null) Some(v) - else None - } + override def get(k: A) = Option(underlying get k) override def empty = new JConcurrentMapWrapper(new juc.ConcurrentHashMap[A, B]) - def putIfAbsent(k: A, v: B): Option[B] = { - val r = underlying.putIfAbsent(k, v) - if (r != null) Some(r) else None - } + def putIfAbsent(k: A, v: B): Option[B] = Option(underlying.putIfAbsent(k, v)) def remove(k: A, v: B): Boolean = underlying.remove(k, v) - def replace(k: A, v: B): Option[B] = { - val prev = underlying.replace(k, v) - if (prev != null) Some(prev) else None - } + def replace(k: A, v: B): Option[B] = Option(underlying.replace(k, v)) def replace(k: A, oldvalue: B, newvalue: B): Boolean = underlying.replace(k, oldvalue, newvalue) @@ -380,25 +364,16 @@ private[collection] trait Wrappers { case class JDictionaryWrapper[A, B](underlying: ju.Dictionary[A, B]) extends mutable.AbstractMap[A, B] with mutable.Map[A, B] { override def size: Int = underlying.size - def get(k: A) = { - val v = underlying get k - if (v != null) Some(v) else None - } + def get(k: A) = Option(underlying get k) def +=(kv: (A, B)): this.type = { underlying.put(kv._1, kv._2); this } def -=(key: A): this.type = { underlying remove key; this } - override def put(k: A, v: B): Option[B] = { - val r = underlying.put(k, v) - if (r != null) Some(r) else None - } + override def put(k: A, v: B): Option[B] = Option(underlying.put(k, v)) override def update(k: A, v: B) { underlying.put(k, v) } - override def remove(k: A): Option[B] = { - val r = underlying remove k - if (r != null) Some(r) else None - } + override def remove(k: A): Option[B] = Option(underlying remove k) def iterator = enumerationAsScalaIterator(underlying.keys) map (k => (k, underlying get k)) diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 1ead894faf..1b52e40b72 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -217,8 +217,8 @@ self => pos = thisString.indexOf(separator, prev) } while (pos != -1) - if (prev != thisString.size) - res += thisString.substring(prev, thisString.size) + if (prev != thisString.length) + res += thisString.substring(prev, thisString.length) val initialResult = res.result() pos = initialResult.length diff --git a/src/library/scala/ref/WeakReference.scala b/src/library/scala/ref/WeakReference.scala index 6ee40aed5c..9dcc0bbe5f 100644 --- a/src/library/scala/ref/WeakReference.scala +++ b/src/library/scala/ref/WeakReference.scala @@ -28,10 +28,7 @@ object WeakReference { def apply[T <: AnyRef](value: T) = new WeakReference(value) /** Optionally returns the referenced value, or `None` if that value no longer exists */ - def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = { - val x = wr.underlying.get - if (x != null) Some(x) else None - } + def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = Option(wr.underlying.get) } /** diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index aa30887ba0..24c297a2fc 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -105,7 +105,7 @@ object Exception { case x if rethrow(x) => throw x case x if pf isDefinedAt x => pf(x) } - finally fin map (_.invoke()) + finally fin foreach (_.invoke()) /* Create an empty Try container with this Catch and the supplied `Finally`. */ def andFinally(body: => Unit): Catch[T] = fin match { diff --git a/src/reflect/scala/reflect/runtime/TwoWayCache.scala b/src/reflect/scala/reflect/runtime/TwoWayCache.scala index d0fc3dac74..6c1ca5b571 100644 --- a/src/reflect/scala/reflect/runtime/TwoWayCache.scala +++ b/src/reflect/scala/reflect/runtime/TwoWayCache.scala @@ -26,8 +26,7 @@ private[runtime] class TwoWayCache[J, S] { private object SomeRef { def unapply[T](optRef: Option[WeakReference[T]]): Option[T] = if (optRef.nonEmpty) { - val result = optRef.get.get - if (result != null) Some(result) else None + Option(optRef.get.get) } else None } diff --git a/src/reflect/scala/reflect/runtime/TwoWayCaches.scala b/src/reflect/scala/reflect/runtime/TwoWayCaches.scala index 6e2890e536..6ce0c0a728 100644 --- a/src/reflect/scala/reflect/runtime/TwoWayCaches.scala +++ b/src/reflect/scala/reflect/runtime/TwoWayCaches.scala @@ -26,8 +26,7 @@ private[runtime] trait TwoWayCaches { self: SymbolTable => private object SomeRef { def unapply[T](optRef: Option[WeakReference[T]]): Option[T] = if (optRef.nonEmpty) { - val result = optRef.get.get - if (result != null) Some(result) else None + Option(optRef.get.get) } else None } |