Contract

class Contract(val serialName: String, val kind: ContractKind, elements: List<Element> = emptyList(), enumValues: List<String> = emptyList(), val discriminator: String? = null, subtypes: List<Subtype> = emptyList(), val hasPolymorphicDefault: Boolean = false, val base: String? = null)

The wire contract of a single @Serializable type, identified by its serialName and, for a sealed/polymorphic subtype, the base it was reached through (#200). Collections are normalized to sorted order so that equality and the canonical text form are independent of declaration order.

Which payload is populated depends on kind:

Constructors

Link copied to clipboard
constructor(serialName: String, kind: ContractKind, elements: List<Element> = emptyList(), enumValues: List<String> = emptyList(), discriminator: String? = null, subtypes: List<Subtype> = emptyList(), hasPolymorphicDefault: Boolean = false, base: String? = null)

Properties

Link copied to clipboard
val base: String?

The serial name of the ContractKind.SEALED / ContractKind.POLYMORPHIC contract this contract was reached through as a subtype, or null for a contract reached any other way. A subtype's serial name is only unique within its base, so (serialName, base) is the contract's identity (#200). A subtype of two bases is recorded once per base.

Link copied to clipboard
Link copied to clipboard

Class elements, sorted by name.

Link copied to clipboard

Enum value names, sorted.

Link copied to clipboard

Whether an open ContractKind.POLYMORPHIC base registered a default deserializer in its SerializersModule. That fallback lets a reader coerce an unknown (e.g. newly-added) subtype's discriminator to a sentinel instead of throwing, which downgrades an added-subtype forward break to a WARN (#128). Always false for closed/sealed and non-polymorphic contracts.

Link copied to clipboard
Link copied to clipboard

The contract's display identity: Base/sub for a subtype, else the bare serialName. Used in findings and accepted by renames, accepted breaks, and Scope.

Link copied to clipboard
Link copied to clipboard

Sealed/polymorphic subtypes, sorted by discriminator value.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String