Skip to content

Commit 3937029

Browse files
authored
Merge pull request #8450 from dotty-staging/fix-#8389
Fix #8389: Hande immutable.Seq
2 parents 695b8d1 + ad50bf9 commit 3937029

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

library/src/scala/tasty/reflect/SourceCodePrinter.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)