-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mapping TypeMaps over annotations (#15948)
Avoids orphan parameters when pickling Fixes #15922 I am not sure about the status of the test in custome-args/captures. Should it pass or be rejected? But in any case it does not crash anymore.
- Loading branch information
Showing
6 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait Cap { def use(): Int } | ||
type Id[X] = [T] -> (op: X => T) -> T | ||
def mkId[X](x: X): Id[X] = [T] => (op: X => T) => op(x) | ||
|
||
def withCap[X](op: ({*} Cap) => X): X = { | ||
val cap: {*} Cap = new Cap { def use() = { println("cap is used"); 0 } } | ||
val result = op(cap) | ||
result | ||
} | ||
|
||
def leaking(c: {*} Cap): Id[{c} Cap] = mkId(c) | ||
|
||
def test = | ||
val bad = withCap(leaking) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait Cap: | ||
type M | ||
class Id[X] | ||
|
||
object Test: | ||
def withCap[X](op: Cap => X): X = ??? | ||
|
||
class retains1(xs: Any*) extends annotation.StaticAnnotation | ||
|
||
def leaking1(c: Cap): Id[Cap @retains1(c)] = ??? // used to crash with orphan parameter on pickling | ||
def leaking2(c: Cap): Id[c.type] = ??? | ||
|
||
val bad1 = withCap(leaking1) | ||
val bad2 = withCap(leaking2) |