diff options
-rw-r--r-- | src/library/scala/collection/generic/LinearSequenceTemplate.scala | 9 | ||||
-rw-r--r-- | test/files/run/t2212.check | 3 | ||||
-rw-r--r-- | test/files/run/t2212.scala | 10 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/library/scala/collection/generic/LinearSequenceTemplate.scala b/src/library/scala/collection/generic/LinearSequenceTemplate.scala index 6dcf96fce4..2e1f61a36f 100644 --- a/src/library/scala/collection/generic/LinearSequenceTemplate.scala +++ b/src/library/scala/collection/generic/LinearSequenceTemplate.scala @@ -280,11 +280,16 @@ trait LinearSequenceTemplate[+A, +This <: LinearSequenceTemplate[A, This] with L case that1: LinearSequence[_] => var these = this var those = that1 - while (!these.isEmpty && !those.isEmpty && these.head == those.head) { + while (these != null && those != null && !these.isEmpty && !those.isEmpty && these.head == those.head) { these = these.tail those = those.tail } - these.isEmpty && those.isEmpty + if (these == null) + those == null + else if (those == null) + false + else + these.isEmpty && those.isEmpty case _ => super.sameElements(that) } diff --git a/test/files/run/t2212.check b/test/files/run/t2212.check new file mode 100644 index 0000000000..302bd0b6a8 --- /dev/null +++ b/test/files/run/t2212.check @@ -0,0 +1,3 @@ +LinkedList(1) +LinkedList(1) +true diff --git a/test/files/run/t2212.scala b/test/files/run/t2212.scala new file mode 100644 index 0000000000..5f4447fa2b --- /dev/null +++ b/test/files/run/t2212.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]) { + import collection.mutable._ + val x4 = new LinkedList[Int](1, null) + println(x4) + val y4 = new LinkedList[Int](1, null) + println(y4) + println(x4 equals y4) // or (y4 equals x4) + } +} |