Skip to content

Commit e5b8aa4

Browse files
committed
Maintain companion aliases as GADT bounds
1 parent 5c21114 commit e5b8aa4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,20 @@ trait NamerContextOps { this: Context =>
103103

104104
/** A new context for the interior of a class */
105105
def inClassContext(selfInfo: DotClass /* Should be Type | Symbol*/): Context = {
106-
val localCtx: Context = ctx.fresh.setNewScope
106+
var localCtx: FreshContext = ctx.fresh.setNewScope
107107
selfInfo match {
108108
case sym: Symbol if sym.exists && sym.name != nme.WILDCARD => localCtx.scope.openForMutations.enter(sym)
109109
case _ =>
110110
}
111+
if (ctx.owner.is(Module)) {
112+
val opaq = ctx.owner.companionOpaqueType
113+
opaq.getAnnotation(defn.OpaqueAliasAnnot) match {
114+
case Some(Annotation.OpaqueAlias(rhs)) =>
115+
localCtx = localCtx.setFreshGADTBounds
116+
localCtx.gadt.setBounds(opaq, TypeAlias(rhs))
117+
case _ =>
118+
}
119+
}
111120
localCtx
112121
}
113122

@@ -506,7 +515,6 @@ class Namer { typer: Typer =>
506515
case _ =>
507516
}
508517

509-
510518
def setDocstring(sym: Symbol, tree: Tree)(implicit ctx: Context) = tree match {
511519
case t: MemberDef if t.rawComment.isDefined =>
512520
ctx.docCtx.foreach(_.addDocstring(sym, t.rawComment))

0 commit comments

Comments
 (0)