Skip to content

Commit

Permalink
Report error in Setup for illegal capture refs
Browse files Browse the repository at this point in the history
  • Loading branch information
bracevac committed Nov 19, 2024
1 parent 73168ee commit 346266a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import reporting.Message
import printing.{Printer, Texts}, Texts.{Text, Str}
import collection.mutable
import CCState.*
import dotty.tools.dotc.util.NoSourcePosition

/** Operations accessed from CheckCaptures */
trait SetupAPI:
Expand Down Expand Up @@ -323,7 +324,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
val parent2 = stripImpliedCaptureSet(parent1)
for tpt <- tptToCheck do
checkWellformedLater(parent2, ann.tree, tpt)
CapturingType(parent2, ann.tree.toCaptureSet)
try
CapturingType(parent2, ann.tree.toCaptureSet)
catch case ex: IllegalCaptureRef =>
report.error(em"Illegal capture reference: ${ex.getMessage.nn}", tptToCheck.fold(NoSourcePosition)(_.srcPos))
t
else
t.derivedAnnotatedType(parent1, ann)
case throwsAlias(res, exc) =>
Expand Down

0 comments on commit 346266a

Please sign in to comment.