Skip to content

Commit

Permalink
clarify comment about inlineBodyCache
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Dec 22, 2021
1 parent 33ebf01 commit 683c458
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
*/
private val seenInlineCache = mutable.HashSet.empty[Symbol]

/** This cache is optional, it avoids recomputing hashes of inline "Body" annotations. */
/** This cache is optional, it avoids recomputing hashes of inline "Body" annotations,
* e.g. when a concrete inline method is inherited by a subclass.
*/
private val inlineBodyCache = mutable.HashMap.empty[Symbol, Int]

private val allNonLocalClassesInSrc = new mutable.HashSet[xsbti.api.ClassLike]
Expand Down Expand Up @@ -654,12 +656,6 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
// this method need to be recompiled. sbt has no way of tracking method
// bodies, so we include the hash of the body of the method as part of the
// signature we send to sbt.
//
// FIXME: The API of a class we send to Zinc includes the signatures of
// inherited methods, which means that we repeatedly compute the hash of
// an inline def in every class that extends its owner. To avoid this we
// could store the hash as an annotation when pickling an inline def
// and retrieve it here instead of computing it on the fly.

def hash[U](inlineOrigin: Symbol): Int =
assert(seenInlineCache.add(s)) // will fail if already seen, guarded by treeHash
Expand Down

0 comments on commit 683c458

Please sign in to comment.