Skip to content

Commit 8d20b2a

Browse files
authored
Fix #23737: Update superCallContext to include dummy capture parameters in scope (#23740)
Fix #23737 Typing parent types uses `superCallContext`, so this PR updates `superCallContext` to include dummy capture parameters in scope.
2 parents cda33bc + 7e53210 commit 8d20b2a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ object Contexts {
402402
*
403403
* - as owner: The primary constructor of the class
404404
* - as outer context: The context enclosing the class context
405-
* - as scope: type parameters, the parameter accessors, and
406-
* the context bound companions in the class context,
405+
* - as scope: type parameters, the parameter accessors,
406+
* the dummy capture parameters and the context bound companions in the class context,
407407
*
408408
* The reasons for this peculiar choice of attributes are as follows:
409409
*
@@ -420,7 +420,7 @@ object Contexts {
420420
def superCallContext: Context =
421421
val locals = owner.typeParams
422422
++ owner.asClass.unforcedDecls.filter: sym =>
423-
sym.is(ParamAccessor) || sym.isContextBoundCompanion
423+
sym.is(ParamAccessor) || sym.isContextBoundCompanion || sym.isDummyCaptureParam
424424
superOrThisCallContext(owner.primaryConstructor, newScopeWith(locals*))
425425

426426
/** The context for the arguments of a this(...) constructor call.

compiler/src/dotty/tools/dotc/core/SymUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class SymUtils:
9191
self.is(Synthetic) && self.infoOrCompleter.typeSymbol == defn.CBCompanion
9292

9393
def isDummyCaptureParam(using Context): Boolean =
94-
self.isAllOf(CaptureParam) && !(self.isClass || self.is(Method))
94+
self.is(PhantomSymbol) && self.infoOrCompleter.typeSymbol != defn.CBCompanion
9595

9696
/** Is this a case class for which a product mirror is generated?
9797
* Excluded are value classes, abstract classes and case classes with more than one
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import language.experimental.captureChecking
2+
3+
class C
4+
5+
trait A[T]
6+
7+
trait B[CC^] extends A[C^{CC}] // error: CC not found
8+
9+
trait D[CC^]:
10+
val x: Object^{CC} = ???
11+
12+
def f(c: C^) =
13+
val b = new B[{c}] {}
14+
val a: A[C^{c}] = b

0 commit comments

Comments
 (0)