Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsii): compiler allows inheriting interface-violating members #3343

Merged
merged 1 commit into from Jan 18, 2022

Conversation

RomainMuller
Copy link
Contributor

The compiler failed to check inherited members from a base class against
interfaces declared on the inheriting class, so that it was possible to
inherit members that changed the signature of the interface declarations
they implemented (typically specializing them: required implementations
of optional properties, etc...).

While this is valid TypeScript (the implementation is allowed to be
strictly more specific than the interface declaration), this is not
allowed by jsii as this results in type models that cannot be
represented in C# (and other languages that do not allow specialization
by implementing or overriding members).

In addition to fixing this issue, this change adds source bindings to
diagnostics generated when property implementations are rejected, and
fixes a logical error in the message for JSII5010 (immutable and
mutable were reversed so the message read the wrong way around).

Fixes #3342


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

The compiler failed to check inherited members from a base class against
interfaces declared on the inheriting class, so that it was possible to
inherit members that changed the signature of the interface declarations
they implemented (typically specializing them: required implementations
of optional properties, etc...).

While this is valid TypeScript (the implementation is allowed to be
strictly more specific than the interface declaration), this is not
allowed by jsii as this results in type models that cannot be
represented in C# (and other languages that do not allow specialization
by implementing or overriding members).

In addition to fixing this issue, this change adds source bindings to
diagnostics generated when property implementations are rejected, and
fixes a logical error in the message for `JSII5010` (`immutable` and
`mutable` were reversed so the message read the wrong way around).
@RomainMuller RomainMuller requested a review from a team January 18, 2022 10:14
@RomainMuller RomainMuller self-assigned this Jan 18, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 18, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 18, 2022

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 Jan 18, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 18, 2022

Merging (with squash)...

@mergify mergify bot merged commit b5037b9 into main Jan 18, 2022
@mergify mergify bot deleted the rmuller/inerit-iface-impl-from-base branch January 18, 2022 11:23
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jan 18, 2022
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.

jsii: Compiler allows class-inherited member to violate interface
2 participants