Skip to content

Commit

Permalink
Use Using.resource
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki authored and olsdavis committed Apr 4, 2022
1 parent 63c7fa2 commit 2282b1d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions compiler/test/dotty/tools/utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def assertThrows[T <: Throwable: ClassTag](p: T => Boolean)(body: => Any): Unit
end assertThrows

def toolArgsFor(files: List[JPath], charset: Charset = UTF_8): List[String] =
files.flatMap(path => toolArgsParse {
val stream = Files.lines(path, charset)
try stream.limit(10).toScala(List)
finally stream.close()
})
files.flatMap(path => toolArgsParse(resource(Files.lines(path, charset))(_.limit(10).toScala(List))))

// Inspect the first 10 of the given lines for compiler options of the form
// `// scalac: args`, `/* scalac: args`, ` * scalac: args`.
Expand Down

0 comments on commit 2282b1d

Please sign in to comment.