From 456b13e9ba3894f1d4f9188944d2aa261d222ee1 Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Thu, 14 Aug 2025 16:53:21 +0200 Subject: [PATCH 1/3] Update superCallContext to include dummy capture parameters in scope --- compiler/src/dotty/tools/dotc/core/Contexts.scala | 6 +++--- tests/pos-custom-args/captures/i23737.scala | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tests/pos-custom-args/captures/i23737.scala diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index 9de714be8c37..5a0e03330ef2 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -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: * @@ -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. diff --git a/tests/pos-custom-args/captures/i23737.scala b/tests/pos-custom-args/captures/i23737.scala new file mode 100644 index 000000000000..d2d3f6d0cb4a --- /dev/null +++ b/tests/pos-custom-args/captures/i23737.scala @@ -0,0 +1,10 @@ +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} = ??? \ No newline at end of file From ae2a5dc7d2eda5485a81847ddf99700aa21feb6f Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Thu, 14 Aug 2025 17:52:15 +0200 Subject: [PATCH 2/3] Fix condition of checking dummy capture params --- compiler/src/dotty/tools/dotc/core/SymUtils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/SymUtils.scala b/compiler/src/dotty/tools/dotc/core/SymUtils.scala index 34908a2df6d6..f22002495bb3 100644 --- a/compiler/src/dotty/tools/dotc/core/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/SymUtils.scala @@ -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 From 7e5321079f4d6572245a9e4481d4f3107d4891e6 Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Fri, 15 Aug 2025 10:27:34 +0200 Subject: [PATCH 3/3] Update test --- tests/pos-custom-args/captures/i23737.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/pos-custom-args/captures/i23737.scala b/tests/pos-custom-args/captures/i23737.scala index d2d3f6d0cb4a..3d2bb4f6791b 100644 --- a/tests/pos-custom-args/captures/i23737.scala +++ b/tests/pos-custom-args/captures/i23737.scala @@ -7,4 +7,8 @@ trait A[T] trait B[CC^] extends A[C^{CC}] // error: CC not found trait D[CC^]: - val x: Object^{CC} = ??? \ No newline at end of file + val x: Object^{CC} = ??? + +def f(c: C^) = + val b = new B[{c}] {} + val a: A[C^{c}] = b \ No newline at end of file