@@ -16,25 +16,21 @@ case class Cycles(
16
16
object Cycles {
17
17
def fromFile (file : ParsedFile ): Cycles = {
18
18
val sccs = findSCCs(file)
19
- val sccMap = sccs.zipWithIndex.flatMap { (types, i) =>
20
- types.map(_ -> i)
21
- }.toMap
19
+ val sccMap = sccs.zipWithIndex.flatMap { (types, i) => types.map(_ -> i) }
20
+ .toMap
22
21
23
22
given bindings : Bindings = Bindings .fromFile(file)
24
- val badSCCs = sccs.zipWithIndex
25
- .filter { (scc, _) =>
26
- scc.exists { typ =>
27
- val fields = typ.cases.flatMap(_.fields)
28
- fields.exists { field =>
29
- bindings.getType(field.typ) match {
30
- case neighbor : TypeDef =>
31
- field.mutable && scc(neighbor)
32
- case _ => false
33
- }
23
+ val badSCCs = sccs.zipWithIndex.filter { (scc, _) =>
24
+ scc.exists { typ =>
25
+ val fields = typ.cases.flatMap(_.fields)
26
+ fields.exists { field =>
27
+ bindings.getType(field.typ) match {
28
+ case neighbor : TypeDef => field.mutable && scc(neighbor)
29
+ case _ => false
34
30
}
35
31
}
36
32
}
37
- .map(_._2)
33
+ } .map(_._2)
38
34
39
35
Cycles (sccs, sccMap, badSCCs.toSet)
40
36
}
@@ -89,9 +85,7 @@ object Cycles {
89
85
}
90
86
91
87
for (typ <- file.typeDefs) {
92
- if (! indexOf.contains(typ)) {
93
- strongConnect(typ)
94
- }
88
+ if (! indexOf.contains(typ)) { strongConnect(typ) }
95
89
}
96
90
97
91
sccs.toList.reverse
@@ -101,6 +95,5 @@ object Cycles {
101
95
typ : TypeDef
102
96
)(using bindings : Bindings ): List [TypeDef ] = typ.cases
103
97
.flatMap(_.fields.map(field => bindings.getType(field.typ)))
104
- .collect { case td : TypeDef => td }
105
- .distinct
98
+ .collect { case td : TypeDef => td }.distinct
106
99
}
0 commit comments