Skip to content

Commit

Permalink
Merge pull request #11800 from dotty-staging/fix-#9684
Browse files Browse the repository at this point in the history
Widen Skolem type in reflection
  • Loading branch information
smarter authored Mar 18, 2021
2 parents 041c7b2 + 957dc56 commit 6de2883
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
if self.isExpr then Some(new ExprImpl(self, SpliceScope.getCurrent))
else None

def tpe: TypeRepr = self.tpe
def tpe: TypeRepr = self.tpe.widenSkolem
def underlyingArgument: Term = new tpd.TreeOps(self).underlyingArgument
def underlying: Term = new tpd.TreeOps(self).underlying
def etaExpand(owner: Symbol): Term = self.tpe.widen match {
Expand Down
16 changes: 16 additions & 0 deletions tests/pos-macros/i9684/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import scala.quoted._

object X {

inline def printType[A](inline x: A): String = ${
printTypeImpl[A]('x)
}

def printTypeImpl[A:Type](x:Expr[A])(using Quotes): Expr[String] = {
import quotes.reflect._
val value: String = x.asTerm.tpe.show
println(value)
Expr( value )
}

}
7 changes: 7 additions & 0 deletions tests/pos-macros/i9684/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.concurrent._
import scala.concurrent.duration._
import scala.language.postfixOps

@main def Test: Unit =
val latch = Vector.fill(10)(Future successful 10)
X.printType( { Await.ready(latch(3) , 1 second) } )

0 comments on commit 6de2883

Please sign in to comment.