From c3495d8817b6fdec9dda8d362e6303fb2911e3d1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 30 Jun 2026 22:01:20 +0600 Subject: [PATCH] Add HELPERS rule preferring members over when-dispatch extensions Document that a property/method which can live on an interface/class must be declared there and overridden per implementation, instead of a common extension that dispatches with a when over every subtype; shared logic goes into a companion-object function or an internal top-level helper. Co-Authored-By: Claude Opus 4.8 --- agents/HELPERS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agents/HELPERS.md b/agents/HELPERS.md index c75169f992..d9e2d00662 100644 --- a/agents/HELPERS.md +++ b/agents/HELPERS.md @@ -48,3 +48,7 @@ Each section can be ommited if there are no any changes in the section. In case * `Core`: * (`Guest mode`) // change data ``` + +--- + +When a property (or method) can be declared on an interface/class and implemented by each inheritor - it MUST be declared there and overridden per implementation. DO NOT implement such behaviour as a common extension property/function that dispatches with a `when (this)` over every subtype: those branches silently drift out of sync when new subtypes are added and are not part of the type contract. If a part of the implementation is reused across several inheritors, keep that part in a shared helper (a companion-object function of the owner, or an `internal` top-level function for logic shared between different types) and let the overrides reuse it.