Skip to content

Commit

Permalink
Merge pull request #7012 from dotty-staging/fix-7008
Browse files Browse the repository at this point in the history
Fix #7008: dealias temporary types in pickling types
  • Loading branch information
liufengyun committed Aug 12, 2019
2 parents b221132 + cd9b3f8 commit b534eb2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ object PickledQuotes {
def unpickleType(tasty: PickledQuote, args: PickledTypeArgs)(implicit ctx: Context): Tree = {
val tastyBytes = TastyString.unpickle(tasty)
val unpickled = unpickle(tastyBytes, args, isType = true)(ctx.addMode(Mode.ReadPositions))
unpickled match {
val tpt = unpickled match {
case Block(aliases, tpt) =>
// `@quoteTypeTag type` aliasses are not required after unpickling
tpt
case tpt => tpt
}
tpt.withType(dealiasTypeTags(tpt.tpe))
}

// TASTY picklingtests/pos/quoteTest.scala
Expand Down
4 changes: 0 additions & 4 deletions compiler/test-resources/repl-macros/i6263
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ scala> withQuoteContext { fn("foo") }
ok
scala> withQuoteContext { fn((1,2)) }
ok
scala> object O
// defined object O
scala> withQuoteContext { fn(O) }
ok
scala> withQuoteContext { fn(1) }
ok
19 changes: 19 additions & 0 deletions tests/run-macros/i7008/macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import scala.quoted._, scala.quoted.matching._
import delegate scala.quoted._
import scala.tasty._

case class Box[T](v: T)

inline def mcr(expr: => Boolean): Unit = ${mcrProxy('expr)}

def mcrProxy(expr: Expr[Boolean]) given QuoteContext: Expr[Unit] = {
val res = mcrImpl[Boolean]('{ (esx: Seq[Box[Boolean]]) => () }, expr)
// println(s"Out: ${res.show}")
res
}

def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T]) given (ctx: QuoteContext, tt: Type[T]): Expr[Unit] = {
import ctx.tasty._
val arg = Seq('{(Box($expr))}).toExprOfSeq
func(arg)
}
1 change: 1 addition & 0 deletions tests/run-macros/i7008/test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@main def Test = println(mcr(true))

0 comments on commit b534eb2

Please sign in to comment.