Elements. Pull implementations out of ConstructorElementMixin, leave only declarations.

ConstructorMember uses baseElement to implement, as every other method.

Change-Id: I3d6e5f16e83e6c601691cfdd0c254b861ffd9a68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435960
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2025-06-20 10:10:00 -07:00
committed by Commit Queue
parent 1dc17b9a22
commit 38ac87f64d
2 changed files with 29 additions and 17 deletions
+23 -17
View File
@@ -922,28 +922,13 @@ mixin ConstructorElementMixin
/// Whether the constructor can be used as a default constructor - unnamed,
/// and has no required parameters.
bool get isDefaultConstructor {
// unnamed
if (name2 != 'new') {
return false;
}
// no required parameters
for (var parameter in parameters) {
if (parameter.isRequired) {
return false;
}
}
// OK, can be used as default constructor
return true;
}
bool get isDefaultConstructor;
/// Whether the constructor represents a factory constructor.
bool get isFactory;
/// Whether the constructor represents a generative constructor.
bool get isGenerative {
return !isFactory;
}
bool get isGenerative;
@override
LibraryElementImpl get library2;
@@ -1066,6 +1051,22 @@ class ConstructorFragmentImpl extends ExecutableFragmentImpl
setModifier(Modifier.CONST, isConst);
}
@override
bool get isDefaultConstructor {
// unnamed
if (name2 != 'new') {
return false;
}
// no required parameters
for (var parameter in parameters) {
if (parameter.isRequired) {
return false;
}
}
// OK, can be used as default constructor
return true;
}
@override
bool get isFactory {
return hasModifier(Modifier.FACTORY);
@@ -1076,6 +1077,11 @@ class ConstructorFragmentImpl extends ExecutableFragmentImpl
setModifier(Modifier.FACTORY, isFactory);
}
@override
bool get isGenerative {
return !isFactory;
}
@override
ElementKind get kind => ElementKind.CONSTRUCTOR;
@@ -67,9 +67,15 @@ class ConstructorMember extends ExecutableMember
@override
bool get isConstantEvaluated => declaration.isConstantEvaluated;
@override
bool get isDefaultConstructor => baseElement.isConst;
@override
bool get isFactory => declaration.isFactory;
@override
bool get isGenerative => baseElement.isGenerative;
@override
LibraryElementImpl get library2 {
return _declaration.library!;