File tree Expand file tree Collapse file tree
compiler/src/dotty/tools/dotc/typer
tests/neg-custom-args/captures Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,7 +263,12 @@ class CheckCaptures extends Recheck:
263263 case ref : TermRef => ref.symbol.enclosure != ownEnclosure
264264 case _ => true
265265 }
266- checkSubset(targetSet, curEnv.captured, pos)
266+ def includeIn (env : Env ) =
267+ capt.println(i " Include call capture $targetSet in ${env.owner}" )
268+ checkSubset(targetSet, env.captured, pos)
269+ includeIn(curEnv)
270+ if curEnv.owner.isTerm && curEnv.outer.owner.isClass then
271+ includeIn(curEnv.outer)
267272
268273 def includeBoxedCaptures (tp : Type , pos : SrcPos )(using Context ): Unit =
269274 if curEnv.isOpen then
Original file line number Diff line number Diff line change 1+ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/nestedclass.scala:15:15 ----------------------------------
2+ 15 | val xsc: C = xs // error
3+ | ^^
4+ | Found: (xs : {cap1} C)
5+ | Required: C
6+
7+ longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ class CC
2+ type Cap = {* } CC
3+
4+ abstract class C :
5+ def head : String
6+
7+ def test (cap1 : Cap , cap2 : Cap ) =
8+ def f (x : String ): String = if cap1 == cap1 then " " else " a"
9+ def g (x : String ): String = if cap2 == cap2 then " " else " a"
10+
11+ val xs =
12+ class Cimpl extends C :
13+ def head = f(" " )
14+ new Cimpl
15+ val xsc : C = xs // error
You can’t perform that action at this time.
0 commit comments