Skip to content

Commit

Permalink
Improve the opt-out
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Nov 16, 2023
1 parent 2b15927 commit 552bbba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ trait ContextUtil[C <: Quotes & scala.Singleton](val qctx: C, val valStart: Int)
override def toString: String =
s"Input($tpe, $qual, $term, $name)"

def isCacheInput: Boolean =
Option(qual.tpe.termSymbol) match
case Some(x) => !x.hasAnnotation(cacheOptOutSym)
case None => !qual.symbol.hasAnnotation(cacheOptOutSym)
def isCacheInput: Boolean = isCacheInput(qual)
private def isCacheInput(tree: Term): Boolean =
tree match
case Inlined(_, _, tree) => isCacheInput(tree)
case Apply(_, List(arg)) => isCacheInput(arg)
case _ =>
Option(tree.tpe.termSymbol) match
case Some(x) => !x.hasAnnotation(cacheOptOutSym)
case None => !tree.symbol.hasAnnotation(cacheOptOutSym)

/**
* Represents an output expression via Def.declareOutput
Expand Down
5 changes: 3 additions & 2 deletions util-cache-resolver/src/main/scala/sbt/util/ActionCache.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sbt.util

import scala.reflect.ClassTag
import scala.annotation.StaticAnnotation
import scala.annotation.{ meta, StaticAnnotation }
import sjsonnew.{ HashWriter, JsonFormat }
import sjsonnew.support.murmurhash.Hasher
import xsbti.VirtualFile
Expand Down Expand Up @@ -33,4 +33,5 @@ class CacheConfiguration(
val outputDirectory: Path,
)

class cacheOptOut() extends StaticAnnotation
@meta.getter
class cacheOptOut(reason: String = "") extends StaticAnnotation

0 comments on commit 552bbba

Please sign in to comment.