Skip to content

Allow subclassing an external class with deferred resolution#693

Closed
hadley wants to merge 1 commit into
external-classfrom
external-subclass
Closed

Allow subclassing an external class with deferred resolution#693
hadley wants to merge 1 commit into
external-classfrom
external-subclass

Conversation

@hadley

@hadley hadley commented Jun 10, 2026

Copy link
Copy Markdown
Member

Stacked on top of #660 (base branch: external-class).

`new_class()` now accepts a `new_external_class()` as its `parent`. The child
constructor takes the child's own properties plus `...`, which it forwards to
the parent, so the external parent is only resolved the first time an object is
constructed (not when the class is defined). This means a package can subclass
a class from a soft dependency and still build and load when that dependency is
absent.

On first construction the class is rebuilt with the resolved parent (and the
result cached), so inherited properties, validation, and dispatch all behave as
if the parent had been known up front.

Adds an in-process test plus a cross-package test (new fixture package t5,
which subclasses ParentClass from soft dependency t1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hadley hadley marked this pull request as draft June 10, 2026 16:45
@hadley hadley closed this Jun 18, 2026
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