Skip to content

Commit 73fab25

Browse files
authored
specify that types can be omitted from augmenting declarations, and will be inferred from the original (#3940)
Closes #3879
1 parent d8a7ca7 commit 73fab25

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

working/augmentation-libraries/feature-specification.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ problems. We want it as a lint instead of a language restriction so that it
267267
doesn’t interfere with macro-generated code, and so that users can `// ignore:`
268268
it if they know what they’re doing.
269269

270+
### Type inheritance
271+
272+
When a type is omitted in an augmenting declaration, if the first declaration
273+
that introduced the member has a type specified in the ommitted types position,
274+
then that type is inherited.
275+
276+
This applies to return types, parameter types, variable types, and type
277+
parameter bounds (but not type parameter names or regular parameter names, those
278+
need to be re-declared).
279+
280+
It is a compile time error for a manually written type is not the same as a type
281+
that would be inherited if that manually writted type had been omitted.
282+
270283
### Augmented Expression
271284

272285
The exact result of an `augmented` expression depends on what is being
@@ -445,7 +458,7 @@ The augmenting function does not have to pass the same arguments to
445458
`augmented(…)` as were passed to it. It may invoke `augmented` once, more than
446459
once, or not at all.
447460

448-
It is a compile-time error if:
461+
It is a compile-time error if, after type inheritance:
449462

450463
* The function signature of the augmenting function does not exactly match the
451464
function signature of the augmented function. This means the return types
@@ -719,7 +732,7 @@ to modify local variables, but the former introduces different variables than
719732
the ones that existed when evaluating the initializer list. If the initializer
720733
list captures variables in closures, that body may not work.)**
721734

722-
It is a compile-time error if:
735+
It is a compile-time error if, after type inheritance:
723736

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

0 commit comments

Comments
 (0)