Skip to content

Commit

Permalink
Seal coercible (for safety), make it not subclass Function1 (to preve…
Browse files Browse the repository at this point in the history
…nt accidentally putting implicit conversions in scope)
  • Loading branch information
Jorge Ortiz committed Mar 24, 2010
1 parent 7009bea commit bc31c5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/scala/scalaj/collection/j2s/Implicits.scala
Expand Up @@ -20,7 +20,9 @@ trait Implicits {
implicit def RichJDictionary[A, B](underlying: ju.Dictionary[A, B]): RichDictionary[A, B] = new RichDictionary(underlying)
}

trait Coercible[A, B] extends (A => B)
sealed trait Coercible[-A, +B] {
def apply(x: A): B
}

object Coercible extends LowPriorityCoercible {
private[collection] def coerce[M[_], A, B](m: M[A])(implicit c: Coercible[A, B]): M[B] = m.asInstanceOf[M[B]]
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/scalaj/collection/s2j/Implicits.scala
Expand Up @@ -22,7 +22,9 @@ trait Implicits {
implicit def RichSMutableMap[A, B](underlying: scm.Map[A, B]): RichMutableMap[A, B] = new RichMutableMap(underlying)
}

trait Coercible[A, B] extends (A => B)
sealed trait Coercible[-A, +B] {
def apply(x: A): B
}

object Coercible extends LowPriorityCoercible {
private[collection] def coerce[M[_], A, B](m: M[A])(implicit c: Coercible[A, B]): M[B] = m.asInstanceOf[M[B]]
Expand Down

0 comments on commit bc31c5b

Please sign in to comment.