Scala 3 macros, extension methods, and slick

Here’s a program I’m trying to write using Macros to fetch the schemas from an object containing slick table defintions. The table definitions look like

object TableDefinitions {

class LocationPictureURLsTable(tag: Tag) extends Table[(Long, java.lang.String)](tag, "LocationPictureURLs") {
  def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def value = column[java.lang.String]("value")
  def * = (id, value)
  val query = TableQuery[LocationPictureURLsTable]
}

...
}
import slick.jdbc.PostgresProfile.api._
import scala.quoted._

object DDLGenerator {
  inline def generateDDL[T]: Unit = ${ generateDDLImpl[T] }

  private def generateDDLImpl[T: Type](using Quotes): Expr[Unit] = {
    import quotes.reflect._

    val tableDefs = TypeRepr.of[T].typeSymbol.declaredTypes
      .filter(_.isClassDef)
      .filter(_.typeRef.baseClasses.exists(_.fullName == "slick.lifted.Table"))

    val ddlStatementsExprs = tableDefs.map { tableSymbol =>
      val tableName = tableSymbol.name

      val companionModule = tableSymbol.companionModule
      val querySymbol = companionModule.declaredMethods.find(_.name == "query").get
      val queryExpr = Ref(querySymbol).asExprOf[TableQuery[?]]

      '{
        val createIfNotExistsAction = $queryExpr.schema.createIfNotExists
        val ddlStatements = createIfNotExistsAction.statements
        val fileName = s"./src/main/scala/org/example/sql/$tableName.sql"
        println(s"Writing DDL statements for $tableName to $$fileName")
        val output = new java.io.PrintWriter(fileName)
        ddlStatements.foreach(output.println)
        output.close()
      }
    }

    Expr.block(ddlStatementsExprs.toList, '{ () })
  }

  def main(args: Array[String]): Unit = {
    println("Start generating table definitions")
    generateDDL[TableDefinitions.type]
    println("End generating table definitions")
  }
}

But I get the following error:

value schema is not a member of slick.lifted.TableQuery[?]
        val createIfNotExistsAction = $queryExpr.schema.createIfNotExists

Does anyone know how I might go about resoving this ?? I think using Scala 2 runtime reflection and it might have been easier to attempt this.

It looks like schema should be an extension method possibly resolved through importing Slick 3.5.0 - slick.jdbc.PostgresProfile . However we have the value schema is not a member of slick.lifted.TableQuery[?] issue.

Is there an issue with Scala 3 methods and loading the extension method? Or am I missing something in the application?

This has been asked without resolution in Discord

Can you please check if you can call .schema on TableQuery outside of the macro? This would give a clue about what direction to check to resolve this.