sbt/sbt
Vedi su GitHub[2.x] `@cacheLevel` and `@transient` annotation does not work if local val
Open
#9162 aperta il 30 apr 2026
Bughelp wanted
Metriche repository
- Star
- (4928 star)
- Metriche merge PR
- (Merge medio 1g 15h) (66 PR mergiate in 30 g)
Descrizione
steps
project/A.scala
import sbt._
import sbt.util.cacheLevel
class A
object A {
val f1 = {
@cacheLevel(Array.empty)
val b = taskKey[A]("")
b := new A
}
val f2 = {
@transient
val b = taskKey[A]("")
b := new A
}
}
project/build.properties
sbt.version=2.0.0-RC12
problem
[error] -- Error: /Users/kenji/sbt-2-task-local-val-annotation/project/A.scala:11:4 ----
[error] 11 | b := new A
[error] | ^^^^^^^^^^
[error] |given evidence sjsonnew.JsonFormat[A] is not found; opt out of caching by annotating the key with @transient, or as foo := Def.uncached(...), or provide a given value
[error] |---------------------------------------------------------------------------
[error] |Inline stack trace
[error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error] |This location contains code that was inlined from A.scala:11
[error] ---------------------------------------------------------------------------
[error] -- Error: /Users/kenji/sbt-2-task-local-val-annotation/project/A.scala:18:4 ----
[error] 18 | b := new A
[error] | ^^^^^^^^^^
[error] |given evidence sjsonnew.JsonFormat[A] is not found; opt out of caching by annotating the key with @transient, or as foo := Def.uncached(...), or provide a given value
[error] |---------------------------------------------------------------------------
[error] |Inline stack trace
[error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error] |This location contains code that was inlined from A.scala:18
[error] ---------------------------------------------------------------------------
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed