File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/captures Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1537,6 +1537,8 @@ trait Checking {
15371537 else tree
15381538 else if ! cls.derivesFrom(defn.AnnotationClass ) then
15391539 errorTree(tree, em " $cls is not a valid Scala annotation: it does not extend `scala.annotation.Annotation` " )
1540+ else if cls == defn.AssumeSafeAnnot && Feature .safeEnabled then
1541+ errorTree(tree, em " @assumeSafe cannot be used in safe mode " )
15401542 else tree
15411543
15421544 /** Check arguments of compiler-defined annotations */
Original file line number Diff line number Diff line change 1+ import language .experimental .safe
2+ import caps .unsafe .untrackedCaptures
3+ import caps .assumeSafe
4+ import scala .collection .mutable .HashMap
5+
6+ @ assumeSafe // error
7+ class Memoized [A , B ](f : A -> B ) {
8+
9+ @ untrackedCaptures
10+ private val cached = HashMap [A , B ]()
11+
12+ val x : A => B = f.asInstanceOf [A => B ]
13+
14+ def apply (x : A ) = cached.getOrElseUpdate(x, f(x))
15+ }
You can’t perform that action at this time.
0 commit comments