Skip to content

assertion failed: unresolved symbols: parameter v when pickling #16355

Closed
@kubukoz

Description

@kubukoz

Compiler version

3.2.1

Minimized code

//> using scala "3.2.1"
import scala.quoted.Expr
import scala.quoted.Type
import scala.quoted.quotes
import scala.quoted.Quotes

object macros {

  inline transparent def mkNames[A]: List[Any] = ${ mkNamesImpl[A] }

  def mkNamesImpl[A: Type](using Quotes): Expr[List[Any]] = {
    import quotes.reflect._

    val fieldNames = TypeRepr.of[A].typeSymbol.declaredFields.map(_.name)

    val types = fieldNames
      .map { f =>
        val t1 = ConstantType(StringConstant(f))
        t1.asType match {
          case '[t1Type] => TypeRepr.of[(t1Type, "aa")]
        }
      }
      .reduceLeft[TypeRepr](OrType(_, _))

    types.asType match {
      case '[ttt] =>
        Expr.ofList[ttt](
          fieldNames.map { v =>
            Expr[(v.type, "aa")](v -> "aa").asExprOf[ttt]
          }
        )
    }
  }

}

Output (click arrow to expand)

Error compiling project (Scala 3.2.1, JVM)
Error: Unexpected error when compiling project_f0e8bc45bf: 'assertion failed: unresolved symbols: parameter v (line 27) #18316 when pickling /Users/kubukoz/projects/demos/macros.scala'
Compilation failed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions