MacroSelectors

dev.constructive.eo.generics.MacroSelectors

Quote-context selector-AST helpers shared between LensMacro and the JsonPrismMacro / AvroPrismMacro cursor macros. All parse single-field selector lambdas (_.fieldName) and validate non-duplicates; the per-macro divergence is just the error-message tag.

Attributes

Source
MacroSelectors.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def caseFieldType[A : Type](using q: Quotes)(who: String, nameE: Expr[String]): (String, Int, q.reflect.TypeRepr)

Validate a Dynamic-sugar literal field name against A's case-class schema. Returns the field name, its declaration index in A, and its widened TypeRepr; aborts with a who-tagged error when the name isn't a compile-time literal or A has no such case field. Shared backbone of the cursor macros' selectDynamic sugar — the caller owns the module-specific codec summon + emit.

Validate a Dynamic-sugar literal field name against A's case-class schema. Returns the field name, its declaration index in A, and its widened TypeRepr; aborts with a who-tagged error when the name isn't a compile-time literal or A has no such case field. Shared backbone of the cursor macros' selectDynamic sugar — the caller owns the module-specific codec summon + emit.

Attributes

Source
MacroSelectors.scala
def extractFieldName(using Quotes)(t: x$1.reflect.Term): Option[String]

Loose variant of extractSingleFieldName — strips Inlined / Typed wrappers around the lambda AND around its Select body, and does NOT require the Select receiver to be the bare lambda parameter. Used by the cursor macros' .field(_.x) sugar, whose selectors are always single-hop but may arrive wrapped. Kept distinct from extractSingleFieldName (which rejects nested chains by construction) so callers that need the strict form still have it.

Loose variant of extractSingleFieldName — strips Inlined / Typed wrappers around the lambda AND around its Select body, and does NOT require the Select receiver to be the bare lambda parameter. Used by the cursor macros' .field(_.x) sugar, whose selectors are always single-hop but may arrive wrapped. Kept distinct from extractSingleFieldName (which rejects nested chains by construction) so callers that need the strict form still have it.

Attributes

Source
MacroSelectors.scala
def extractSingleFieldName(using Quotes)(t: x$1.reflect.Term): Option[String]

Strips Inlined / Typed wrappers and peeks inside the lambda body for a single Select whose receiver is exactly the lambda parameter (an Ident). Receiver-is-Ident is load-bearing — nested paths like _.a.b parse as Select(Select(Ident(_), "a"), "b") and fall through to None so each macro can produce its own "nested paths" message.

Strips Inlined / Typed wrappers and peeks inside the lambda body for a single Select whose receiver is exactly the lambda parameter (an Ident). Receiver-is-Ident is load-bearing — nested paths like _.a.b parse as Select(Select(Ident(_), "a"), "b") and fall through to None so each macro can produce its own "nested paths" message.

Attributes

Source
MacroSelectors.scala
def fieldsSelectorNT[A : Type](using q: Quotes)(who: String, selectorsE: Expr[Seq[A => Any]]): (List[String], List[Int], q.reflect.TypeRepr)

Validate a .fields(_.a, _.b, …) varargs selector list against A's case-class schema and synthesise the SELECTOR-order NamedTuple type: arity ≥ 2, single-hop selectors only, known fields, no duplicates. Returns the selected names (selector order), their declaration indices in A (declaration order lookup — the field-schema-naming resolution of issue #35), and the NamedTuple[names, values] TypeRepr. Shared backbone of AvroPrismMacro.fieldsCommon / JsonPrismMacro.fieldsCommon — the caller owns the module-specific codec summon + emit.

Validate a .fields(_.a, _.b, …) varargs selector list against A's case-class schema and synthesise the SELECTOR-order NamedTuple type: arity ≥ 2, single-hop selectors only, known fields, no duplicates. Returns the selected names (selector order), their declaration indices in A (declaration order lookup — the field-schema-naming resolution of issue #35), and the NamedTuple[names, values] TypeRepr. Shared backbone of AvroPrismMacro.fieldsCommon / JsonPrismMacro.fieldsCommon — the caller owns the module-specific codec summon + emit.

Attributes

Source
MacroSelectors.scala
def iterableElementType[A](who: String)(using evidence$1: Type[A], q: Quotes): q.reflect.TypeRepr

The single element type of a Scala collection type A (via its Iterable base type), or abort with a who-tagged error. Shared by the cursor macros' .at / .each sugar.

The single element type of a Scala collection type A (via its Iterable base type), or abort with a who-tagged error. Shared by the cursor macros' .at / .each sugar.

Attributes

Source
MacroSelectors.scala
def reportDuplicateSelectors(using Quotes)(who: String, resolved: List[(Int, String)]): Unit

Reject duplicate field names; aborts on the first duplicate. The who tag prefixes the message.

Reject duplicate field names; aborts on the first duplicate. The who tag prefixes the message.

Attributes

Source
MacroSelectors.scala