Skip to content

refactor: remove speculative abstraction from kuri-bind#51

Merged
OmarAlJarrah merged 2 commits into
mainfrom
refactor/simplify-kuri-bind
Jul 8, 2026
Merged

refactor: remove speculative abstraction from kuri-bind#51
OmarAlJarrah merged 2 commits into
mainfrom
refactor/simplify-kuri-bind

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

What

Three simplifications in the kuri-bind reflection binder, all internal.

  • UrlBinder/UriBinder interfaces had one implementer each and were never referenced as a declared type — introduced only for a "codegen later" that isn't here. Their two Reflective*Binder wrappers were near-identical glue, each spinning up its own BindingExecutor.
  • applyQuery / applyQueryMapEntry duplicated the same iterable-fan-out logic.
  • PlanCache was a ~35-line wrapper over PlanCompiler (one caller each), duplicating PlanCompiler's own type != Any::class guard, while the member scanner already caches inline.

Change

  • Delete the two interfaces and two wrapper classes; KuriBind drives a single shared BindingExecutor directly. Drops two redundant executor instances and two dead check(bound === base) postconditions.
  • Extract one addQueryValues helper; the map-entry path keeps its name/empty-guard, the plain path collapses to a call.
  • Fold the ConcurrentHashMap into PlanCompiler (matching the scanner's inline-cache idiom), delete PlanCache, and dedupe the precondition to one site. compile() stays public (the compiler test suites call it).

Two files are renamed to match their sole remaining declaration: Binder.ktProfile.kt, ReflectiveBinder.ktBindingExecutor.kt.

Safety

Pure refactor — binding behavior unchanged. The one end-to-end test (ReflectiveBinderTest) is retargeted from the removed ReflectiveUrlBinder to BindingExecutor, preserving all six assertions (6 tests, 0 failures). Public API unchanged (apiCheck passes with no apiDump — every removed symbol was internal). Net −65 lines.

Left as-is (verified genuine, not over-abstraction)

BuilderSink (real 2-impl seam — Url vs Uri userinfo differ), ComponentSink, Converters' typed when branches, the MemberScanner/PlanCompiler split, the distinct scan-cache vs plan-cache purposes, and KuriBind's parallel toUrl*/toUri* methods (intentional Java-ergonomic symmetry).


Final PR in the series; stacked on #50.

@OmarAlJarrah OmarAlJarrah force-pushed the refactor/parser-idna-housekeeping branch from 77c554a to 29fb632 Compare July 8, 2026 11:30
@OmarAlJarrah OmarAlJarrah changed the base branch from refactor/parser-idna-housekeeping to main July 8, 2026 11:38
Three simplifications in the reflection binder, all internal:

  - Collapse the UrlBinder/UriBinder interfaces (one implementer each, never
    referenced as a type — introduced only for a hypothetical future codegen
    backend) and their two near-identical ReflectiveBinder wrappers. KuriBind
    now drives a single shared BindingExecutor directly, dropping two redundant
    executor instances and two dead `check(bound === base)` postconditions.
  - Fold the duplicated iterable-fan-out query logic (applyQuery /
    applyQueryMapEntry) into one addQueryValues helper.
  - Merge the thin PlanCache wrapper into PlanCompiler, matching the inline
    ConcurrentHashMap-cache idiom the member scanner already uses, and dedupe
    the `type != Any::class` precondition to a single site.

Two files are renamed to match their sole remaining declaration (Binder.kt ->
Profile.kt, ReflectiveBinder.kt -> BindingExecutor.kt). One end-to-end test is
retargeted from the removed ReflectiveUrlBinder class to BindingExecutor,
preserving all its assertions.

Pure refactor: binding behavior unchanged, public API unchanged.
@OmarAlJarrah OmarAlJarrah force-pushed the refactor/simplify-kuri-bind branch from b60c01f to 1ac2a99 Compare July 8, 2026 11:43
The reflective binder wrappers were removed along with the ReflectiveBinder.kt
file, but the end-to-end test kept the old name for a type that no longer
exists. Rename the file and class to BindingExecutorTest, matching the class it
actually exercises, and reword the addQueryValues comment to explain why value
is nullable rather than restating the null-safe call mechanics.
@OmarAlJarrah OmarAlJarrah merged commit 035fb29 into main Jul 8, 2026
9 checks passed
@OmarAlJarrah OmarAlJarrah deleted the refactor/simplify-kuri-bind branch July 8, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant