From 65aeffb3feb960a31b67c2d8102341594f992230 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 12 Dec 2019 17:04:46 +0100 Subject: [PATCH] Fix #7723: Make erasedName work for module classes --- compiler/src/dotty/tools/dotc/core/SymDenotations.scala | 4 +++- tests/run/i7723.scala | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/run/i7723.scala diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 50b940ec9211..68131320e302 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -522,7 +522,9 @@ object SymDenotations { case Some(ann) => ann.arguments match { case Literal(Constant(str: String)) :: Nil => - if (isType) str.toTypeName else str.toTermName + if isTerm then str.toTermName + else if is(Module) then str.toTypeName.moduleClassName + else str.toTypeName case _ => name } case _ => name diff --git a/tests/run/i7723.scala b/tests/run/i7723.scala new file mode 100644 index 000000000000..53303b029597 --- /dev/null +++ b/tests/run/i7723.scala @@ -0,0 +1,9 @@ +object Test with + @scala.annotation.alpha("A") + class B(val i: Int = 1) + + def main(args: Array[String]): Unit = + assert(B().i == 1) + +@scala.annotation.alpha("AA") + class BB(val i: Int = 1)