-
Notifications
You must be signed in to change notification settings - Fork 1.1k
given instance is declared as erased, but is in fact used #13785
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
Comments
Seems like the library generates too much code while inlining. Up to |
Is there a way to print the generated code? object PrintMacPass {
inline def apply[T](inline any: T): T = ${ printMacImpl('any) }
def printMacImpl[T: Type](any: Expr[T])(using qctx: Quotes): Expr[T] = {
import qctx.reflect._
println(Printer.TreeShortCode.show(any.asTerm))
any
}
} If I were able to see what it generates I could probably understand why it's generating too much code. |
That will unfortunately not work as once the error is emitted we stop inlining. Hence that macro will not get expanded. I instrumented a version of the compiler that will print what is being inlined. You may clone https://github.com/dotty-staging/dotty/tree/instument-inlining and then publish it locally by doing Or even better, transform your inline functions that use |
Thanks, that was super useful. I can understand what is going on. The fact that I call explicitly
|
Compiler version
3.1.0
Problem
This is a follow-up to #13044.
There are few occurrences where I observe the error
given instance is declared as erased, but is in fact used
, but increasing-Xmax-inlines
doesn't solve the problem. Instead, the compilation goes on forever while using a lot of CPU.To reproduce, clone this branch: https://github.com/ghostdogpr/caliban/tree/repro-1 (branch = repro-1)
In sbt:
++3.1.0
(the project cross-compiles and uses Scala 2 by default), thenfederation / compile
.You should get this:
If you add
-Xmax-inlines: 50
to scala options, instead of the error it compiles forever with high CPU usage.The code for the derivation is here: https://github.com/ghostdogpr/caliban/blob/repro-1/core/src/main/scala-3/caliban/schema/SchemaDerivation.scala
Uncommenting this line and commenting
import genericSchema.gen
instead removes the error.Let me know if you need more details about it. Thanks!
The text was updated successfully, but these errors were encountered: