Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when printing skolem type in singleton instance. #9684

Closed
rssh opened this issue Aug 30, 2020 · 2 comments · Fixed by #11800
Closed

Exception when printing skolem type in singleton instance. #9684

rssh opened this issue Aug 30, 2020 · 2 comments · Fixed by #11800

Comments

@rssh
Copy link
Contributor

rssh commented Aug 30, 2020

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
@rssh
Copy link
Contributor Author

rssh commented Aug 30, 2020

match-error-on-print-scolem-type.tar.gz
(ful sbt project)

@rssh rssh changed the title Exception when printing concrete type fr Exception when printing skolem type in singleton instance. Aug 31, 2020
@smarter
Copy link
Member

smarter commented Aug 31, 2020

The tasty pickler just unwraps skolems so I guess the tasty-reflect printer should do the same (that won't always give you something that passes the typechecker but that's not the only situation where you have a type that cannot be represented in source code) /cc @nicolasstucki

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 18, 2021
KacperFKorban pushed a commit to KacperFKorban/dotty that referenced this issue Mar 19, 2021
michelou pushed a commit to michelou/dotty that referenced this issue Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants