From 4453b485d024d7857db068323726ab92b1776445 Mon Sep 17 00:00:00 2001 From: rochala Date: Sun, 23 Aug 2026 13:57:58 +0200 Subject: [PATCH] Drop the blanket Scala 2 caveat; report the real gap instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every Scala 2 signature carried `// [Scala 2 — limited type information]`, appended on source language alone rather than on any evidence of loss — about 70 times in a single cats.data.NonEmptyList lookup. Measured it. Comparing scala-library 2.13.16 (pickles) against scala2-library-tasty-experimental_3 (the same stdlib recompiled to TASTy): 2878 signature lines over 76 symbols, 95.4% byte-identical after normalisation, and no case where the Scala 2 side lost a type the Scala 3 side had. Where they diverge the Scala 2 rendering is the better one more often than the worse (70 lines to 22), and the TASTy side is the one that failed to load 5 of 81 symbols. The real Scala 2 gap is documentation: pickles carry no Scaladoc, so 0 of 76 lookups had prose docs versus 70 of 76 from TASTy. So the per-signature caveat goes, and the once-per-response footer now states what is true. The README support table repeated the same inaccurate claim; corrected. Co-Authored-By: Claude Opus 5 --- README.md | 2 +- lib/src/cellar/TypePrinter.scala | 9 ++------- lib/src/cellar/handlers/GetHandler.scala | 5 ++++- lib/test/src/cellar/TypePrinterTest.scala | 9 +++++++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 57dd5d7..bbe4c62 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/src/cellar/TypePrinter.scala b/lib/src/cellar/TypePrinter.scala index 89cff55..c33824a 100644 --- a/lib/src/cellar/TypePrinter.scala +++ b/lib/src/cellar/TypePrinter.scala @@ -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 diff --git a/lib/src/cellar/handlers/GetHandler.scala b/lib/src/cellar/handlers/GetHandler.scala index 46aa8e8..11cc738 100644 --- a/lib/src/cellar/handlers/GetHandler.scala +++ b/lib/src/cellar/handlers/GetHandler.scala @@ -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 diff --git a/lib/test/src/cellar/TypePrinterTest.scala b/lib/test/src/cellar/TypePrinterTest.scala index ec7ee5b..1944847 100644 --- a/lib/test/src/cellar/TypePrinterTest.scala +++ b/lib/test/src/cellar/TypePrinterTest.scala @@ -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() @@ -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