Skip to content

Commit 701a4ae

Browse files
committed
Bugfix: Make sure to restore anonymous function infos
Make sure to restore info of anonymous functions and their parameters after cc
1 parent 60a7057 commit 701a4ae

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,9 @@ class CheckCaptures extends Recheck, SymTransformer:
444444
atPhase(preRecheckPhase.prev)(meth.denot.copySymDenotation())
445445
.installAfter(preRecheckPhase)
446446

447-
//atPhase(preRecheckPhase.prev)(meth.denot.copySymDenotation())
448-
// .installAfter(thisPhase)
449447
// Next, update all parameter symbols to match expected formals
450448
meth.paramSymss.head.lazyZip(ptformals).foreach { (psym, pformal) =>
451-
psym.copySymDenotation(info = pformal.mapExprType).installAfter(preRecheckPhase)
452-
// psym.copySymDenotation(info = pformal).installAfter(thisPhase)
453-
// println(i"UPDATE $psym to ${pformal.mapExprType}, was $pformal")
449+
psym.updateInfoBetween(preRecheckPhase, thisPhase, pformal.mapExprType)
454450
}
455451
// Next, update types of parameter ValDefs
456452
mdef.paramss.head.lazyZip(ptformals).foreach { (param, pformal) =>
@@ -464,8 +460,7 @@ class CheckCaptures extends Recheck, SymTransformer:
464460
denot.info = mt.companion(ptformals, mdef.tpt.knownType)
465461
.showing(i"simplify info of $meth to $result", capt)
466462
recheckDef(mdef, meth)
467-
meth.copySymDenotation(info = completer, initFlags = meth.flags &~ Touched)
468-
.installAfter(preRecheckPhase)
463+
meth.updateInfoBetween(preRecheckPhase, thisPhase, completer)
469464
case _ =>
470465
case _ =>
471466
super.recheckBlock(block, pt)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@annotation.experimental class C(x: () => Unit) extends caps.Pure // error
2+
3+
@annotation.experimental class D(@annotation.constructorOnly x: () => Unit) extends caps.Pure // ok
4+

0 commit comments

Comments
 (0)