Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.1, Scala 2.10.3
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: Collections
    • Labels:
      None

      Description

      see code

        final override def sum[B >: Int](implicit num: Numeric[B]): Int = {
          if (isEmpty) 0
          else if (numRangeElements == 1) head
          else (numRangeElements.toLong * (head + last) / 2).toInt
        }
      

      test that show that such implementation is wrong

      scala>  object mynum extends Numeric[Int] { 
           |   // Members declared in scala.math.Numeric
           |   def fromInt(x: Int): Int = ???
           |   def minus(x: Int,y: Int): Int = ???
           |   def negate(x: Int): Int = ???
           |   def plus(x: Int,y: Int): Int = ???
           |   def times(x: Int,y: Int): Int = ???
           |   def toDouble(x: Int): Double = ???
           |   def toFloat(x: Int): Float = ???
           |   def toInt(x: Int): Int = ???
           |   def toLong(x: Int): Long = ???
           |   
           |   // Members declared in scala.math.Ordering
           |   def compare(x: Int,y: Int): Int = ???
           | }
      defined module mynum
      
      scala> (1 to 100).sum(mynum)
      res0: Int = 5050
      
      

      This test should throw scala.NotImplementedError

        Activity

        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/3124

          People

          • Assignee:
            Dmitry Petrashko
            Reporter:
            Dmitry Petrashko
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development