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

jsii should enforce consistent return types between symbols and their overrides #100

Closed
mpiroc opened this issue Jul 24, 2018 · 1 comment · Fixed by #115
Closed

jsii should enforce consistent return types between symbols and their overrides #100

mpiroc opened this issue Jul 24, 2018 · 1 comment · Fixed by #115

Comments

@mpiroc
Copy link
Contributor

mpiroc commented Jul 24, 2018

In .NET, return types must match exactly. So this is invalid:

class A {}
class B : A {}

class Base {
    public virtual A MyProp { get; set; }
}

class Child : Base {
    public override B MyProp { get; set; }
}

When jsii detects inconsistent return types, it should report an error.

@mpiroc
Copy link
Contributor Author

mpiroc commented Jul 24, 2018

See aws/aws-cdk#392 for example.

rix0rrr added a commit that referenced this issue Aug 6, 2018
Verify that the type signature of overridden members is identical
to the type signature of the base class. While in many languages
return types may be narrowed in subclasses, this is not true
for (e.g.) C#.

We want to disallow this pattern in jsii so that people
will not be able to write classes that don't behave the same
in C# and other languages.

Fixes #100.
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 a pull request may close this issue.

1 participant