Skip to content

Conversation

mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Sep 12, 2025

Preparing PR for end-2-end tests for #4924

This uses a jsii-compiler pre-release to demonstrate functionality.

Order of publishing will be:

  1. Merge & release feat: declare support for new feature class-covariant-overrides #4924
  2. Update, merge & release feat: allow covariant overrides in classes jsii-compiler#2324
  3. Update & merge this PR

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 2 times, most recently from f9f27f7 to 8b209be Compare September 13, 2025 12:36
@mrgrain mrgrain force-pushed the mrgrain/chore/class-covariant-overrides-tests branch 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. 👍🏻

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