diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-30 21:24:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-30 21:24:17 +0000 |
commit | c0bfbce726c9cb74154ee9f30166feb97bfd0331 (patch) | |
tree | b39f6dbd5fc86822bcbdd48f9f0dd0dedbe85c0c | |
parent | 89de9c3f9ff33d9fe74263f49ff8cdb987211fbf (diff) | |
download | scala-c0bfbce726c9cb74154ee9f30166feb97bfd0331.tar.gz scala-c0bfbce726c9cb74154ee9f30166feb97bfd0331.tar.bz2 scala-c0bfbce726c9cb74154ee9f30166feb97bfd0331.zip |
Removed Proxy from parents of WrappedString.
forward toString, but forwarding equals and hashCode breaks equality
with sequences. Closes #4122, no review.
-rw-r--r-- | src/library/scala/collection/immutable/WrappedString.scala | 3 | ||||
-rw-r--r-- | test/files/run/bug4122.scala | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/WrappedString.scala b/src/library/scala/collection/immutable/WrappedString.scala index 62a39213d5..3a689bab85 100644 --- a/src/library/scala/collection/immutable/WrappedString.scala +++ b/src/library/scala/collection/immutable/WrappedString.scala @@ -29,7 +29,7 @@ import scala.util.matching.Regex * @define Coll WrappedString * @define coll wrapped string */ -class WrappedString(override val self: String) extends IndexedSeq[Char] with StringLike[WrappedString] with Proxy { +class WrappedString(val self: String) extends IndexedSeq[Char] with StringLike[WrappedString] { override protected[this] def thisCollection: WrappedString = this override protected[this] def toCollection(repr: WrappedString): WrappedString = repr @@ -39,6 +39,7 @@ class WrappedString(override val self: String) extends IndexedSeq[Char] with Str override def slice(from: Int, until: Int): WrappedString = new WrappedString(self.substring(from max 0, until min self.length)) + override def toString = self } /** A companion object for wrapped strings. diff --git a/test/files/run/bug4122.scala b/test/files/run/bug4122.scala new file mode 100644 index 0000000000..5ff570c009 --- /dev/null +++ b/test/files/run/bug4122.scala @@ -0,0 +1,14 @@ +object Test { + val sw: Seq[Char] = "ab" + val sw2: Seq[Char] = Array('a', 'b') + val sw3 = Seq('a', 'b') + val sw4 = "ab".toList + val all = List(sw, sw2, sw3, sw4) + + def main(args: Array[String]): Unit = { + for (s1 <- all ; s2 <- all) { + assert(s1 == s2, s1 + " != " + s2) + assert(s1.## == s2.##, s1 + ".## != " + s2 + ".##") + } + } +} |