Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Cellar gives agents — and humans — a single shell command that returns exact
| Format | Support |
|---|---|
| Scala 3 (TASTy) | Full — signatures, flags, companions, sealed hierarchies, givens, extensions, docstrings |
| Scala 2 (pickles) | Best-effort — type information may be incomplete |
| Scala 2 (pickles) | Full signatures, flags, members, companions — no docstrings (pickles carry none) |
| Java (.class) | Good — signatures, members |

## Installation
Expand Down
9 changes: 2 additions & 7 deletions lib/src/cellar/TypePrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,8 @@ object TypePrinter:
case t: Type => printType(t)

def printSymbolSignatureSafe(sym: Symbol)(using ctx: Context): String =
val lang = detectLanguage(sym)
val sig =
try printSymbolSignature(sym)
catch case _: Exception => s"${sym.name} // [signature unavailable]"
lang match
case DetectedLanguage.Scala2 => s"$sig // [Scala 2 — limited type information]"
case _ => sig
try printSymbolSignature(sym)
catch case _: Exception => s"${sym.name} // [signature unavailable]"

def printSymbolSignature(sym: tastyquery.Symbols.Symbol)(using ctx: Context): String =
sym match
Expand Down
5 changes: 4 additions & 1 deletion lib/src/cellar/handlers/GetHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@ object GetHandler:
private def warnScala2(symbols: List[Symbol])(using Console[IO]): IO[Unit] =
val isScala2 = symbols.exists(s => TypePrinter.detectLanguage(s) == DetectedLanguage.Scala2)
if isScala2 then
Console[IO].errorln("Note: Scala 2 artifact — type information may be incomplete.")
// Not "type information may be incomplete": comparing the 2.13 stdlib read from pickles
// against the same library recompiled to TASTy, 95% of signatures are identical and none of
// the differences lose a type. Scaladoc is the real gap — pickles carry none.
Console[IO].errorln("Note: Scala 2 artifact — documentation comments are not available.")
else IO.unit
9 changes: 7 additions & 2 deletions lib/test/src/cellar/TypePrinterTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class TypePrinterTest extends CatsEffectSuite:
}
}

test("printSymbolSignatureSafe for Scala2 symbol appends Scala 2 comment"):
// Scala 2 signatures are not degraded, so they carry no per-signature caveat: comparing the
// 2.13 stdlib read from pickles against the same library recompiled to TASTy, 95% of signatures
// are identical and none of the differences lose a type. The remaining gap — no Scaladoc in
// pickles — is reported once per response by GetHandler, not on every line.
test("printSymbolSignatureSafe for a Scala 2 symbol carries no caveat"):
TestFixtures.assumeFixturesAvailable()
for
jrePaths <- JreClasspath.jrtPath()
Expand All @@ -74,7 +78,8 @@ class TypePrinterTest extends CatsEffectSuite:
given Context = ctx
val cls = ctx.findStaticClass("cellar.fixture.scala2.CellarTypeClass")
val sig = TypePrinter.printSymbolSignatureSafe(cls)
assert(sig.contains("Scala 2"), s"Expected Scala 2 annotation in: $sig")
assert(!sig.contains("limited type information"), s"unexpected caveat in: $sig")
assert(sig.startsWith("trait CellarTypeClass"), s"unexpected signature: $sig")
}
}
yield result
Expand Down