File tree 3 files changed +292
-70
lines changed
compiler/src/dotty/tools/dotc 3 files changed +292
-70
lines changed Original file line number Diff line number Diff line change @@ -177,4 +177,24 @@ object NamerOps:
177
177
cls.registeredCompanion = modcls
178
178
modcls.registeredCompanion = cls
179
179
180
+ /** For secondary constructors, make it known in the context that their type parameters
181
+ * are aliases of the class type parameters. This is done by (ab?)-using GADT constraints.
182
+ * See pos/i941.scala
183
+ */
184
+ def linkConstructorParams (sym : Symbol )(using Context ): Context =
185
+ if sym.isConstructor && ! sym.isPrimaryConstructor then
186
+ sym.rawParamss match
187
+ case (tparams @ (tparam :: _)) :: _ if tparam.isType =>
188
+ val rhsCtx = ctx.fresh.setFreshGADTBounds
189
+ rhsCtx.gadt.addToConstraint(tparams)
190
+ tparams.lazyZip(sym.owner.typeParams).foreach { (psym, tparam) =>
191
+ val tr = tparam.typeRef
192
+ rhsCtx.gadt.addBound(psym, tr, isUpper = false )
193
+ rhsCtx.gadt.addBound(psym, tr, isUpper = true )
194
+ }
195
+ rhsCtx
196
+ case _ =>
197
+ ctx
198
+ else ctx
199
+
180
200
end NamerOps
Original file line number Diff line number Diff line change
1
+ package dotty .tools .dotc
2
+ package transform
3
+
4
+ import core .Phases .Phase
5
+ import core .DenotTransformers .IdentityDenotTransformer
6
+ import core .Contexts .{Context , ctx }
7
+
8
+ /** A phase that precedes the rechecker and that allows installing
9
+ * new types for local symbols.
10
+ */
11
+ class PreRecheck extends Phase , IdentityDenotTransformer :
12
+
13
+ def phaseName : String = " preRecheck"
14
+
15
+ override def isEnabled (using Context ) = next.isEnabled
16
+
17
+ override def changesBaseTypes : Boolean = true
18
+
19
+ def run (using Context ): Unit = ()
20
+
21
+ override def isCheckable = false
You can’t perform that action at this time.
0 commit comments