Fix Scala 2 nested-object display and several signature bugs#87
Open
rochala wants to merge 2 commits into
Open
Fix Scala 2 nested-object display and several signature bugs#87rochala wants to merge 2 commits into
rochala wants to merge 2 commits into
Conversation
Adds cellar.fixture.scala2.CellarADT — a sealed trait whose subtypes (CellarAA, CellarAB) live inside its companion object, which is the idiomatic Scala 2 ADT pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Problem
-------
Querying a Scala 2 sealed ADT (sealed trait T; object T { case object A
extends T }) produced garbled output: subtype names used JVM $-encoding
(CellarADT$.CellarAA$), module class appeared as a third duplicate
result block, zero-param defs were missing the ': ReturnType' colon,
<init> constructors leaked into member lists, and the package-object
prefix ('package.List') was not stripped from Scala 2 type names.
Changes
-------
GetFormatter
- normalizeScala2FQN: strips '$.' → '.' and trailing '$' from
displayFullName; applied to heading FQN, Origin field, and subtype
list so all user-visible names use source-level dotted notation.
- renderMembers: handle TermSymbol (module val) by delegating to its
module class, so standalone objects keep their members after the
module-class deduplication in SymbolResolver.
PublicApiFilter
- Filter <init> constructor symbols from member listings.
SymbolResolver
- Deduplicate module classes whose module val is also in the result
set; findStaticModuleClass returning raw Foo$ alongside findStaticTerm
returning the object val previously produced a spurious third block.
TypePrinter
- TermSymbol with a plain Type declared type (Scala 2 zero-param def):
render as 'def foo: T' instead of 'def fooT' (was missing the colon).
- PolyType result type: add ': ' separator before the return type when
the result is a plain Type (e.g. '[A]: List[A]' not '[A]List[A]').
- TypeRef prefix: skip prefix when it prints as 'package' to suppress
the Scala 2 package-object artefact ('package.List' → 'List').
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Querying a Scala 2 sealed ADT — the idiomatic
sealed trait T; object T { case object A extends T }pattern — produced garbled output:$-encoding (CellarADT$.CellarAA$instead ofCellarADT.CellarAA)': ReturnType'colon (def isValidinstead ofdef isValid: Boolean)[A]List[A]instead of[A]: List[A])<init>constructor symbols leaked into member listingspackage.Listinstead ofList)Changes
GetFormatternormalizeScala2FQN: strips$.→.and trailing$fromdisplayFullName; applied to heading, Origin field, and subtype list so all user-visible names use source-level dotted notationrenderMembers: handleTermSymbol(module val) by delegating to its module class, so standalone objects keep their members after the module-class deduplicationPublicApiFilter<init>constructor symbols from member listingsSymbolResolverfindStaticModuleClassreturning rawFoo$alongsidefindStaticTermreturning the object val previously produced a spurious third blockTypePrinterTermSymbolwith a plainTypedeclared type (Scala 2 zero-param def): render asdef foo: Tinstead ofdef fooTPolyTyperesult: add': 'separator before the return type when the result is a plainTypeTypeRefprefix: skip prefix when it prints as"package"to suppress the Scala 2 package-object artefactNew fixture:
fixtureScala2/src/cellar/fixture/scala2/CellarADT.scala— sealed ADT with companion-nested subtypes🤖 Generated with Claude Code