diff --git a/lib/src/cellar/TypePrinter.scala b/lib/src/cellar/TypePrinter.scala index 569b4f0..062dbc5 100644 --- a/lib/src/cellar/TypePrinter.scala +++ b/lib/src/cellar/TypePrinter.scala @@ -93,8 +93,10 @@ object TypePrinter: case term: TermSymbol => val keyword = termKeyword(term) - val sig = printMethodic(term.declaredType) - s"$keyword ${term.name}$sig" + if term.isModuleVal then s"$keyword ${term.name}" + else + val sig = printMethodic(term.declaredType) + s"$keyword ${term.name}$sig" case other => other.toString diff --git a/lib/test/src/cellar/TypePrinterTest.scala b/lib/test/src/cellar/TypePrinterTest.scala index 1a99bbe..f11b785 100644 --- a/lib/test/src/cellar/TypePrinterTest.scala +++ b/lib/test/src/cellar/TypePrinterTest.scala @@ -69,6 +69,26 @@ class TypePrinterTest extends CatsEffectSuite: } yield result + test("printSymbolSignature for companion object term does not double the name"): + withCtx { ctx => + IO.blocking { + given Context = ctx + val term = ctx.findStaticTerm("cellar.fixture.scala3.CellarTC") + val sig = TypePrinter.printSymbolSignature(term) + assertEquals(sig, "object CellarTC") + } + } + + test("printSymbolSignature for companion object class prints module class name"): + withCtx { ctx => + IO.blocking { + given Context = ctx + val cls = ctx.findStaticModuleClass("cellar.fixture.scala3.CellarTC") + val sig = TypePrinter.printSymbolSignature(cls) + assert(sig.startsWith("object"), s"Expected 'object' keyword in: $sig") + } + } + test("printSymbolSignatureSafe does not throw for Java symbol"): withCtx { ctx => IO.blocking {