mirror of https://github.com/sbt/sbt.git
Fix lazy val support
Problem ------- By Typer phase it seems like lazy val is expanded out to `def x(): Int` and synthetic `val x$lzy1`, which results in NoSuchMethod `x$lzy1`. Solution -------- Assume the naming convention and grab the part before `$`.
This commit is contained in:
parent
ad90590bc6
commit
8c2e4f936e
|
|
@ -14,6 +14,7 @@ import dotty.tools.dotc.Run
|
||||||
import dotty.tools.dotc.util.SourceFile
|
import dotty.tools.dotc.util.SourceFile
|
||||||
import dotty.tools.io.{ PlainDirectory, Directory, VirtualDirectory, VirtualFile }
|
import dotty.tools.io.{ PlainDirectory, Directory, VirtualDirectory, VirtualFile }
|
||||||
import dotty.tools.repl.AbstractFileClassLoader
|
import dotty.tools.repl.AbstractFileClassLoader
|
||||||
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.nio.file.{ Files, Path, Paths, StandardOpenOption }
|
import java.nio.file.{ Files, Path, Paths, StandardOpenOption }
|
||||||
|
|
@ -306,9 +307,11 @@ object Eval:
|
||||||
}
|
}
|
||||||
|
|
||||||
def currentClasspath: Seq[Path] =
|
def currentClasspath: Seq[Path] =
|
||||||
val cl = ClassLoader.getSystemClassLoader()
|
val urls = sys.props
|
||||||
val urls = cl.asInstanceOf[URLClassLoader].getURLs().toList
|
.get("java.class.path")
|
||||||
urls.map(_.getFile).map(Paths.get(_))
|
.map(_.split(File.pathSeparator))
|
||||||
|
.getOrElse(Array.empty[String])
|
||||||
|
urls.toVector.map(Paths.get(_))
|
||||||
|
|
||||||
def bytes(s: String): Array[Byte] = s.getBytes("UTF-8")
|
def bytes(s: String): Array[Byte] = s.getBytes("UTF-8")
|
||||||
|
|
||||||
|
|
@ -384,7 +387,11 @@ object Eval:
|
||||||
tree match
|
tree match
|
||||||
case tpd.ValDef(name, tpt, _)
|
case tpd.ValDef(name, tpt, _)
|
||||||
if isTopLevelModule(tree.symbol.owner) && isAcceptableType(tpt.tpe) =>
|
if isTopLevelModule(tree.symbol.owner) && isAcceptableType(tpt.tpe) =>
|
||||||
vals ::= name.toString
|
val str = name.mangledString
|
||||||
|
vals ::= (
|
||||||
|
if str.contains("$lzy") then str.take(str.indexOf("$"))
|
||||||
|
else str
|
||||||
|
)
|
||||||
case t: tpd.Template => this((), t.body)
|
case t: tpd.Template => this((), t.body)
|
||||||
case t: tpd.PackageDef => this((), t.stats)
|
case t: tpd.PackageDef => this((), t.stats)
|
||||||
case t: tpd.TypeDef => this((), t.rhs)
|
case t: tpd.TypeDef => this((), t.rhs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue