Skip to content

Fix #23737: Update superCallContext to include dummy capture parameters in scope #23740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ object Contexts {
*
* - as owner: The primary constructor of the class
* - as outer context: The context enclosing the class context
* - as scope: type parameters, the parameter accessors, and
* the context bound companions in the class context,
* - as scope: type parameters, the parameter accessors,
* the dummy capture parameters and the context bound companions in the class context,
*
* The reasons for this peculiar choice of attributes are as follows:
*
Expand All @@ -420,7 +420,7 @@ object Contexts {
def superCallContext: Context =
val locals = owner.typeParams
++ owner.asClass.unforcedDecls.filter: sym =>
sym.is(ParamAccessor) || sym.isContextBoundCompanion
sym.is(ParamAccessor) || sym.isContextBoundCompanion || sym.isDummyCaptureParam
superOrThisCallContext(owner.primaryConstructor, newScopeWith(locals*))

/** The context for the arguments of a this(...) constructor call.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SymUtils:
self.is(Synthetic) && self.infoOrCompleter.typeSymbol == defn.CBCompanion

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

/** Is this a case class for which a product mirror is generated?
* Excluded are value classes, abstract classes and case classes with more than one
Expand Down
14 changes: 14 additions & 0 deletions tests/pos-custom-args/captures/i23737.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import language.experimental.captureChecking

class C

trait A[T]

trait B[CC^] extends A[C^{CC}] // error: CC not found

trait D[CC^]:
val x: Object^{CC} = ???

def f(c: C^) =
val b = new B[{c}] {}
val a: A[C^{c}] = b
Loading