Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-9885

BatchSourceFile throws an exception when there is an empty line at the end of a file

    Details

      Description

          val file = new BatchSourceFile(
            "bug.scala",
            """package com.example
              |object Test {
              |}
              |
              |""".stripMargin
          )
       
          val offset = file.lineToOffset(4)
          file.offsetToLine(offset)
      

      Fails with:

      java.lang.ArrayIndexOutOfBoundsException: 6
      at scala.reflect.internal.util.BatchSourceFile.findLine$1(SourceFile.scala:178)
      at scala.reflect.internal.util.BatchSourceFile.offsetToLine(SourceFile.scala:181)
      

        Attachments

          Activity

            People

            • Assignee:
              apm A. P. Marki
              Reporter:
              chessman Eugene Apollonsky
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: