Skip to content

Commit 7f5d1cc

Browse files
srawlinscommit-bot@chromium.org
authored andcommitted
Correct some of the terminology surrounding the "default constructor."
A constructor without a name is an "unnamed" constructor. A class which has no constructors explicitly specified implicitly has one "default constructor". See from the spec: > Iff no constructor is specified for a class _C_, it implicitly has a > default constructor `C(): super() {}`, unless _C_ is the built-in > class `Object`. This is the singular reference in the spec to this "default constructor." There is text which refers to the implicit superinitializer which refers to the superclass's unnamed constructor which must have zero arguments: > If no superinitializer is provided, an implicit superinitializer of > the form `super()` is added at the end of _k_'s initializer list, > unless the enclosing class is class `Object`. Change-Id: I3202c3923d2c561d40c2251c1b13ea4fde8bda48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208865 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 6d683d5 commit 7f5d1cc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/analyzer/lib/src/error/codes.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
28712871
*/
28722872
static const CompileTimeErrorCode CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
28732873
CompileTimeErrorCode('CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
2874-
"The class '{0}' doesn't have a default constant constructor.",
2874+
"The class '{0}' doesn't have an unnamed constant constructor.",
28752875
correction: "Try calling a different constructor.");
28762876

28772877
static const CompileTimeErrorCode CONTINUE_LABEL_ON_SWITCH =
@@ -3227,7 +3227,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
32273227
static const CompileTimeErrorCode DUPLICATE_CONSTRUCTOR_DEFAULT =
32283228
CompileTimeErrorCode(
32293229
'DUPLICATE_CONSTRUCTOR',
3230-
"The default constructor is already defined.",
3230+
"The unnamed constructor is already defined.",
32313231
correction: "Try giving one of the constructors a name.",
32323232
hasPublishedDocs: true,
32333233
uniqueName: 'DUPLICATE_CONSTRUCTOR_DEFAULT',
@@ -8848,7 +8848,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
88488848
// ```
88498849
static const CompileTimeErrorCode NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
88508850
CompileTimeErrorCode('NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
8851-
"The class '{0}' doesn't have a default constructor.",
8851+
"The class '{0}' doesn't have an unnamed constructor.",
88528852
correction:
88538853
"Try using one of the named constructors defined in '{0}'.",
88548854
hasPublishedDocs: true);
@@ -9955,8 +9955,8 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
99559955
static const CompileTimeErrorCode NON_GENERATIVE_IMPLICIT_CONSTRUCTOR =
99569956
CompileTimeErrorCode(
99579957
'NON_GENERATIVE_IMPLICIT_CONSTRUCTOR',
9958-
"The default constructor of superclass '{0}' (called by the implicit "
9959-
"default constructor of '{1}') must be a generative constructor, "
9958+
"The unnamed constructor of superclass '{0}' (called by the default "
9959+
"constructor of '{1}') must be a generative constructor, "
99609960
"but factory found.",
99619961
correction: "Try adding an explicit constructor that has a different "
99629962
"superinitializer or changing the superclass constructor '{2}' "

pkg/analyzer/tool/diagnostics/diagnostics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,7 @@ class F {}
33523352

33533353
_The constructor with name '{0}' is already defined._
33543354

3355-
_The default constructor is already defined._
3355+
_The unnamed constructor is already defined._
33563356

33573357
#### Description
33583358

@@ -8738,7 +8738,7 @@ name: example
87388738

87398739
### new_with_undefined_constructor_default
87408740

8741-
_The class '{0}' doesn't have a default constructor._
8741+
_The class '{0}' doesn't have an unnamed constructor._
87428742

87438743
#### Description
87448744

0 commit comments

Comments
 (0)