Skip to content

Commit c0b545b

Browse files
oderskysmarter
authored andcommitted
Keep rhs of TypeDef in typed tree
This is important for IDEs who want to see the full tree. The tree now gets replaced by a TypeTree in PostTyper.
1 parent dd73318 commit c0b545b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
180180
case tree: DefDef =>
181181
transformAnnots(tree)
182182
superAcc.wrapDefDef(tree)(super.transform(tree).asInstanceOf[DefDef])
183+
case tree: TypeDef =>
184+
transformAnnots(tree)
185+
val sym = tree.symbol
186+
val tree1 =
187+
if (sym.isClass) tree
188+
else {
189+
cpy.TypeDef(tree)(rhs = TypeTree(tree.symbol.info))
190+
}
191+
super.transform(tree1)
183192
case tree: MemberDef =>
184193
transformAnnots(tree)
185194
super.transform(tree)

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
961961
val TypeDef(name, rhs) = tdef
962962
checkLowerNotHK(sym, tdef.tparams.map(symbolOfTree), tdef.pos)
963963
completeAnnotations(tdef, sym)
964-
val _ = typedType(rhs) // unused, typecheck only to remove from typedTree
965-
assignType(cpy.TypeDef(tdef)(name, TypeTree(sym.info), Nil), sym)
964+
assignType(cpy.TypeDef(tdef)(name, typedType(rhs), Nil), sym)
966965
}
967966

968967
def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context) = track("typedClassDef") {

0 commit comments

Comments
 (0)