Skip to content

Commit 8c90908

Browse files
committed
add testcase for #15921
1 parent bae5b97 commit 8c90908

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait Stream { def close(): Unit = (); def write(x: Any): Unit = () }
2+
3+
object Test {
4+
def usingLogFile[T](op: (c: {*} Stream) => T): T =
5+
val logFile = new Stream { }
6+
val result = op(logFile)
7+
logFile.close()
8+
result
9+
10+
val later = usingLogFile { f => () => f.write(0) } // error
11+
later() // writing to closed file!
12+
}

0 commit comments

Comments
 (0)