Skip to content

Commit dd58f75

Browse files
committed
Fix the test by ignoring synthetic symbols
1 parent c387ef2 commit dd58f75

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import dotty.tools.dotc.core.NameOps.*
1616
import dotty.tools.dotc.core.Names.*
1717
import dotty.tools.dotc.core.Phases.*
1818
import dotty.tools.dotc.core.Symbols.*
19+
import dotty.tools.dotc.core.Definitions
1920
import dotty.tools.dotc.core.Denotations.StaleSymbol
2021
import dotty.tools.dotc.core.Types.*
2122

@@ -75,7 +76,7 @@ class ExtractDependencies extends Phase {
7576
override def run(using Context): Unit = {
7677
val unit = ctx.compilationUnit
7778
val rec = unit.depRecorder
78-
val collector = ExtractDependenciesCollector(rec)
79+
val collector = ExtractDependenciesCollector(rec, defn)
7980
collector.traverse(unit.tpdTree)
8081

8182
if (ctx.settings.YdumpSbtInc.value) {
@@ -137,7 +138,7 @@ object ExtractDependencies {
137138
* specially, see the subsection "Dependencies introduced by member reference and
138139
* inheritance" in the "Name hashing algorithm" section.
139140
*/
140-
private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.TreeTraverser { thisTreeTraverser =>
141+
private class ExtractDependenciesCollector(rec: DependencyRecorder, defn: Definitions) extends tpd.TreeTraverser { thisTreeTraverser =>
141142
import tpd.*
142143

143144
private def addMemberRefDependency(sym: Symbol)(using Context): Unit =
@@ -169,14 +170,23 @@ private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.
169170
if cls.isLocal then LocalDependencyByInheritance
170171
else DependencyByInheritance
171172

173+
private val ignoredSymbols = Set[Symbol](
174+
defn.syntheticScalaClasses*
175+
) ++ Set(
176+
defn.ClassClass,
177+
defn.ModuleSerializationProxyClass,
178+
defn.ModuleSerializationProxyConstructor,
179+
)
180+
172181
private def ignoreDependency(sym: Symbol)(using Context) =
173182
try
174183
!sym.exists ||
175184
sym.isAbsent(canForce = false) || // ignore dependencies that have a symbol but do not exist.
176185
// e.g. java.lang.Object companion object
177186
sym.isEffectiveRoot ||
178187
sym.isAnonymousFunction ||
179-
sym.isAnonymousClass
188+
sym.isAnonymousClass ||
189+
ignoredSymbols(sym)
180190
catch case ex: StaleSymbol =>
181191
// can happen for constructor proxies. Test case is pos-macros/i13532.
182192
true

sbt-bridge/test/xsbt/ExtractUsedNamesSpecification.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class ExtractUsedNamesSpecification {
7878
val compilerForTesting = new ScalaCompilerForUnitTesting
7979
val usedNames = compilerForTesting.extractUsedNamesFromSrc(srcA, srcB, srcC, srcD)
8080
val scalaVersion = scala.util.Properties.versionNumberString
81-
val namesA = standardNames ++ Set("Nothing", "Any")
82-
val namesAX = standardNames ++ Set("x", "T", "A", "Nothing", "Any")
81+
val namesA = standardNames
82+
val namesAX = standardNames ++ Set("x", "T", "A")
8383
val namesB = Set("A", "Int", "A;init;", "Unit")
84-
val namesC = Set("B;init;", "B", "Unit")
84+
val namesC = Set("B;init;", "B", "Unit", "Object")
8585
val namesD = standardNames ++ Set("C", "X", "foo", "Int", "T")
8686
assertEquals(namesA, usedNames("A"))
8787
assertEquals(namesAX, usedNames("A.X"))
@@ -143,17 +143,15 @@ class ExtractUsedNamesSpecification {
143143
"M",
144144
"N",
145145
"Predef",
146-
"???",
147-
"Nothing")
146+
"???")
148147
val expectedNames_bar =
149148
standardNames ++
150149
Set("B",
151150
"bar",
152151
"P1",
153152
"P0",
154153
"Predef",
155-
"???",
156-
"Nothing")
154+
"???")
157155
assertEquals(expectedNames_lista, usedNames("Test_lista"))
158156
assertEquals(expectedNames_at, usedNames("Test_at"))
159157
assertEquals(expectedNames_as, usedNames("Test_as"))

sbt-test/source-dependencies/inline-rec-change-inline/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ copy-file changes/B1.scala B.scala
66
> compile
77
# 1 to recompile B, then 1 more to recompile A due to B.inlinedAny change,
88
# then 1 final compilation to recompile C due to A.callInline change
9-
> checkIterations 3
9+
> checkIterations 2

sbt-test/source-dependencies/inline-rec-change-param/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ copy-file changes/B1.scala B.scala
66
> compile
77
# 1 to recompile B, then 1 more to recompile A due to B.inlinedAny change,
88
# then 1 final compilation to recompile C due to A.callInline change
9-
> checkIterations 3
9+
> checkIterations 2

sbt-test/source-dependencies/inline-rec-change-res-transparent/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ copy-file changes/B1.scala B.scala
66
> compile
77
# 1 to recompile B, then 1 more to recompile A due to B.inlinedAny change,
88
# then 1 final compilation to recompile C due to A.callInline change
9-
> checkIterations 3
9+
> checkIterations 2

sbt-test/source-dependencies/inline-rec-change-res/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ copy-file changes/B1.scala B.scala
66
> compile
77
# 1 to recompile B, then 1 more to recompile A due to B.inlinedAny change,
88
# then 1 final compilation to recompile C due to A.callInline change
9-
> checkIterations 3
9+
> checkIterations 2

sbt-test/source-dependencies/inline-rec-change-typaram/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ $ copy-file changes/B1.scala B.scala
66
> compile
77
# 1 to recompile B, then 1 more to recompile A due to B.inlinedAny change,
88
# then 1 final compilation to recompile C due to A.callInline change
9-
> checkIterations 3
9+
> checkIterations 2

sbt-test/source-dependencies/inline-rec-deep/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ $ copy-file changes/C1.scala C.scala
77
# 1 to recompile C, then 1 more to recompile B due to C.inlinedAny change,
88
# then 1 more to recompile A due to B.delegated change, then 1 final compilation
99
# to recompile D due to A.callInline change
10-
> checkIterations 4
10+
> checkIterations 3

0 commit comments

Comments
 (0)