Skip to content

Commit e0cbd12

Browse files
committed
Scala 2.11 compatibiltity: no Java SAMs
1 parent 5b4ca4f commit e0cbd12

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/main/scala/scala/async/internal/ExprBuilder.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ trait ExprBuilder {
302302
checkForUnsupportedAwait(scrutinee)
303303

304304
val caseStates = new Array[Int](cases.length)
305-
java.util.Arrays.setAll(caseStates, (_ => nextState()): IntUnaryOperator)
305+
java.util.Arrays.setAll(caseStates, new IntUnaryOperator {
306+
override def applyAsInt(operand: Int): Int = nextState()
307+
})
306308
val afterMatchState = nextState()
307309

308310
asyncStates +=

src/main/scala/scala/async/internal/LiveVariables.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scala.async.internal
22

33
import java.util
4+
import java.util.function.{IntConsumer, IntPredicate}
45

56
import scala.collection.immutable.IntMap
67

@@ -26,7 +27,7 @@ trait LiveVariables {
2627
var assignsOf = Map[Int, List[Tree]]()
2728

2829
for ((fld, where) <- liveVarsMap) {
29-
where.foreach { (state: Int) =>
30+
where.foreach { new IntConsumer { def accept(state: Int): Unit = {
3031
assignsOf get state match {
3132
case None =>
3233
assignsOf += (state -> List(fld))
@@ -35,7 +36,7 @@ trait LiveVariables {
3536
case _ =>
3637
// do nothing
3738
}
38-
}
39+
}}}
3940
}
4041

4142
assignsOf
@@ -272,15 +273,21 @@ trait LiveVariables {
272273
val nullOutAt: Map[Tree, StateSet] =
273274
for ((fld, lastStates) <- lastUsages) yield {
274275
var result = new StateSet
275-
lastStates.foreach { s =>
276+
lastStates.foreach(new IntConsumer { def accept(s: Int): Unit = {
276277
if (s != finalState.state) {
277278
val lastAsyncState = asyncStates.find(_.state == s).get
278279
val succNums = lastAsyncState.nextStates
279280
// all successor states that are not indirect predecessors
280281
// filter out successor states where the field is live at the entry
281-
util.Arrays.stream(succNums).filter(num => !isPred(num, s)).filter(num => !LVentry(num).contains(fld.symbol)).forEach(result += _)
282+
var i = 0
283+
while (i < succNums.length) {
284+
val num = succNums(i)
285+
if (!isPred(num, s) && !LVentry(num).contains(fld.symbol))
286+
result += num
287+
i += 1
288+
}
282289
}
283-
}
290+
}})
284291
(fld, result)
285292
}
286293

0 commit comments

Comments
 (0)