Skip to content

Commit 6de2883

Browse files
authored
Merge pull request #11800 from dotty-staging/fix-#9684
Widen Skolem type in reflection
2 parents 041c7b2 + 957dc56 commit 6de2883

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
366366
if self.isExpr then Some(new ExprImpl(self, SpliceScope.getCurrent))
367367
else None
368368

369-
def tpe: TypeRepr = self.tpe
369+
def tpe: TypeRepr = self.tpe.widenSkolem
370370
def underlyingArgument: Term = new tpd.TreeOps(self).underlyingArgument
371371
def underlying: Term = new tpd.TreeOps(self).underlying
372372
def etaExpand(owner: Symbol): Term = self.tpe.widen match {

tests/pos-macros/i9684/Macro_1.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted._
2+
3+
object X {
4+
5+
inline def printType[A](inline x: A): String = ${
6+
printTypeImpl[A]('x)
7+
}
8+
9+
def printTypeImpl[A:Type](x:Expr[A])(using Quotes): Expr[String] = {
10+
import quotes.reflect._
11+
val value: String = x.asTerm.tpe.show
12+
println(value)
13+
Expr( value )
14+
}
15+
16+
}

tests/pos-macros/i9684/Test_2.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.concurrent._
2+
import scala.concurrent.duration._
3+
import scala.language.postfixOps
4+
5+
@main def Test: Unit =
6+
val latch = Vector.fill(10)(Future successful 10)
7+
X.printType( { Await.ready(latch(3) , 1 second) } )

0 commit comments

Comments
 (0)