diff --git a/collections/src/main/scala/strawman/collection/mutable/LinkedList.scala b/collections/src/main/scala/strawman/collection/mutable/LinkedList.scala index 8aff10ea16..062ebdd9bc 100644 --- a/collections/src/main/scala/strawman/collection/mutable/LinkedList.scala +++ b/collections/src/main/scala/strawman/collection/mutable/LinkedList.scala @@ -56,7 +56,7 @@ private[mutable] final class LinkedList[A]() extends AbstractSeq[A] next = this } - def addOne(elem: A): this.type = { append(LinkedList(elem)); this } + def addOne(elem: A): this.type = { append(new LinkedList(elem, LinkedList.empty[A])); this } // Members declared in strawman.collection.mutable.IterableOps def filterInPlace(p: A => Boolean): this.type = { diff --git a/test/junit/src/test/scala/strawman/collection/mutable/LinkedListTest.scala b/test/junit/src/test/scala/strawman/collection/mutable/LinkedListTest.scala new file mode 100644 index 0000000000..c6c7270b72 --- /dev/null +++ b/test/junit/src/test/scala/strawman/collection/mutable/LinkedListTest.scala @@ -0,0 +1,14 @@ +package strawman.collection.mutable + +import strawman.collection.immutable.List + +import org.junit.Test + +class LinkedListTest { + + @Test + def fromTerminates(): Unit = { + LinkedList.from(List(1)) // Doesn’t throw a StackOverflowException + } + +}