[2.x] Fix lazy val name handling in Eval (#8818) (#8852)

Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
This commit is contained in:
eugene yokota 2026-03-01 05:28:43 -05:00 committed by GitHub
parent 22450b947c
commit 1d6ec91dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import java.nio.file.{ Files, Path, Paths, StandardOpenOption }
import java.security.MessageDigest
import scala.jdk.CollectionConverters.*
import scala.quoted.*
import scala.reflect.NameTransformer
import sbt.io.{ Hash, IO }
/**
@ -429,8 +430,9 @@ object Eval:
vals ::= name.mangledString
case tpd.ValDef(name, tpt, _) if name.is(NameKinds.LazyLocalName) =>
val str = name.mangledString
val methodName = str.take(str.indexOf("$lzy"))
val m = tree.symbol.owner.requiredMethod(methodName.replace("$minus", "-"))
val methodName = str.take(str.indexOf(NameTransformer.LAZY_LOCAL_SUFFIX_STRING))
val decodedName = NameTransformer.decode(methodName)
val m = tree.symbol.owner.requiredMethod(decodedName)
if isAcceptableType(m.info) then vals ::= methodName
case t: tpd.Template => this((), t.body)
case t: tpd.PackageDef => this((), t.stats)

View File

@ -0,0 +1,13 @@
lazy val `a + b` = "2.13.18"
// https://github.com/scala/scala3/blob/3.8.2/library/src/scala/reflect/NameTransformer.scala#L47-L64
lazy val ~=<>!#%^&|*/+-:\\?@ = "my-name"
scalaVersion := `a + b`
name := ~=<>!#%^&|*/+-:\\?@
InputKey[Unit]("check") := {
assert(scalaVersion.value == "2.13.18")
assert(name.value == "my-name")
}

View File

@ -0,0 +1,2 @@
> compile
> check