File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
compiler/src/dotty/tools/dotc/cc Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -489,7 +489,8 @@ class CheckCaptures extends Recheck, SymTransformer:
489
489
/** Class-specific capture set relations:
490
490
* 1. The capture set of a class includes the capture sets of its parents.
491
491
* 2. The capture set of the self type of a class includes the capture set of the class.
492
- * 3. The capture set of the self type of a class includes the capture set of every class parameter.
492
+ * 3. The capture set of the self type of a class includes the capture set of every class parameter,
493
+ * unless the parameter is marked @constructorOnly.
493
494
*/
494
495
override def recheckClassDef (tree : TypeDef , impl : Template , cls : ClassSymbol )(using Context ): Type =
495
496
val saved = curEnv
@@ -501,7 +502,8 @@ class CheckCaptures extends Recheck, SymTransformer:
501
502
val thisSet = cls.classInfo.selfType.captureSet.withDescription(i " of the self type of $cls" )
502
503
checkSubset(localSet, thisSet, tree.srcPos) // (2)
503
504
for param <- cls.paramGetters do
504
- checkSubset(param.termRef.captureSet, thisSet, param.srcPos) // (3)
505
+ if ! param.hasAnnotation(defn.ConstructorOnlyAnnot ) then
506
+ checkSubset(param.termRef.captureSet, thisSet, param.srcPos) // (3)
505
507
super .recheckClassDef(tree, impl, cls)
506
508
finally
507
509
curEnv = saved
You can’t perform that action at this time.
0 commit comments