Closed
Description
Minimized code
file X.scala:
package x
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 )
}
}
file Main.scala:
package x
import scala.concurrent._
import scala.concurrent.duration._
import scala.language.postfixOps
object Main:
def main(args:Array[String]):Unit =
val latch = Vector.fill(10)(Future successful 10)
X.printType( { Await.ready(latch(3) , 1 second) } )
Output (click arrow to expand)
[info] Compiling 1 Scala source to /Users/rssh/tests/dotty/assert-in-print/target/scala-0.28/classes ...
[error] -- Error: /Users/rssh/tests/dotty/assert-in-print/src/main/scala/x/Main.scala:11:14
[error] 11 | X.printType( { Await.ready(latch(3) , 1 second) } )
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |Exception occurred while executing macro expansion.
[error] |scala.MatchError: Skolem(249706902) (of class dotty.tools.dotc.core.Types$SkolemType)
[error] | at scala.tasty.reflect.ExtractorsPrinter$Buffer.visitType(ExtractorsPrinter.scala:227)
[error] | at scala.tasty.reflect.ExtractorsPrinter.showTypeOrBounds(ExtractorsPrinter.scala:11)
[error] | at scala.tasty.Reflection$TypeOrBoundsOps$.extension_showExtractors(Reflection.scala:1348)
[error] | at scala.tasty.reflect.SourceCodePrinter$Buffer.printType(SourceCodePrinter.scala:1225)
[error] | at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypeOrBound(SourceCodePrinter.scala:1068)
[error] | at scala.tasty.reflect.SourceCodePrinter.showTypeOrBounds(SourceCodePrinter.scala:16)
[error] | at scala.tasty.Reflection$TypeOrBoundsOps$.extension_showWith(Reflection.scala:1356)
[error] | at scala.tasty.Reflection$TypeOrBoundsOps$.extension_show(Reflection.scala:1352)
[error] | at x.X$.printTypeImpl(X.scala:13)
[error] |
[error] | This location contains code that was inlined from Main.scala:11
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 2 s, completed 30 Aug 2020, 21:36:08