Skip to content

Fix companion object name being doubled in search results#15

Merged
rochala merged 2 commits intomainfrom
fix-companion-object-printer
Mar 24, 2026
Merged

Fix companion object name being doubled in search results#15
rochala merged 2 commits intomainfrom
fix-companion-object-printer

Conversation

@rochala
Copy link
Copy Markdown
Contributor

@rochala rochala commented Mar 24, 2026

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 noreply@anthropic.com

  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 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect signature printing for companion objects (module val TermSymbols) in search/get output by avoiding appending the module class type (which previously produced duplicated names like object LoggerSupportLoggerSupport$).

Changes:

  • Update TypePrinter.printSymbolSignature to skip declaredType rendering for term.isModuleVal.
  • Preserve existing signature rendering for non-module term symbols.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 95 to +99
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"
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.
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) <noreply@anthropic.com>
@rochala rochala merged commit 3094937 into main Mar 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Printer for companion objects is incorrect

2 participants