Skip to content

Commit b50d209

Browse files
committed
Make Constructors change owners.
1 parent e1c482a commit b50d209

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
9595
if (noDirectRefsFrom(tree)) tree else super.transform(tree)
9696
}
9797

98-
def apply(tree: Tree, inSuperCall: Boolean = false)(implicit ctx: Context): Tree = {
98+
def apply(tree: Tree, prevOwner: Symbol, inSuperCall: Boolean = false)(implicit ctx: Context): Tree = {
9999
this.excluded = if (inSuperCall) EmptyFlags else Mutable
100-
transform(tree)
100+
transform(tree).changeOwnerAfter(prevOwner, constr.symbol, thisTransform)
101101
}
102102
}
103103

@@ -153,19 +153,19 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
153153
val sym = stat.symbol
154154
if (isRetained(sym)) {
155155
if (!stat.rhs.isEmpty && !isWildcardArg(stat.rhs))
156-
constrStats += Assign(ref(sym), intoConstr(stat.rhs)).withPos(stat.pos)
156+
constrStats += Assign(ref(sym), intoConstr(stat.rhs, sym)).withPos(stat.pos)
157157
clsStats += cpy.ValDef(stat)(rhs = EmptyTree)
158158
}
159159
else if (!stat.rhs.isEmpty) {
160160
sym.copySymDenotation(
161161
initFlags = sym.flags &~ Private,
162162
owner = constr.symbol).installAfter(thisTransform)
163-
constrStats += intoConstr(stat)
163+
constrStats += intoConstr(stat, sym)
164164
}
165165
case _: DefTree =>
166166
clsStats += stat
167167
case _ =>
168-
constrStats += intoConstr(stat)
168+
constrStats += intoConstr(stat, tree.symbol)
169169
}
170170
splitStats(stats1)
171171
case Nil =>

0 commit comments

Comments
 (0)