@@ -149,6 +149,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
149
149
* the rhs of the key. If a symbol is present in the value set, then do not hash its signature or inline body.
150
150
*/
151
151
private val seenInlineCache = mutable.HashMap .empty[Symbol , mutable.HashSet [Symbol ]]
152
+ private val inlineBodyCache = mutable.HashMap .empty[Symbol , Int ]
152
153
153
154
private val allNonLocalClassesInSrc = new mutable.HashSet [xsbti.api.ClassLike ]
154
155
private val _mainClasses = new mutable.HashSet [String ]
@@ -652,17 +653,27 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
652
653
// an inline def in every class that extends its owner. To avoid this we
653
654
// could store the hash as an annotation when pickling an inline def
654
655
// and retrieve it here instead of computing it on the fly.
655
- val root =
656
- if inlineOrigin.exists then
657
- inlineOrigin
658
- else
659
- assert(! seenInlineCache.contains(s))
660
- seenInlineCache.put(s, mutable.HashSet .empty)
661
- s
662
- if ! seenInlineCache(root).contains(s) then
663
- seenInlineCache(root) += s
664
- val inlineBodyHash = treeHash(inlineBody, inlineOrigin = root)
656
+
657
+ def registerInlineHash (inlineBodyHash : Int ): Unit =
665
658
annots += marker(inlineBodyHash.toString)
659
+
660
+ def nestedHash (root : Symbol ): Unit =
661
+ if ! seenInlineCache(root).contains(s) then
662
+ seenInlineCache(root) += s
663
+ registerInlineHash(treeHash(inlineBody, inlineOrigin = root))
664
+
665
+ def originHash (root : Symbol ): Unit =
666
+ def computeHash (): Int =
667
+ assert(! seenInlineCache.contains(root))
668
+ seenInlineCache.put(root, mutable.HashSet (root))
669
+ val res = treeHash(inlineBody, inlineOrigin = root)
670
+ seenInlineCache.remove(root)
671
+ res
672
+ registerInlineHash(inlineBodyCache.getOrElseUpdate(root, computeHash()))
673
+
674
+ if inlineOrigin.exists then nestedHash(root = inlineOrigin)
675
+ else originHash(root = s)
676
+
666
677
end if
667
678
668
679
// In the Scala2 ExtractAPI phase we only extract annotations that extend
0 commit comments