File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
src/dotty/tools/dotc/printing
test/dotty/tools/dotc/printing Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -745,8 +745,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
745
745
case info : ImportType => return s " import $info.expr.show "
746
746
case _ =>
747
747
}
748
- if (sym.is(ModuleClass ))
749
- kindString(sym) ~~ (nameString(sym.name.stripModuleClassSuffix) + idString(sym))
748
+ if (sym.is(ModuleClass )) {
749
+ val name =
750
+ if (sym.isPackageObject) sym.owner.name
751
+ else sym.name.stripModuleClassSuffix
752
+ kindString(sym) ~~ (nameString(name) + idString(sym))
753
+ }
750
754
else
751
755
super .toText(sym)
752
756
}
Original file line number Diff line number Diff line change
1
+ package dotty .tools .dotc .printing
2
+
3
+ import dotty .tools .DottyTest
4
+ import dotty .tools .dotc .ast .tpd
5
+ import dotty .tools .dotc .core .Names ._
6
+ import dotty .tools .dotc .core .Symbols ._
7
+ import org .junit .Assert .assertEquals
8
+ import org .junit .Test
9
+
10
+ class PrinterTests extends DottyTest {
11
+ import tpd ._
12
+
13
+ @ Test
14
+ def packageObject : Unit = {
15
+ val source = """
16
+ package object foo {
17
+ def bar: Int = 1
18
+ }
19
+ """
20
+
21
+ checkCompile(" frontend" , source) { (tree, context) =>
22
+ implicit val ctx = context
23
+ val bar = tree.find(tree => tree.symbol.name == termName(" bar" )).get
24
+ assertEquals(" package object foo" , bar.symbol.owner.show)
25
+ }
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments