<commit_before>package scala.compat.java8

import org.junit.Test
import org.junit.Assert._

import collectionImpl._

class StepperTest {
  class IncStepperA(private val size0: Long) extends NextStepper[Int] with StepperLike[Int, IncStepperA] {
    if (size0 < 0) throw new IllegalArgumentException("Size must be >= 0L")
    private var i = 0L
    def characteristics = 0
    def knownSize = math.max(0L, size0 - i)
    def hasStep = i < knownSize
    def nextStep() = { i += 1; (i - 1).toInt }
    def substep() = if ((knownSize - i) <= 1) null else {
      val sub = new IncStepperA(size0 - (size0 - i)/2)
      sub.i = i
      i = sub.size0
      sub
    }
    def typedPrecisely = this
    def spliterator = ???
  }

  class IncStepperB(private val size0: Long) extends TryStepper[Int] with StepperLike[Int, IncStepperB] {
    if (size0 < 0) throw new IllegalArgumentException("Size must be >= 0L")
    private var i = 0L
    def characteristics = 0
    def knownSize = math.max(0L, size0 - i)
    def tryStep(f: Int => Unit): Boolean = if (i >= size0) false else { f(i.toInt); i += 1; true }
    def substep() = if ((knownSize - i) <= 1) null else {
      val sub = new IncStepperB(size0 - (size0 - i)/2)
      sub.i = i
      i = sub.size0
      sub
    }
    def typedPrecisely = this
    def spliterator = ???
  }

  def subs[Z, A, CC <: Stepper[A]](zero: Z)(s: Stepper[A])(f: Stepper[A] => Z, op: (Z, Z) => Z): Z = {
    val ss = s.substep()
    if (ss == null) op(zero, f(s))
    else {
      val left = subs(zero)(ss)(f, op)
      subs(left)(s)(f, op)
    }
  }

  val sizes = Vector(0, 1, 2, 4, 15, 17, 2512)
  def sources: Vector[(Int, Stepper[Int])] = sizes.flatMap(i => Vector(i -> new IncStepperA(i), i -> new IncStepperB(i)))

  @Test
  def count_only() {
    sources.foreach{ case (i, s) => assertEquals(i, s.count) }
    sources.foreach{ case (i, s) => assertEquals(i, subs(0)(s)(_.count.toInt, _ + _)) }
  }
}
<commit_msg>Moved classes outside of StepperTest to see if this helps exception.<commit_after>package scala.compat.java8

import org.junit.Test
import org.junit.Assert._

import collectionImpl._

class IncStepperA(private val size0: Long) extends NextStepper[Int] {
  if (size0 < 0) throw new IllegalArgumentException("Size must be >= 0L")
  private var i = 0L
  def characteristics = 0
  def knownSize = math.max(0L, size0 - i)
  def hasStep = i < knownSize
  def nextStep() = { i += 1; (i - 1).toInt }
  def substep() = if ((knownSize - i) <= 1) null else {
    val sub = new IncStepperA(size0 - (size0 - i)/2)
    sub.i = i
    i = sub.size0
    sub
  }
  def typedPrecisely = this
  def spliterator = ???
}

class IncStepperB(private val size0: Long) extends TryStepper[Int] {
  if (size0 < 0) throw new IllegalArgumentException("Size must be >= 0L")
  private var i = 0L
  def characteristics = 0
  def knownSize = math.max(0L, size0 - i)
  def tryStep(f: Int => Unit): Boolean = if (i >= size0) false else { f(i.toInt); i += 1; true }
  def substep() = if ((knownSize - i) <= 1) null else {
    val sub = new IncStepperB(size0 - (size0 - i)/2)
    sub.i = i
    i = sub.size0
    sub
  }
  def typedPrecisely = this
  def spliterator = ???
}

class StepperTest {
  def subs[Z, A, CC <: Stepper[A]](zero: Z)(s: Stepper[A])(f: Stepper[A] => Z, op: (Z, Z) => Z): Z = {
    val ss = s.substep()
    if (ss == null) op(zero, f(s))
    else {
      val left = subs(zero)(ss)(f, op)
      subs(left)(s)(f, op)
    }
  }

  val sizes = Vector(0, 1, 2, 4, 15, 17, 2512)
  def sources: Vector[(Int, Stepper[Int])] = sizes.flatMap(i => Vector(i -> new IncStepperA(i), i -> new IncStepperB(i)))

  @Test
  def count_only() {
    sources.foreach{ case (i, s) => assertEquals(i, s.count) }
    sources.foreach{ case (i, s) => assertEquals(i, subs(0)(s)(_.count.toInt, _ + _)) }
  }
}

{'fraction_non_alphanumeric': 0.15374507227332457, 'fraction_numerical': 0.023127463863337715, 'mean_word_length': 2.9075975359342916, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3102628', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1407, 'n_words': 420}