OfThisClassField
Resolves — or synthesizes — a per-class member holding an instance of typeSymbol obtained via a companion of(KClass<*>) factory (e.g. Logger.of(this::class) / Meter.of(this::class)).
access resolves the member in three steps:
a member named memberName (e.g.
log) is reused when its type is the target type;otherwise the class's single property of the target type — whatever its name (e.g.
private val logger = Logger.of(this::class)) — is reused; two or more such properties are ambiguous, so none is picked;otherwise
private val [syntheticName] = <Type>.of(this::class)is synthesized (created once per class). A memberName member of a foreign type (e.g.org.slf4j.Loggerwhen we want a log4kLogger) is never reused — the synthetic name is distinct, so it never clashes.
Synthesized fields are collected during the module traversal and only attached to their classes by commit afterwards, so a class's declaration list is never mutated while it is being iterated.
Functions
Returns an expression that yields the typeSymbol instance for function (reused member or synthesized field), or null (after reporting an error) when function has no enclosing class or dispatch receiver.