diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-19 15:27:19 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-19 15:27:19 +0000 |
commit | 5bb967a3de039830dcc453bb92d3b6a0b794684f (patch) | |
tree | cc33748f925b4c0f307bd23b4b442c57f9b2046a /src/library/scala/math/Integral.scala | |
parent | 8f0ff8bc2aaaa5299ebe4f617ab9e28443f994bd (diff) | |
download | scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.tar.gz scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.tar.bz2 scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.zip |
Some boundary conditions in range.
infix implicits to Integral and Fractional. As a bonus this patch
knocked 10,000 long boxings off a specialized test. Who knew. Closes
#4308, #4321, review by community.
Diffstat (limited to 'src/library/scala/math/Integral.scala')
-rw-r--r-- | src/library/scala/math/Integral.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/library/scala/math/Integral.scala b/src/library/scala/math/Integral.scala index 9c1deaea33..bb364a79b4 100644 --- a/src/library/scala/math/Integral.scala +++ b/src/library/scala/math/Integral.scala @@ -24,3 +24,14 @@ trait Integral[T] extends Numeric[T] { } override implicit def mkNumericOps(lhs: T): IntegralOps = new IntegralOps(lhs) } + +object Integral { + trait ExtraImplicits { + /** The regrettable design of Numeric/Integral/Fractional has them all + * bumping into one another when searching for this implicit, so they + * are exiled into their own companions. + */ + implicit def infixIntegralOps[T](x: T)(implicit num: Integral[T]): Integral[T]#IntegralOps = new num.IntegralOps(x) + } + object Implicits extends ExtraImplicits +}
\ No newline at end of file |