@@ -192,23 +192,31 @@ object NamerOps:
192192 modcls.registeredCompanion = cls
193193
194194 /** For secondary constructors, make it known in the context that their type parameters
195- * are aliases of the class type parameters. This is done by (ab?)-using GADT constraints.
196- * See pos/i941.scala
195+ * are aliases of the class type parameters.
196+ * @return if `sym` is a secondary constructor, a fresh context that
197+ * contains GADT constraints linking the type parameters.
197198 */
198199 def linkConstructorParams (sym : Symbol )(using Context ): Context =
199200 if sym.isConstructor && ! sym.isPrimaryConstructor then
200201 sym.rawParamss match
201202 case (tparams @ (tparam :: _)) :: _ if tparam.isType =>
202203 val rhsCtx = ctx.fresh.setFreshGADTBounds
203- rhsCtx.gadt.addToConstraint(tparams)
204- tparams.lazyZip(sym.owner.typeParams).foreach { (psym, tparam) =>
205- val tr = tparam.typeRef
206- rhsCtx.gadt.addBound(psym, tr, isUpper = false )
207- rhsCtx.gadt.addBound(psym, tr, isUpper = true )
208- }
204+ linkConstructorParams(sym, tparams, rhsCtx)
209205 rhsCtx
210206 case _ =>
211207 ctx
212208 else ctx
213209
210+ /** For secondary constructor `sym`, make it known in the given context `rhsCtx`
211+ * that their type parameters are aliases of the class type parameters. This is done
212+ * by (ab?)-using GADT constraints. See pos/i941.scala.
213+ */
214+ def linkConstructorParams (sym : Symbol , tparams : List [Symbol ], rhsCtx : Context )(using Context ): Unit =
215+ rhsCtx.gadt.addToConstraint(tparams)
216+ tparams.lazyZip(sym.owner.typeParams).foreach { (psym, tparam) =>
217+ val tr = tparam.typeRef
218+ rhsCtx.gadt.addBound(psym, tr, isUpper = false )
219+ rhsCtx.gadt.addBound(psym, tr, isUpper = true )
220+ }
221+
214222end NamerOps
0 commit comments