Skip to content

Commit b534eb2

Browse files
authored
Merge pull request #7012 from dotty-staging/fix-7008
Fix #7008: dealias temporary types in pickling types
2 parents b221132 + cd9b3f8 commit b534eb2

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ object PickledQuotes {
7272
def unpickleType(tasty: PickledQuote, args: PickledTypeArgs)(implicit ctx: Context): Tree = {
7373
val tastyBytes = TastyString.unpickle(tasty)
7474
val unpickled = unpickle(tastyBytes, args, isType = true)(ctx.addMode(Mode.ReadPositions))
75-
unpickled match {
75+
val tpt = unpickled match {
7676
case Block(aliases, tpt) =>
7777
// `@quoteTypeTag type` aliasses are not required after unpickling
7878
tpt
7979
case tpt => tpt
8080
}
81+
tpt.withType(dealiasTypeTags(tpt.tpe))
8182
}
8283

8384
// TASTY picklingtests/pos/quoteTest.scala

compiler/test-resources/repl-macros/i6263

-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ scala> withQuoteContext { fn("foo") }
77
ok
88
scala> withQuoteContext { fn((1,2)) }
99
ok
10-
scala> object O
11-
// defined object O
12-
scala> withQuoteContext { fn(O) }
13-
ok
1410
scala> withQuoteContext { fn(1) }
1511
ok

tests/run-macros/i7008/macro_1.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import scala.quoted._, scala.quoted.matching._
2+
import delegate scala.quoted._
3+
import scala.tasty._
4+
5+
case class Box[T](v: T)
6+
7+
inline def mcr(expr: => Boolean): Unit = ${mcrProxy('expr)}
8+
9+
def mcrProxy(expr: Expr[Boolean]) given QuoteContext: Expr[Unit] = {
10+
val res = mcrImpl[Boolean]('{ (esx: Seq[Box[Boolean]]) => () }, expr)
11+
// println(s"Out: ${res.show}")
12+
res
13+
}
14+
15+
def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T]) given (ctx: QuoteContext, tt: Type[T]): Expr[Unit] = {
16+
import ctx.tasty._
17+
val arg = Seq('{(Box($expr))}).toExprOfSeq
18+
func(arg)
19+
}

tests/run-macros/i7008/test_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@main def Test = println(mcr(true))

0 commit comments

Comments
 (0)