File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
library/src/scala/tasty/reflect
tests/run-custom-args/tasty-inspector Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -1443,7 +1443,9 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14431443
14441444 object Sequence {
14451445 def unapply (tpe : Type )(using ctx : Context ): Option [Type ] = tpe match {
1446- case AppliedType (seq, (tp : Type ) :: Nil ) if seq.typeSymbol == ctx.requiredClass(" scala.collection.Seq" ) => Some (tp)
1446+ case AppliedType (seq, (tp : Type ) :: Nil )
1447+ if seq.typeSymbol == ctx.requiredClass(" scala.collection.Seq" ) || seq.typeSymbol == ctx.requiredClass(" scala.collection.immutable.Seq" ) =>
1448+ Some (tp)
14471449 case _ => None
14481450 }
14491451 }
Original file line number Diff line number Diff line change 1+ import scala .tasty ._
2+ import scala .tasty .inspector ._
3+
4+ @ main def Test = {
5+ val inspector = new TastyInspector {
6+ def processCompilationUnit (reflect : Reflection )(tree : reflect.Tree ): Unit = {
7+ import reflect .{_ , given _ }
8+ println(tree.show)
9+ }
10+ }
11+ inspector.inspect(" " , List (" scala.tasty.Reflection" ))
12+ }
Original file line number Diff line number Diff line change 1+ import scala .tasty ._
2+ import scala .tasty .inspector ._
3+
4+ @ main def Test = {
5+ // in dotty-example-project
6+ val inspector = new TastyInspector {
7+ def processCompilationUnit (reflect : Reflection )(tree : reflect.Tree ): Unit = {
8+ import reflect .{_ , given _ }
9+ println(tree.show)
10+ }
11+ }
12+ inspector.inspect(" " , List (" TraitParams" ))
13+ }
14+
15+ object TraitParams {
16+
17+ trait Base (val msg : String )
18+ class A extends Base (" Hello" )
19+ class B extends Base (" Dotty!" )
20+
21+ // Union types only exist in Dotty, so there's no chance that this will accidentally be compiled with Scala 2
22+ private def printMessages (msgs : (A | B )* ) = println(msgs.map(_.msg).mkString(" " ))
23+
24+ def test : Unit = {
25+
26+ printMessages(new A , new B )
27+
28+ // Sanity check the classpath: this won't run if the dotty jar is not present.
29+ val x : Int => Int = z => z
30+ x(1 )
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments