Skip to content

Commit 07ec0b0

Browse files
committed
Backwards compatible changes to cross-compile with the 2.13 collections
1 parent 5019e69 commit 07ec0b0

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

shared/src/main/scala/scala/xml/dtd/impl/NondetWordAutom.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private[dtd] abstract class NondetWordAutom[T <: AnyRef] {
4747
def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default)
4848

4949
private def next(Q: immutable.BitSet, f: (Int) => immutable.BitSet): immutable.BitSet =
50-
(Q map f).foldLeft(immutable.BitSet.empty)(_ ++ _)
50+
((Q: Set[Int]) map f).foldLeft(immutable.BitSet.empty)(_ ++ _)
5151

5252
private def finalStates = 0 until nstates filter isFinal
5353
override def toString = {

shared/src/main/scala/scala/xml/dtd/impl/SubsetConstruction.scala

+9-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T])
2020

2121
def determinize: DetWordAutom[T] = {
2222
// for assigning numbers to bitsets
23-
var indexMap = scala.collection.Map[immutable.BitSet, Int]()
24-
var invIndexMap = scala.collection.Map[Int, immutable.BitSet]()
23+
var indexMap = scala.collection.immutable.Map[immutable.BitSet, Int]()
24+
var invIndexMap = scala.collection.immutable.Map[Int, immutable.BitSet]()
2525
var ix = 0
2626

2727
// we compute the dfa with states = bitsets
@@ -37,8 +37,11 @@ private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T])
3737
rest.push(sink, q0)
3838

3939
def addFinal(q: immutable.BitSet) {
40-
if (nfa containsFinal q)
41-
finals = finals.updated(q, selectTag(q, nfa.finals))
40+
if (nfa containsFinal q) {
41+
val finalsClone = finals.clone
42+
finalsClone(q) = selectTag(q, nfa.finals)
43+
finals = finalsClone
44+
}
4245
}
4346
def add(Q: immutable.BitSet) {
4447
if (!states(Q)) {
@@ -69,7 +72,8 @@ private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T])
6972

7073
// collect default transitions
7174
val Pdef = nfa nextDefault P
72-
deftrans = deftrans.updated(P, Pdef)
75+
deftrans = deftrans.clone
76+
deftrans(P) = Pdef
7377
add(Pdef)
7478
}
7579

shared/src/main/scala/scala/xml/parsing/MarkupParser.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
358358
}
359359
nextch()
360360
val str = cbuf.toString()
361-
cbuf.length = 0
361+
cbuf.clear()
362362
str
363363
}
364364

@@ -390,7 +390,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
390390
xToken("--")
391391
while (!eof) {
392392
if (ch == '-' && { sb.append(ch); nextch(); ch == '-' }) {
393-
sb.length = sb.length - 1
393+
sb.setLength(sb.length - 1)
394394
nextch()
395395
xToken('>')
396396
return handle.comment(pos, sb.toString())
@@ -608,7 +608,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
608608
exit = eof || (ch == '<') || (ch == '&')
609609
}
610610
val str = cbuf.toString
611-
cbuf.length = 0
611+
cbuf.clear()
612612
str
613613
}
614614

@@ -630,7 +630,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
630630
}
631631
nextch()
632632
val str = cbuf.toString()
633-
cbuf.length = 0
633+
cbuf.clear()
634634
str
635635
}
636636

@@ -653,7 +653,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
653653
}
654654
nextch()
655655
val str = cbuf.toString
656-
cbuf.length = 0
656+
cbuf.clear()
657657
str
658658
}
659659

@@ -799,7 +799,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
799799
//Console.println("END["+ch+"]")
800800
nextch()
801801
val cmstr = cbuf.toString()
802-
cbuf.length = 0
802+
cbuf.clear()
803803
handle.elemDecl(n, cmstr)
804804
}
805805

@@ -826,7 +826,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
826826
nextch()
827827
}
828828
val atpe = cbuf.toString
829-
cbuf.length = 0
829+
cbuf.clear()
830830

831831
val defdecl: DefaultDecl = ch match {
832832
case '\'' | '"' =>
@@ -846,7 +846,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
846846
xSpaceOpt()
847847

848848
attList ::= AttrDecl(aname, atpe, defdecl)
849-
cbuf.length = 0
849+
cbuf.clear()
850850
}
851851
nextch()
852852
handle.attListDecl(n, attList.reverse)

0 commit comments

Comments
 (0)