Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Sep 12, 2025

Updates docs and additional tools with support for class covariant overrides.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mrgrain mrgrain marked this pull request as draft September 12, 2025 12:05
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 12, 2025
@mrgrain mrgrain force-pushed the mrgrain/chore/class-covariant-overrides-tests branch from 341e875 to fc8c4ed Compare September 12, 2025 12:06
@mrgrain mrgrain force-pushed the mrgrain/chore/class-covariant-overrides-tests branch 3 times, most recently from d9f8334 to e9d2913 Compare September 14, 2025 15:01
mergify bot pushed a commit that referenced this pull request Sep 15, 2025
)

This adds support for the new `class-covariant-overrides` feature into `@jsii/spec`.

`class-covariant-overrides` relaxes the existing restriction on covariant overrides [^1]. With the feature it is now allowed to override the `type of readonly class properties` and the `return type of class methods` when extending other classes, as long as the changes are covariant [^2] [^3] to the superclass. Importantly, covariant overrides are still not allowed when implementing interfaces.

Compilers that are producing assemblies with covariant class overrides MUST include `class-covariant-overrides` in the `usedFeatures` set.

This feature does not require any changes to the kernels, runtimes or packmak. All generated code already is already correct when given an appropriate assembly. We can now add support for this feature due to the upgrade to `net6.0` [^4] which was the only thing blocking it.

Proof all of this is working together: #4925

[^1]: https://aws.github.io/jsii/user-guides/lib-author/typescript-restrictions/#covariant-overrides-parameter-list-changes
[^2]: https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)
[^3]: As of today this feature strictly applies to class and interface types, event though some built-in types like lists might also be technically covariant.
[^4]: #4916

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will need features passed into loadAssembly calls in various places, won't it?

See my PRs I guess

@rix0rrr
Copy link
Contributor

rix0rrr commented Sep 15, 2025

Here is what I was referring to: #4929

@mrgrain
Copy link
Contributor Author

mrgrain commented Sep 15, 2025

Here is what I was referring to: #4929

I'll wait for you PRs to be merged to avoid duplication. 👍🏻

@mrgrain mrgrain force-pushed the mrgrain/chore/class-covariant-overrides-tests branch 5 times, most recently from 0cdf0c5 to 37cb171 Compare October 17, 2025 21:40
@mrgrain mrgrain changed the title chore: end-2-end test for covariant overrides in classes feat: support class covariant overrides in tools and docs Oct 20, 2025
@mrgrain mrgrain changed the title feat: support class covariant overrides in tools and docs feat: support class covariant overrides in kernel, tools and docs Oct 20, 2025
@mrgrain mrgrain marked this pull request as ready for review October 20, 2025 11:41
@mrgrain mrgrain force-pushed the mrgrain/chore/class-covariant-overrides-tests branch from 37cb171 to 9f36773 Compare October 20, 2025 11:44
@mrgrain
Copy link
Contributor Author

mrgrain commented Oct 20, 2025

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

queue

🛑 Configuration not compatible with a branch protection setting

The branch protection setting Require branches to be up to date before merging is not compatible with draft PR checks. To keep this branch protection enabled, update your Mergify configuration to enable in-place checks: set merge_queue.max_parallel_checks: 1, set every queue rule batch_size: 1, and avoid two-step CI (make merge_conditions identical to queue_conditions). Otherwise, disable this branch protection.

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Oct 20, 2025
@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

Merging (with squash)...

@mrgrain
Copy link
Contributor Author

mrgrain commented Oct 20, 2025

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

refresh

✅ Pull request refreshed

@mrgrain
Copy link
Contributor Author

mrgrain commented Oct 20, 2025

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

queue

🛑 Configuration not compatible with a branch protection setting

The branch protection setting Require branches to be up to date before merging is not compatible with draft PR checks. To keep this branch protection enabled, update your Mergify configuration to enable in-place checks: set merge_queue.max_parallel_checks: 1, set every queue rule batch_size: 1, and avoid two-step CI (make merge_conditions identical to queue_conditions). Otherwise, disable this branch protection.

@mrgrain mrgrain merged commit cf4a0b6 into main Oct 20, 2025
36 of 37 checks passed
@mrgrain mrgrain deleted the mrgrain/chore/class-covariant-overrides-tests branch October 20, 2025 12:32
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants