Skip to content

[1.x] Tell objects and classes apart in inheritance dependency tracking (backport of #1807, #1809, #1837) - #1839

Merged
retronym merged 5 commits into
sbt:1.12.xfrom
retronym:backport/1.12.x-z2-name-kinds
Oct 7, 2026
Merged

retronym merged 5 commits into
sbt:1.12.xfrom
retronym:backport/1.12.x-z2-name-kinds

Conversation

@retronym

@retronym retronym commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Backports #1807 and #1809 to 1.12.x. Unlike the rest of the 1.12.x backports, this one adds public API to compiler-interface, so it is separate and needs a maintainer decision.

Problem

Dependency tracking records object B extends A and trait B extends A as the same edge from B to A. With a plain trait B and a companion object B extends A, subclasses of B then depend on A's private members, so changes in A recompile them needlessly (#1795).

Change

The bridge reports whether the dependent name is a term or a type, and only the type side's parents go into a trait's extraHash.

API addition: compiler-interface gains xsbti.AnalysisCallback4 (extends AnalysisCallback3), xsbti.ClassRef and xsbti.NameKind. It is purely additive. Bridges that don't implement it (older zinc bridges, the current scala2-sbt-bridge, Scala 3) fall back to the String overloads, which treat every name as a type and so behave as before. scala2-sbt-bridge can only adopt it once this is in a zinc release.

Commit Upstream
Add pending test for module-side inheritance in trait extraHash #1807
Tell a class and its companion object apart in dependencies #1807
Name the used-name kinds after the qualifier #1809 (renames an API added in #1807, before release)
Fix stray '>' in AnalysisCallback4 Javadoc #1835 (JDK 8 and 11 javadoc reject it)
Run "2.13.y" scripted projects on scala2-sbt-bridge #1837 (test-only)

The last commit makes scripted select bridges by label, so "2.13.y" projects run on scala2-sbt-bridge instead of zinc's own bridge sources. Its pending module-inheritance-extra-hash-213-bin fails on the stock bridge and passes with retronym/scala#135, which shows the bridge half of #1807 is needed on 2.13.

Deviations from upstream

  • Incremental.scala is ported to Scala 2 syntax, keeping private[this] as on 1.12.x. The Java interfaces, bridge sources, JavaAnalyze, TestCallback and the tests apply unchanged.
  • Run "2.13.y" scripted projects on scala2-sbt-bridge #1837: IncHandler and BridgeProviderTestkit are ported to Scala 2 syntax. project/Dependencies.scala is unchanged (scala213ForBridge is already 2.13.18), and the scripted-test docs it extends don't exist on 1.12.x.

Tests

  • module-inheritance-extra-hash (scripted, new) fails without the change and passes with it.
  • pipelining/trait-extends-java-interface (scripted, new) guards the Java-parent path of the new code.

AI disclosure

LLM assisted, but fully human reviewed.

lrytz and others added 5 commits October 6, 2026 07:24
…t#1807)

Backport of sbt#1807 (develop 0a46334).

Adds xsbti.AnalysisCallback4, ClassRef and NameKind to compiler-interface
(additive). Bridges that don't implement it behave as before.

Deviations from upstream:
- Incremental.scala hand-ported to Scala 2 syntax; private[this] kept as on 1.12.x.
Backport of sbt#1835 (develop 4fa2eae).

`<code>AnalyzedClass</code>>` has an extra '>'. javadoc on JDK 8 and 11
rejects it ("bad use of '>'"), which fails the doc task there.
Backport of sbt#1837 (develop 7080f96).

Scripted picked a bridge by Scala version and took the first match, so
"2.13.y" projects ran on zinc's own compiler-bridge sources rather than
on scala2-sbt-bridge. Select bridges by label instead, add a checkBridge
scripted command with a general/bridge-* test per label, fail a scripted
test whose projects use different labels, and add
module-inheritance-extra-hash-213-bin as a pending test of sbt#1807's
bridge side on scala2-sbt-bridge.

Deviations from upstream:
- IncHandler and BridgeProviderTestkit are ported to Scala 2 syntax;
  1.12.x's ScalaBridge entries keep their class directory only.
- project/Dependencies.scala is unchanged: scala213ForBridge is already
  2.13.18 on 1.12.x.
- contributing-docs/03_scripted_tests.md does not exist on 1.12.x, so
  the documentation of the labels is not ported.
@retronym
retronym force-pushed the backport/1.12.x-z2-name-kinds branch from 2793555 to a4d31f9 Compare October 5, 2026 21:24
@retronym
retronym marked this pull request as ready for review October 5, 2026 21:24
* can tell the two apart. A bridge that only calls the inherited overloads keeps
* the previous behaviour, where they are conflated.
*/
public interface AnalysisCallback4 extends AnalysisCallback3 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm. Thanks

@retronym
retronym merged commit 3c098ce into sbt:1.12.x Oct 7, 2026
8 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.

3 participants