From fbe8816fd17acd6130d78b2201ce55ed88a7cda1 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 24 Mar 2026 11:47:57 +0100 Subject: [PATCH 1/2] Fix companion object name being doubled in search results Module val symbols (companion objects) were printing both the term name and their declared type (a TypeRef to the module class), producing output like "object LoggerSupportLoggerSupport$". Skip the type signature for module vals since "object Name" is sufficient. Fixes #11 Co-Authored-By: Claude Sonnet 4.6 --- lib/src/cellar/TypePrinter.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 From 4ac030c4dfef505817db66b047d59e79bbe9c121 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 24 Mar 2026 16:20:04 +0100 Subject: [PATCH 2/2] Add tests for companion object printer fix Test that printSymbolSignature for a companion object term symbol produces "object CellarTC" without doubling the name, and that the module class variant starts with "object". Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/test/src/cellar/TypePrinterTest.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 {