Skip to content

Commit 8d3c7a2

Browse files
committed
Erase rhs of erased non inlined val/def in PostTyper
1 parent 954c25b commit 8d3c7a2

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ object PostTyper {
4040
*
4141
* (10) Adds Child annotations to all sealed classes
4242
*
43-
* (11) Minimizes `call` fields of `Inlined` nodes to just point to the toplevel
44-
* class from which code was inlined.
43+
* (11) Replace RHS of `erased` (but not `inline`) members by `(???: rhs.type)`
4544
*
4645
* The reason for making this a macro transform is that some functions (in particular
4746
* super and protected accessors and instantiation checks) are naturally top-down and
@@ -183,14 +182,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
183182
ctx.compilationUnit.containsInlineCalls = true
184183
}
185184

186-
private object dropInlines extends TreeMap {
187-
override def transform(tree: Tree)(implicit ctx: Context): Tree = tree match {
188-
case Inlined(call, _, _) =>
189-
cpy.Inlined(tree)(call, Nil, Typed(ref(defn.Predef_undefined), TypeTree(tree.tpe)))
190-
case _ => super.transform(tree)
191-
}
192-
}
193-
194185
override def transform(tree: Tree)(implicit ctx: Context): Tree =
195186
try tree match {
196187
case tree: Ident if !tree.isType =>
@@ -218,7 +209,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
218209
tree.fun,
219210
tree.args.map(arg =>
220211
if (methType.isImplicitMethod && arg.pos.isSynthetic) ref(defn.Predef_undefined)
221-
else dropInlines.transform(arg)))
212+
else arg))
222213
else
223214
tree
224215
methPart(app) match {
@@ -328,9 +319,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
328319
}
329320

330321
/** Transforms the rhs tree into a its default tree if it is in an `erased` val/def.
331-
* Performed to shrink the tree that is known to be erased later.
332-
*/
322+
* Performed to shrink the tree that is known to be erased later.
323+
*/
333324
private def normalizeErasedRhs(rhs: Tree, sym: Symbol)(implicit ctx: Context) =
334-
if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
325+
if (!sym.isEffectivelyErased || sym.isInlineMethod || !rhs.tpe.exists) rhs
326+
else Typed(ref(defn.Predef_undefined), TypeTree(rhs.tpe))
335327
}
336328
}

0 commit comments

Comments
 (0)