Skip to content

Commit 5b5ac6a

Browse files
nguyenyoucodex
andcommitted
chore(compiler): add top-level object dependency regression test
Add a focused Zinc callback test for the class file paired with a top-level object binary name. LLM assistance: Codex helped investigate and write the test; the callback data and targeted test result were reviewed locally. Co-Authored-By: Codex GPT-5.6 Sol (Extra High) <codex@openai.com>
1 parent 34f2030 commit 5b5ac6a

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

sbt-bridge/test/xsbt/DependencySpecification.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,30 @@ class DependencySpecification {
106106
assertEquals(Set.empty, inheritance("B"))
107107
}
108108

109+
@Test
110+
def binaryDependencyOnTopLevelObjectUsesModuleClassFile = {
111+
val upstream =
112+
"""|package example
113+
|object Api {
114+
| val value = 1
115+
|}""".stripMargin
116+
val downstream =
117+
"""|package example
118+
|object Usage {
119+
| val value = Api.value
120+
|}""".stripMargin
121+
122+
val compilerForTesting = new ScalaCompilerForUnitTesting
123+
val output = compilerForTesting.compileSrcs(List(List(upstream), List(downstream)))
124+
val downstreamSource = output.srcFiles.last
125+
val dependencyClassFiles = output.analysis.binaryDependencies.collect {
126+
case (classFile, "example.Api$", _, source, _) if source == downstreamSource =>
127+
classFile.getFileName.toString
128+
}
129+
130+
assertEquals(Seq("Api$.class"), dependencyClassFiles.toSeq)
131+
}
132+
109133
@Test
110134
def extractedTopLevelImportDependencies = {
111135
val srcA =

0 commit comments

Comments
 (0)