Skip to content

Commit f8aa775

Browse files
committed
Turn IndexedView into a trait to avoid reflective access
1 parent bd4ca4e commit f8aa775

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/scala/strawman/collection/CollectionStrawman6.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ trait LinearSeq[+A] extends Seq[A] with LinearSeqLike[A, LinearSeq] { self =>
149149
}
150150
}
151151

152+
trait IndexedSeq[+A] extends Seq[A] { self =>
153+
override def view: IndexedView[A] = new IndexedView[A] {
154+
def length: Int = self.length
155+
def apply(i: Int): A = self(i)
156+
}
157+
}
158+
152159
/** Base trait for strict collections that can be built using a builder.
153160
* @param A the element type of the collection
154161
* @param Repr the type of the underlying collection

src/main/scala/strawman/collection/package.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import Predef.{augmentString => _, wrapString => _, _}
44
import scala.reflect.ClassTag
55

66
package object collection extends LowPriority {
7-
type IndexedSeq[+A] = Seq[A] {
8-
def view: IndexedView[A]
9-
}
10-
117
// ------------------ Decorators to add collection ops to existing types -----------------------
128

139
/** Decorator to add collection operations to strings.

0 commit comments

Comments
 (0)