Skip to content

Commit

Permalink
Make derivedAnnotation of universal the identity
Browse files Browse the repository at this point in the history
Fixes #14782
  • Loading branch information
odersky committed Aug 17, 2022
1 parent 5f77ad5 commit fa7ee14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/cc/CaptureAnnotation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ case class CaptureAnnotation(refs: CaptureSet, kind: CapturingKind) extends Anno
if kind == CapturingKind.ByName then defn.RetainsByNameAnnot else defn.RetainsAnnot

override def derivedAnnotation(tree: Tree)(using Context): Annotation =
unsupported("derivedAnnotation(Tree)")
if refs == CaptureSet.universal then this
else unsupported("derivedAnnotation(Tree)")

def derivedAnnotation(refs: CaptureSet, kind: CapturingKind)(using Context): Annotation =
if (this.refs eq refs) && (this.kind == kind) then this
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i14782.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object BugExample {
val urls: List[String] = List("any_url")
val closures: List[Unit => Unit] =
urls.map(url => _ => {
println("Scraping " + url)
})
for (closure <- closures) closure(())
}

0 comments on commit fa7ee14

Please sign in to comment.