summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-06-01 12:49:48 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2016-06-01 12:49:48 +0200
commit128ac65991210fee3d5e273e30c9f31322e1a585 (patch)
tree719349123872ad69414218e4abbdd3c39128168c /src
parent608387529b790c2a0fc87b4cf5b5324d68d02648 (diff)
parentec1e80422676f02a088034d1658c7cb7f2e6e663 (diff)
downloadscala-128ac65991210fee3d5e273e30c9f31322e1a585.tar.gz
scala-128ac65991210fee3d5e273e30c9f31322e1a585.tar.bz2
scala-128ac65991210fee3d5e273e30c9f31322e1a585.zip
Merge pull request #5198 from sjrd/privatize-range-members
Privatize the deprecated members of `immutable.Range`.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/Range.scala28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 0c24d17c15..2e56750115 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -81,8 +81,7 @@ extends scala.collection.AbstractSeq[Int]
|| (start == end && !isInclusive)
)
- @deprecated("this method will be made private, use `length` instead", "2.11.0")
- final val numRangeElements: Int = {
+ private val numRangeElements: Int = {
if (step == 0) throw new IllegalArgumentException("step cannot be 0.")
else if (isEmpty) 0
else {
@@ -92,21 +91,16 @@ extends scala.collection.AbstractSeq[Int]
}
}
- @deprecated("this method will be made private, use `last` instead", "2.11.0")
- final val lastElement =
- if (isEmpty) start - step
- else step match {
- case 1 => if (isInclusive) end else end-1
- case -1 => if (isInclusive) end else end+1
- case _ =>
- val remainder = (gap % step).toInt
- if (remainder != 0) end - remainder
- else if (isInclusive) end
- else end - step
- }
-
- @deprecated("this method will be made private", "2.11.0")
- final val terminalElement = lastElement + step
+ // This field has a sensible value only for non-empty ranges
+ private val lastElement = step match {
+ case 1 => if (isInclusive) end else end-1
+ case -1 => if (isInclusive) end else end+1
+ case _ =>
+ val remainder = (gap % step).toInt
+ if (remainder != 0) end - remainder
+ else if (isInclusive) end
+ else end - step
+ }
/** The last element of this range. This method will return the correct value
* even if there are too many elements to iterate over.