TypeVarOps

scalus.compiler.sir.lowering.typegens.TypeVarOps
object TypeVarOps

Cross-cutting helper for TypeVarRepresentation source values (Phase 5, design §3.6). A value carrying TypeVarRepresentation(kind) has bytes in some concrete repr's form; which form depends on kind and the value's underlying SIR type:

  • Transparent — passthrough; bytes are in whatever form the source produced. Conversion to a concrete target relabels the value as the target repr.
  • Unwrapped — bytes are in tp.defaultRepresentation form. Conversion relabels as that underlying repr first, then delegates back to the dispatcher to convert to the target.
  • Fixed — bytes are in tp.defaultTypeVarReperesentation form (the type's natural Data-shaped form). Conversion converts to that underlying repr first, then routes to the target.

bridgeFromKind is currently called from SumUplcConstrOps.emitConvert, SumDispatch.sumCaseImpl, OneElementWrapperEmitter.emitConvert, and SumListEmitterCommon.emitConvert.

The companion bridgeToKind handles the symmetric case — concrete source, TypeVar target. Canonical contract: result.representation reflects the actual byte shape (concrete repr the bytes were converted to), NOT the requested TypeVar target — symmetric to bridgeFromKind, which also returns a concrete-repr value rather than wrapping a TypeVar label. Downstream consumers that need the TypeVar label can wrap explicitly. This convention preserves the "honest about byte shape" invariant: .representation always reflects what the bytes actually are, never an abstract claim that may not match.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
TypeVarOps.type

Members list

Value members

Concrete methods

Convert a TypeVar-labeled value to a concrete target repr. The underlying-repr lookups go through the input's typegen so the helper works for DataConstrEmitter, SumListEmitterCommon, etc.

Convert a TypeVar-labeled value to a concrete target repr. The underlying-repr lookups go through the input's typegen so the helper works for DataConstrEmitter, SumListEmitterCommon, etc.

Attributes

Convert a concrete-repr value to a TypeVar target. Symmetric mirror of bridgeFromKind: just as bridgeFromKind resolves a TypeVar source to a concrete-repr value (no pretend-it's-still-TypeVar wrapping), bridgeToKind returns a value whose bytes are in the type's default form for the target's kind, without relabeling as target.

Convert a concrete-repr value to a TypeVar target. Symmetric mirror of bridgeFromKind: just as bridgeFromKind resolves a TypeVar source to a concrete-repr value (no pretend-it's-still-TypeVar wrapping), bridgeToKind returns a value whose bytes are in the type's default form for the target's kind, without relabeling as target.

  • Transparent — bytes are whatever the source produced (caller declared "any-shape"); pass through unchanged.
  • Unwrapped — convert to the type's defaultRepresentation form.
  • Fixed — convert to the type's defaultTypeVarReperesentation (Data) form.

The "no relabel" choice (chosen 2026-05-08 after testing both variants) matches bridgeFromKind's convention: result's representation reflects the actual byte shape, not the abstract TypeVar label the caller asked for. Downstream consumers that need the TypeVar label can wrap explicitly.

Attributes