Skip to content

Commit 141cea9

Browse files
committed
Avoid including call captures twice when applying a method
1 parent d97dfea commit 141cea9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,12 @@ class CheckCaptures extends Recheck, SymTransformer:
291291
if sym.exists && curEnv.isOpen then markFree(capturedVars(sym), pos)
292292

293293
override def recheckIdent(tree: Ident)(using Context): Type =
294-
if tree.symbol.is(Method) then includeCallCaptures(tree.symbol, tree.srcPos)
295-
else markFree(tree.symbol, tree.srcPos)
294+
if tree.symbol.is(Method) then
295+
if tree.symbol.info.isParameterless then
296+
// there won't be an apply; need to include call captures now
297+
includeCallCaptures(tree.symbol, tree.srcPos)
298+
else
299+
markFree(tree.symbol, tree.srcPos)
296300
super.recheckIdent(tree)
297301

298302
/** A specialized implementation of the selection rule.

0 commit comments

Comments
 (0)