Skip to content

Commit 052e9b1

Browse files
committed
Don't write public methods with non-public parameters.
If the parameter types of a method have lower visibility than the method itself, then the method cannot be overridden because the parameter types cannot be expressed. This is a confusing and frustrating situation to expose via public API. Such methods should either have access as strong as their parameter types, or be made final.
1 parent 742cb71 commit 052e9b1

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/actors-migration/scala/actors/migration/Props.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ case class Props(creator: () ⇒ InternalActor, dispatcher: String) {
1010
/**
1111
* Returns a new Props with the specified creator set
1212
*/
13-
def withCreator(c: InternalActor) = copy(creator = () c)
14-
13+
final def withCreator(c: InternalActor) = copy(creator = () c)
1514
}

src/library/scala/collection/immutable/HashMap.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class HashMap[A, +B] extends AbstractMap[A, B]
120120
*/
121121
object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
122122

123-
private abstract class Merger[A, B] {
123+
private[collection] abstract class Merger[A, B] {
124124
def apply(kv1: (A, B), kv2: (A, B)): (A, B)
125125
def invert: Merger[A, B]
126126
}
@@ -197,7 +197,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
197197
// }
198198
// }
199199

200-
override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
200+
private[collection] override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
201201
if (hash == this.hash && key == this.key ) {
202202
if (merger eq null) {
203203
if (this.value.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this
@@ -238,7 +238,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
238238
override def get0(key: A, hash: Int, level: Int): Option[B] =
239239
if (hash == this.hash) kvs.get(key) else None
240240

241-
override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
241+
private[collection] override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
242242
if (hash == this.hash) {
243243
if ((merger eq null) || !kvs.contains(key)) new HashMapCollision1(hash, kvs.updated(key, value))
244244
else new HashMapCollision1(hash, kvs + merger((key, kvs(key)), kv))
@@ -316,7 +316,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
316316
None
317317
}
318318

319-
override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] = {
319+
private[collection] override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] = {
320320
val index = (hash >>> level) & 0x1f
321321
val mask = (1 << index)
322322
val offset = Integer.bitCount(bitmap & (mask-1))

src/reflect/scala/reflect/runtime/JavaMirrors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { thisUnive
9898
private val fieldCache = new TwoWayCache[jField, TermSymbol]
9999
private val tparamCache = new TwoWayCache[jTypeVariable[_ <: GenericDeclaration], TypeSymbol]
100100

101-
def toScala[J: HasJavaClass, S](cache: TwoWayCache[J, S], key: J)(body: (JavaMirror, J) => S): S =
101+
private[runtime] def toScala[J: HasJavaClass, S](cache: TwoWayCache[J, S], key: J)(body: (JavaMirror, J) => S): S =
102102
cache.toScala(key){
103103
val jclazz = implicitly[HasJavaClass[J]] getClazz key
104104
body(mirrorDefining(jclazz), key)

0 commit comments

Comments
 (0)