Skip to content

Fix Scala 3 top-level rendering bugs#86

Open
rochala wants to merge 1 commit into
mainfrom
fix/top-level-rendering
Open

Fix Scala 3 top-level rendering bugs#86
rochala wants to merge 1 commit into
mainfrom
fix/top-level-rendering

Conversation

@rochala

@rochala rochala commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes several rendering bugs introduced in #81 (Scala 3 top-level defs/types/objects support).

Bugs fixed

TypePrinter

  • Parameterless def/val was missing the : separator — def hello printed as def helloUnit instead of def hello: Unit
  • TypeMemberSymbol had no case, falling through to a raw toString sentinel — opaque type Hello = Int printed as symbol[...]

GetFormatter

  • $package$ wrapper segments and trailing $ leaked into the ## heading and Origin line
  • renderSubtypes called displayFullName without userFqn, so case object / object sealed children showed a trailing $ in the Known subtypes line (e.g. CellarB$)

SymbolResolver

  • @main def foo generates a synthetic launcher class foo with only <init> + main. When a top-level def with the same FQN exists, the launcher is now filtered from results. Uses subsetOf instead of exact-set equality for resilience against future Scala versions adding extra synthetics.

Tests added

Three end-to-end formatter tests in GetFormatterTest that resolve through SymbolResolver and assert on the actual rendered Markdown:

  • @main def hello → heading, origin, signature, no synthetic class leak
  • opaque type Hello = Int → correct opaque type rendering
  • Hello.fromInt companion member → heading and origin hide $package$

Also

Added a principle to CLAUDE.md requiring end-to-end output verification when fixing rendering bugs.

🤖 Generated with Claude Code

- TypePrinter: parameterless def/val now prints ': Type' (was missing colon)
- TypePrinter: add TypeMemberSymbol case for opaque types, type aliases,
  abstract types (was falling through to toString sentinel)
- GetFormatter: apply userFqn() to FQN heading and origin so $package$
  wrapper segments and trailing $ never appear in output
- GetFormatter: apply userFqn() in renderSubtypes so case object / object
  sealed children don't leak trailing $ in Known subtypes line
- SymbolResolver: filter @main launcher class from results when a top-level
  def with the same FQN exists; use subsetOf for future-proofing
- GetFormatterTest: add 3 end-to-end formatter tests for @main def,
  opaque type, and companion member
- CLAUDE.md: add principle to verify e2e output quality when fixing bugs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant