File tree Expand file tree Collapse file tree 3 files changed +20
-14
lines changed
scala-2.11_2.12/scala/util/compat
scala-2.13/scala/util/compat
test/scala/test/scala/util Expand file tree Collapse file tree 3 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 1
- package scala .util
1
+ package scala .util . compat
2
2
3
3
import java .util .concurrent .atomic .AtomicBoolean
4
4
5
5
import scala .util .control .{ControlThrowable , NonFatal }
6
+ import scala .util ._
6
7
7
8
/** A utility for performing automatic resource management. It can be used to perform an
8
9
* operation using resources, after which it will release the resources, in reverse order
@@ -281,7 +282,9 @@ object Using {
281
282
282
283
object Resource {
283
284
/** An implicit `Resource` for [[java.lang.AutoCloseable `AutoCloseable`s ]]. */
284
- implicit val autoCloseableResource : Resource [AutoCloseable ] = (resource : AutoCloseable ) => resource.close()
285
+ implicit val autoCloseableResource : Resource [AutoCloseable ] = new Resource [AutoCloseable ] {
286
+ def release (resource : AutoCloseable ) = resource.close()
287
+ }
285
288
}
286
289
287
290
}
Original file line number Diff line number Diff line change 1
- package scala .util
2
-
3
- package object compat {
4
- /**
5
- * Adds chaining methods `tap` and `pipe` to every type. See [[ChainingOps ]].
6
- */
7
- object chainingOps extends ChainingSyntax
8
- }
1
+ package scala .util
2
+
3
+ package object compat {
4
+ /**
5
+ * Adds chaining methods `tap` and `pipe` to every type. See [[ChainingOps ]].
6
+ */
7
+ object chainingOps extends ChainingSyntax
8
+
9
+ type Using [R ] = scala.util.Using [R ]
10
+ val Using = scala.util.Using
11
+ }
Original file line number Diff line number Diff line change 1
- package scala .util
1
+ package scala .util . compat
2
2
3
3
import org .junit .runner .RunWith
4
4
import org .junit .runners .JUnit4
@@ -310,7 +310,7 @@ class UsingTest {
310
310
val group = new ResourceGroup
311
311
val res = Using .resources(
312
312
group.newResource(),
313
- group.newResource(),
313
+ group.newResource()
314
314
) { (r1, r2) =>
315
315
r1.identity(1 ) + r2.identity(1 )
316
316
}
@@ -323,7 +323,7 @@ class UsingTest {
323
323
val res = Using .resources(
324
324
group.newResource(),
325
325
group.newResource(),
326
- group.newResource(),
326
+ group.newResource()
327
327
) { (r1, r2, r3) =>
328
328
r1.identity(1 ) +
329
329
r2.identity(1 ) +
@@ -339,7 +339,7 @@ class UsingTest {
339
339
group.newResource(),
340
340
group.newResource(),
341
341
group.newResource(),
342
- group.newResource(),
342
+ group.newResource()
343
343
) { (r1, r2, r3, r4) =>
344
344
r1.identity(1 ) +
345
345
r2.identity(1 ) +
You can’t perform that action at this time.
0 commit comments