Skip to content

Commit 31f3d2b

Browse files
authored
Only allow super parameters in class declarations. (#2148)
* Only allow super parameters in `class` declarations. Makes it explicit that you cannot use super-parameters in an `enum` declaration constructor..
1 parent d90210c commit 31f3d2b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

working/1855 - super parameters/proposal.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dart Super-Initializer Parameters
22

3-
Author: [email protected]<br>Version: 1.2
3+
Author: [email protected]<br>Version: 1.3
44

55
## Background and Motivation
66

@@ -46,9 +46,9 @@ _That is, exactly the same grammar as initializing formals, but with `super` ins
4646

4747
## Semantics
4848

49-
It’s a **compile-time error** if a super-parameter in any declaration other than a non-redirecting generative constructor.
49+
It’s a **compile-time error** if a super-parameter declaration occurs in any declaration other than a non-redirecting generative constructor of a class declaration.
5050

51-
_All non-redirecting generative constructors have a super-constructor invocation at the end of their initializer list. If none is written (or there is even no initializer list), the default is an invocation of `super()`, targeting the unnamed superclass constructor. It’s a compiler-time error if the superclass does not have the specified constructor, or it’s not a generative constructor._
51+
_All non-redirecting generative constructors of a class declaration have a super-constructor invocation at the end of their initializer list. If none is written (or there is even no initializer list), the default is an invocation of `super()`, targeting the unnamed superclass constructor. It’s a compiler-time error if the superclass does not have the specified constructor, or it’s not a generative constructor. The new enhanced `enum` declarations, on the other hand, do have non-redirecting generative constructors, but those cannot not have any super-invocations, and they also have no known superclass constructor to forward parameters to._
5252

5353
It’s a **compile-time error** if `var` occurs as the first token of a `<superFormalParameter>` production. (It’s generally a compile-time error if `const` or `late` occurs in a parameter declaration, this also applies to super-parameters).
5454

@@ -176,3 +176,5 @@ class C extends B {
176176
1.1: Don’t allow both positional super parameters and explicit positional arguments. Inherit default value.
177177

178178
1.2: Don’t do inference (and implicit coercion) on the implicit arguments.
179+
180+
1.3: Make it explicit that you can't use super parameters in the new enum declarations.

0 commit comments

Comments
 (0)