Skip to content

Commit 97c5d92

Browse files
committed
Workaround the broken hashCode of api.* classes
When adding a single field to `Type`, incremental compilation using Scala 2.12 was compiling 1 file, then 12 files, then stopped. But incremental compilation with Dotty did not stop until the whole project was recompiled, this happened because lookups in the `refinedTypeCache` failed, which I tracked down to sbt-contraband generating broken hashCode implementations (sbt/contraband#119). We work around this by using a ListMap instead of a HashMap.
1 parent 4b862f8 commit 97c5d92

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
137137
/** This cache is necessary to avoid unstable name hashing when `typeCache` is present,
138138
* see the comment in the `RefinedType` case in `computeType`
139139
* The cache key is (api of RefinedType#parent, api of RefinedType#refinedInfo).
140-
*/
141-
private[this] val refinedTypeCache = new mutable.HashMap[(api.Type, api.Definition), api.Structure]
140+
*/
141+
// FIXME: This should be a HashMap but cannot be until the fix for
142+
// https://github.com/sbt/contraband/issues/119 is part of a released version
143+
// of sbt, until then we cannot rely on the hashCode method of the api.* classes.
144+
private[this] val refinedTypeCache = new mutable.ListMap[(api.Type, api.Definition), api.Structure]
142145

143146
private[this] val allNonLocalClassesInSrc = new mutable.HashSet[xsbti.api.ClassLike]
144147
private[this] val _mainClasses = new mutable.HashSet[String]

0 commit comments

Comments
 (0)