File tree Expand file tree Collapse file tree 5 files changed +46
-1
lines changed
sbt-test/sbt-dotty/tasty-inspector-cache
tasty-inspector/src/scala/tasty/inspector Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1+ lazy val dottyVersion = sys.props(" plugin.scalaVersion" )
2+
3+ lazy val lib = project
4+ .in(file(" lib" ))
5+ .settings(
6+ scalaVersion := dottyVersion
7+ )
8+
9+ val jarDest = file(" target" ) / " app.jar"
10+
11+ val runTest = Def .taskKey[Unit ](" run tests" )
12+
13+ lazy val inspector = project
14+ .in(file(" inspector" ))
15+ .settings(
16+ scalaVersion := dottyVersion,
17+ libraryDependencies += " org.scala-lang" %% " scala3-tasty-inspector" % scalaVersion.value,
18+ runTest :=
19+ Def .sequential(
20+ Def .task(IO .copyFile((lib/ Compile / packageBin).value, jarDest)),
21+ (Compile / run).toTask(" " + jarDest.getAbsolutePath)
22+ ).value
23+ )
24+ .dependsOn(lib)
Original file line number Diff line number Diff line change 1+ import scala .quoted .Quotes
2+ import scala .quoted .quotes
3+ import scala .tasty .inspector as ins
4+
5+ // Test for https://github.com/lampepfl/dotty/issues/13919
6+ class MyInspector extends ins.Inspector :
7+ def inspect (using Quotes )(tastys : List [ins.Tasty [quotes.type ]]): Unit =
8+ import quotes .reflect ._
9+ TypeRepr .of[Int ]
10+ TypeRepr .of[String ]
11+
12+
13+ @ main def main (args : String * ): Unit =
14+ ins.TastyInspector .inspectTastyFilesInJar(args.head)(new MyInspector )
Original file line number Diff line number Diff line change 1+ class Dummy // we need at least one file for the tasty inspector to run
Original file line number Diff line number Diff line change 1+ > inspector/runTest
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import dotty.tools.dotc.core.Contexts.Context
1010import dotty .tools .dotc .core .Mode
1111import dotty .tools .dotc .core .Phases .Phase
1212import dotty .tools .dotc .fromtasty ._
13+ import dotty .tools .dotc .quoted .QuotesCache
1314import dotty .tools .dotc .util .ClasspathFromClassloader
1415import dotty .tools .dotc .CompilationUnit
1516import dotty .tools .unsupported
@@ -64,7 +65,11 @@ object TastyInspector:
6465 class TastyInspectorPhase extends Phase :
6566 override def phaseName : String = " tastyInspector"
6667
67- override def runOn (units : List [CompilationUnit ])(using Context ): List [CompilationUnit ] =
68+ override def runOn (units : List [CompilationUnit ])(using ctx0 : Context ): List [CompilationUnit ] =
69+ val ctx = QuotesCache .init(ctx0.fresh)
70+ runOnImpl(units)(using ctx)
71+
72+ private def runOnImpl (units : List [CompilationUnit ])(using Context ): List [CompilationUnit ] =
6873 val quotesImpl = QuotesImpl ()
6974 class TastyImpl (val path : String , val ast : quotesImpl.reflect.Tree ) extends Tasty [quotesImpl.type ] {
7075 val quotes = quotesImpl
You can’t perform that action at this time.
0 commit comments