|
| 1 | +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:14:38 ------------------------------------- |
| 2 | +14 | private val later1 = usingLogFile { f => () => f.write() } // error |
| 3 | + | ^^^^^^^^^^^^^^^^^^^^ |
| 4 | + |Capability f outlives its scope: it leaks into outer capture set 's1 which is owned by value later1. |
| 5 | + |The leakage occurred when trying to match the following types: |
| 6 | + | |
| 7 | + |Found: (f: Test2.File^'s2) ->'s3 () ->{f} Unit |
| 8 | + |Required: Test2.File^ => () ->'s1 Unit |
| 9 | + | |
| 10 | + |where: => refers to a fresh root capability created in value later1 when checking argument to parameter op of method usingLogFile |
| 11 | + | ^ refers to the universal root capability |
| 12 | + | |
| 13 | + | longer explanation available when compiling with `-explain` |
| 14 | +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:15:38 ------------------------------------- |
| 15 | +15 | private val later2 = usingLogFile { f => Box(f) } // error |
| 16 | + | ^^^^^^^^^^^ |
| 17 | + |Capability cap outlives its scope: it leaks into outer capture set 's4 which is owned by value later2. |
| 18 | + |The leakage occurred when trying to match the following types: |
| 19 | + | |
| 20 | + |Found: (f: Test2.File^'s5) ->'s6 Test2.Box[Test2.File^'s7]^'s8 |
| 21 | + |Required: Test2.File^ => Test2.Box[Test2.File^'s4]^'s9 |
| 22 | + | |
| 23 | + |where: => refers to a fresh root capability created in value later2 when checking argument to parameter op of method usingLogFile |
| 24 | + | ^ refers to the universal root capability |
| 25 | + | cap is a root capability associated with the result type of (f: Test2.File^): Test2.Box[Test2.File^'s4]^'s9 |
| 26 | + | |
| 27 | + | longer explanation available when compiling with `-explain` |
| 28 | +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:17:4 -------------------------------------- |
| 29 | +17 | f => () => f.write() // error |
| 30 | + | ^^^^^^^^^^^^^^^^^^^^ |
| 31 | + |Found: (f: Test2.File^'s10) ->'s11 () ->{f} Unit |
| 32 | + |Required: Test2.File^ => () =>² Unit |
| 33 | + | |
| 34 | + |Note that capability f is not included in capture set {cap} |
| 35 | + |because (f : Test2.File^'s10) is not visible from cap in value later3. |
| 36 | + | |
| 37 | + |where: => refers to a fresh root capability created in value later3 when checking argument to parameter op of method usingLogFile |
| 38 | + | =>² and cap refer to a fresh root capability created in value later3 |
| 39 | + | ^ refers to the universal root capability |
| 40 | + | |
| 41 | + | longer explanation available when compiling with `-explain` |
| 42 | +-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/withFile.scala:19:4 -------------------------------------- |
| 43 | +19 | f => Box(f) // error |
| 44 | + | ^^^^^^^^^^^ |
| 45 | + |Found: (f: Test2.File^'s12) ->'s13 Test2.Box[Test2.File^'s14]^'s15 |
| 46 | + |Required: Test2.File^ => Test2.Box[Test2.File^²] |
| 47 | + | |
| 48 | + |Note that capability cap is not included in capture set {cap²} |
| 49 | + |because cap is not visible from cap² in value later4. |
| 50 | + | |
| 51 | + |where: => refers to a fresh root capability created in value later4 when checking argument to parameter op of method usingLogFile |
| 52 | + | ^ refers to the universal root capability |
| 53 | + | ^² and cap² refer to a fresh root capability created in value later4 |
| 54 | + | cap is a root capability associated with the result type of (f: Test2.File^'s12): Test2.Box[Test2.File^'s14]^'s15 |
| 55 | + | |
| 56 | + | longer explanation available when compiling with `-explain` |
| 57 | +-- Error: tests/neg-custom-args/captures/withFile.scala:16:20 ---------------------------------------------------------- |
| 58 | +16 | private val later3 = usingLogFile[() => Unit]: // error |
| 59 | + | ^ |
| 60 | + | value later3 needs an explicit type because it captures a root capability in its type () => Unit. |
| 61 | + | Fields capturing a root capability need to be given an explicit type unless the capability is already |
| 62 | + | subsumed by the computed capability of the enclosing class. |
| 63 | + | |
| 64 | + | where: => refers to a fresh root capability in the type of value later3 |
0 commit comments