We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following throws:
object Test { import scala.collection.immutable.NumericRange case class A(v: Int) implicit object aIsIntegral extends scala.math.Integral[A] { def compare(x: A, y: A): Int = x.v - y.v def fromInt(x: Int): A = A(x) def minus(x: A, y: A): A = A(x.v - y.v) def negate(x: A): A = A(-x.v) def plus(x: A, y: A): A = A(x.v + y.v) def times(x: A, y: A): A = A(x.v * x.v) def quot(x: A, y: A): A = A(x.v / y.v) def rem(x: A, y: A): A = A(x.v % y.v) def toDouble(x: A): Double = x.v.toDouble def toFloat(x: A): Float = x.v.toFloat def toInt(x: A): Int = x.v def toLong(x: A): Long = x.v.toLong } def main(args: Array[String]): Unit = { val r = NumericRange(A(1), A(10), A(1)) println(r) // NumericRange(A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9)) // As expected. println(r.max) // java.util.NoSuchElementException: key not found: Test$aIsIntegral$@1a0e35d3 // at scala.collection.MapLike$class.default(MapLike.scala:228) // at scala.collection.AbstractMap.default(Map.scala:58) // at scala.collection.MapLike$class.apply(MapLike.scala:141) // at scala.collection.AbstractMap.apply(Map.scala:58) // at scala.collection.immutable.NumericRange.max(NumericRange.scala:137) // at Test$.main(Test.scala:26) // at Test.main(Test.scala) // at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) // at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) // at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) // at java.lang.reflect.Method.invoke(Method.java:498) // Expected A(9) } }
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-10086?orig=1 Reporter: @gzm0
Sorry, something went wrong.
@som-snytt said (edited on Dec 2, 2016 11:41:52 PM UTC): WIP scala/scala#5575
gzm0
No branches or pull requests
The following throws:
The text was updated successfully, but these errors were encountered: