Skip to content

Commit

Permalink
add testcase for scala#15921
Browse files Browse the repository at this point in the history
  • Loading branch information
Linyxus committed Oct 31, 2022
1 parent b1c69ba commit ef9e351
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/neg-custom-args/captures/i15921.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait Stream { def close(): Unit = (); def write(x: Any): Unit = () }

object Test {
def usingLogFile[T](op: (c: {*} Stream) => T): T =
val logFile = new Stream { }
val result = op(logFile)
logFile.close()
result

val later = usingLogFile { f => () => f.write(0) } // error
later() // writing to closed file!
}

0 comments on commit ef9e351

Please sign in to comment.