File tree 5 files changed +46
-1
lines changed
sbt-test/sbt-dotty/tasty-inspector-cache
tasty-inspector/src/scala/tasty/inspector
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
10
10
import dotty .tools .dotc .core .Mode
11
11
import dotty .tools .dotc .core .Phases .Phase
12
12
import dotty .tools .dotc .fromtasty ._
13
+ import dotty .tools .dotc .quoted .QuotesCache
13
14
import dotty .tools .dotc .util .ClasspathFromClassloader
14
15
import dotty .tools .dotc .CompilationUnit
15
16
import dotty .tools .unsupported
@@ -64,7 +65,11 @@ object TastyInspector:
64
65
class TastyInspectorPhase extends Phase :
65
66
override def phaseName : String = " tastyInspector"
66
67
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 ] =
68
73
val quotesImpl = QuotesImpl ()
69
74
class TastyImpl (val path : String , val ast : quotesImpl.reflect.Tree ) extends Tasty [quotesImpl.type ] {
70
75
val quotes = quotesImpl
You can’t perform that action at this time.
0 commit comments