2

http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.List

 sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A, List] with LinearSeqOptimized[A, List[A]] 

AbstractSeq[A] の場所はどこですか?

4

2 に答える 2

4

まさにその通りです(scala.collection.AbstractSeq)。ただし、これはパッケージ プライベート クラスであり、API に表示されないのはおそらくそのためです。2.10.2 からの定義は次のとおりです。

/** Explicit instantiation of the `Seq` trait to reduce class file size in subclasses. */
private[scala] abstract class AbstractSeq[+A] extends AbstractIterable[A] with Seq[A]
于 2013-11-08T14:43:59.567 に答える
1

In addition to Swift Tomato's answer, a bit of background - not having the AbstractSeq would mean that the Scala compiler must instantiate bridge methods for methods in Seq for every collection class that extends trait Seq. This compiler trick is needed to support multiple inheritance on the JVM.

Having all the concrete collection extend AbstractSeq allows concrete collections to inherit those bridge methods like any other JVM method, so the compiler does not need to instantiate bridge methods in every concrete collection class -- the class-file sizes of those concrete collections are reduced.

This class is private and visible only in the scala package to avoid further convoluting people's understanding of the collections package.

于 2013-11-08T15:51:16.690 に答える