diff options
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform/PostTyper.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/PostTyper.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 9821757e8..a0fe55a5b 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -104,8 +104,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran private def transformAnnot(annot: Annotation)(implicit ctx: Context): Annotation = annot.derivedAnnotation(transformAnnot(annot.tree)) + private def registerChild(sym: Symbol, tp: Type)(implicit ctx: Context) = { + val cls = tp.classSymbol + if (cls.is(Sealed)) cls.addAnnotation(Annotation.makeChild(sym)) + } + private def transformMemberDef(tree: MemberDef)(implicit ctx: Context): Unit = { val sym = tree.symbol + if (sym.is(CaseVal, butNot = Module | Method)) registerChild(sym, sym.info) sym.transformAnnotations(transformAnnot) } @@ -227,10 +233,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran // Add Child annotation to sealed parents unless current class is anonymous if (!sym.isAnonymousClass) // ignore anonymous class - for (parent <- sym.asClass.classInfo.classParents) { - val pclazz = parent.classSymbol - if (pclazz.is(Sealed)) pclazz.addAnnotation(Annotation.makeChild(sym)) - } + sym.asClass.classInfo.classParents.foreach(registerChild(sym, _)) tree } |