diff options
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform/PostTyper.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/PostTyper.scala | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 9821757e8..bacb88091 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 = Method | Module)) registerChild(sym, sym.info) sym.transformAnnotations(transformAnnot) } @@ -227,9 +233,9 @@ 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 { parent => + val sym2 = if (sym.is(Module)) sym.sourceModule else sym + registerChild(sym2, parent) } tree |