Skip to content

Commit

Permalink
specify that types can be omitted from augmenting declarations, and w…
Browse files Browse the repository at this point in the history
…ill be inferred from the original (#3940)

Closes #3879
  • Loading branch information
jakemac53 authored Jun 28, 2024
1 parent d8a7ca7 commit 73fab25
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions working/augmentation-libraries/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@ problems. We want it as a lint instead of a language restriction so that it
doesn’t interfere with macro-generated code, and so that users can `// ignore:`
it if they know what they’re doing.

### 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 @@ -445,7 +458,7 @@ The augmenting function does not have to pass the same arguments to
`augmented(…)` as were passed to it. It may invoke `augmented` 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 function signature of the augmenting function does not exactly match the
function signature of the augmented function. This means the return types
Expand Down Expand Up @@ -719,7 +732,7 @@ to modify local variables, but the former introduces different variables than
the ones that existed when evaluating the initializer list. If the initializer
list captures variables in closures, that body may not work.)**

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

* The function signature of the augmenting constructor does not match the
signature of the augmented constructor. This means that the parameters must
Expand Down

0 comments on commit 73fab25

Please sign in to comment.