Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/src/cellar/TypePrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines 95 to +99
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior for TermSymbol module vals (skipping the declared type signature) isn’t covered by tests. Consider adding a TypePrinterTest case that resolves an object via ctx.findStaticTerm(...) (module val) and asserts the signature prints as object <Name> and does not include the module class type (e.g., no trailing $).

Copilot uses AI. Check for mistakes.

case other => other.toString

Expand Down
20 changes: 20 additions & 0 deletions lib/test/src/cellar/TypePrinterTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading