Skip to content

specify that types can be omitted from augmenting declarations, and will be inferred from the original #3940

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

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions working/augmentation-libraries/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,19 @@ It is a compile-time error if:
augmentation can both declare a new declaration and augment it in the same
file.*

### Type inheritance

When a type is omitted in an augmenting declaration, if the first declaration
that introduced the member has a type specified in the ommitted types position,
then that type is inherited.

This applies to return types, parameter types, variable types, and type
parameter bounds (but not type parameter names or regular parameter names, those
need to be re-declared).

It is a compile time error for a manually written type is not the same as a type
that would be inherited if that manually writted type had been omitted.

### Augmented Expression

The exact result of an `augmented` expression depends on what is being
Expand Down Expand Up @@ -474,7 +487,7 @@ The augmenting function does not have to pass the same arguments to
`augmented()` as were passed to it. It may call it once, more than once, or not
at all.

It is a compile-time error if:
It is a compile-time error if, after type inheritance:

* The signature of the function augmentation does not exactly match the
original function. This means the return types must be the same; there must
Expand Down Expand Up @@ -706,7 +719,7 @@ original redirecting initializer if there is one.
In the augmenting constructor's body, an `augmented()` call invokes the
original constructor's body.

It is a compile-time error if:
It is a compile-time error if, after type inheritance:

* The signature of the constructor augmentation does not match the original
constructor. This means the return types must be the same; there must be the
Expand Down