You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should not type-check. Accepting the boom function is clearly unsound: given any impure operations that could perform arbitrary effects, boom could hide its captures and pretend that this operation is pure.
The capture checker rejects the morally equivalent variant that uses only reach capabilities:
defrunOpsAlt(ops: List[() =>Unit]):Unit=
ops.foreach: op =>
op()
The compiler complains:
-- Error: issues/drop-caparg.scala:4:15 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 | ops.foreach: op =>
| ^
| Local reach capability ops* leaks into capture scope of method runOpsAlt
5 | op()
We should do something similar with capture polymorphism.
This is necessary for types that contain possibly illegal @retains annotations
since those annotations are only removed before pickling for InferredTypes.
Fixesscala#21347
This is necessary for types that contain possibly illegal @retains annotations
since those annotations are only removed before pickling for InferredTypes.
Fixesscala#21347
This is necessary for types that contain possibly illegal @retains annotations
since those annotations are only removed before pickling for InferredTypes.
Fixes#21347
Compiler version
The
main
branchMinimized code
Output
It type-checks.
Expectation
It should not type-check. Accepting the
boom
function is clearly unsound: given any impure operations that could perform arbitrary effects,boom
could hide its captures and pretend that this operation is pure.The capture checker rejects the morally equivalent variant that uses only reach capabilities:
The compiler complains:
We should do something similar with capture polymorphism.
/cc @odersky
The text was updated successfully, but these errors were encountered: