Closed szymon-rd closed 1 year ago
Quasi minimized:
Wow, thank you so much @andrzejressel, this is very impressive. I've been struggling with this minimization for some time now (got only partway there). This should help out a lot (I'll try to minimize it further, which should be much easier now)
Further minimized:
// Macros.scala
import Main._
import scala.quoted.*
object Macros {
inline def apply(): ProviderProcessor =
${ Macros.processorExpr }
def processorExpr[I: Type](using q: Quotes): Expr[ProviderProcessor] = '{
new ProviderProcessor {
override def apply(simple: Simple): MyF[Int] =
${ Macros.methodProcessorImpl('simple) }
}
}
def methodProcessorImpl[I: Type](using q: Quotes)(service: Expr[Simple]): Expr[MyF[Int]] = {
import q.reflect._
val returnType = TypeRepr.of[Int]
returnType.asType match {
case '[rt] =>
'{
${
import quotes.reflect._
TypeApply(
Select.unique('{ ???.asInstanceOf[Codec] }.asTerm, "apply"),
List(TypeTree.of[rt]) // generates the error, directly using Int instead of rt makes it disappear
).asExpr
}
???
}
}
}
}
// Main.scala
object Main {
type MyF[A]
trait ProviderProcessor {
def apply(simple: Simple): MyF[Int]
}
trait Codec {
def apply[A]: MyF[A]
}
trait Simple {
def a0: Int
}
def test(): Unit = {
val p= Macros()
}
}
Compiler version
Failing with 3.3.1-RC1-bin-20230524-5262680-NIGHTLY Successful build with 3.3.1-RC1-bin-20230518-4ffe5af-NIGHTLY
The error
The build of poppet is failing in the new CB run: https://github.com/VirtusLab/community-build3/actions/runs/5094537615/jobs/9160777992#step:3:370
Output
See the link above
Expectation
Successful compilation