Skip to content

Commit 5051484

Browse files
committed
Elements. Remove VariableElementOrMember.
Change-Id: I08a0b800eb7f61c592e49864307f0bf77da92651 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438300 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent a68b49d commit 5051484

File tree

2 files changed

+29
-65
lines changed

2 files changed

+29
-65
lines changed

pkg/analyzer/lib/src/dart/element/display_string_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class ElementDisplayStringBuilder {
430430
_write('_');
431431
}
432432

433-
void writeVariableElement(VariableElementOrMember element) {
433+
void writeVariableElement(VariableFragmentImpl element) {
434434
_writeType(element.type);
435435
_write(' ');
436436
_write(element.displayName);

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 28 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,9 +3280,6 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
32803280
/// Whether the parameter is an initializing formal parameter.
32813281
bool get isInitializingFormal => false;
32823282

3283-
@override
3284-
bool get isLate => false;
3285-
32863283
/// Whether the parameter is a named parameter.
32873284
///
32883285
/// Named parameters that are annotated with the `@required` annotation are
@@ -6991,7 +6988,7 @@ class LocalVariableElementImpl extends PromotableElementImpl
69916988
}
69926989

69936990
class LocalVariableFragmentImpl extends NonParameterVariableFragmentImpl
6994-
implements LocalVariableFragment, VariableElementOrMember {
6991+
implements LocalVariableFragment {
69956992
late LocalVariableElementImpl _element2 = switch (this) {
69966993
BindPatternVariableFragmentImpl() => BindPatternVariableElementImpl(this),
69976994
JoinPatternVariableFragmentImpl() => JoinPatternVariableElementImpl(this),
@@ -7025,11 +7022,6 @@ class LocalVariableFragmentImpl extends NonParameterVariableFragmentImpl
70257022
enclosingElement3 = value as FragmentImpl;
70267023
}
70277024

7028-
@override
7029-
bool get isLate {
7030-
return hasModifier(Modifier.LATE);
7031-
}
7032-
70337025
@override
70347026
ElementKind get kind => ElementKind.LOCAL_VARIABLE;
70357027

@@ -8725,11 +8717,6 @@ abstract class PropertyInducingFragmentImpl
87258717
return !isFinal;
87268718
}
87278719

8728-
@override
8729-
bool get isLate {
8730-
return hasModifier(Modifier.LATE);
8731-
}
8732-
87338720
@override
87348721
LibraryFragment get libraryFragment {
87358722
return enclosingFragment.libraryFragment!;
@@ -10159,52 +10146,8 @@ abstract class VariableElementImpl extends ElementImpl
1015910146
}
1016010147
}
1016110148

10162-
/// Common base class for all analyzer-internal classes that implement
10163-
/// `VariableElement`.
10164-
abstract class VariableElementOrMember
10165-
implements FragmentOrMember, Annotatable {
10166-
@override
10167-
VariableFragmentImpl get declaration;
10168-
10169-
/// Whether the variable element did not have an explicit type specified
10170-
/// for it.
10171-
bool get hasImplicitType;
10172-
10173-
/// Whether the variable was declared with the 'const' modifier.
10174-
bool get isConst;
10175-
10176-
/// Whether the variable was declared with the 'final' modifier.
10177-
///
10178-
/// Variables that are declared with the 'const' modifier will return `false`
10179-
/// even though they are implicitly final.
10180-
bool get isFinal;
10181-
10182-
/// Whether the variable uses late evaluation semantics.
10183-
///
10184-
/// This will always return `false` unless the experiment 'non-nullable' is
10185-
/// enabled.
10186-
bool get isLate;
10187-
10188-
/// Whether the element is a static variable, as per section 8 of the Dart
10189-
/// Language Specification:
10190-
///
10191-
/// > A static variable is a variable that is not associated with a particular
10192-
/// > instance, but rather with an entire library or class. Static variables
10193-
/// > include library variables and class variables. Class variables are
10194-
/// > variables whose declaration is immediately nested inside a class
10195-
/// > declaration and includes the modifier static. A library variable is
10196-
/// > implicitly static.
10197-
bool get isStatic;
10198-
10199-
/// The declared type of this variable.
10200-
TypeImpl get type;
10201-
}
10202-
1020310149
abstract class VariableFragmentImpl extends FragmentImpl
10204-
implements
10205-
VariableElementOrMember,
10206-
AnnotatableFragmentImpl,
10207-
VariableFragment {
10150+
implements AnnotatableFragmentImpl, VariableFragment {
1020810151
/// The type of this variable.
1020910152
TypeImpl? _type;
1021010153

@@ -10230,7 +10173,8 @@ abstract class VariableFragmentImpl extends FragmentImpl
1023010173
@override
1023110174
VariableElementImpl get element;
1023210175

10233-
@override
10176+
/// Whether the variable element did not have an explicit type specified
10177+
/// for it.
1023410178
bool get hasImplicitType {
1023510179
return hasModifier(Modifier.IMPLICIT_TYPE);
1023610180
}
@@ -10250,7 +10194,7 @@ abstract class VariableFragmentImpl extends FragmentImpl
1025010194
setModifier(Modifier.ABSTRACT, isAbstract);
1025110195
}
1025210196

10253-
@override
10197+
/// Whether the variable was declared with the 'const' modifier.
1025410198
bool get isConst {
1025510199
return hasModifier(Modifier.CONST);
1025610200
}
@@ -10265,7 +10209,10 @@ abstract class VariableFragmentImpl extends FragmentImpl
1026510209
setModifier(Modifier.EXTERNAL, isExternal);
1026610210
}
1026710211

10268-
@override
10212+
/// Whether the variable was declared with the 'final' modifier.
10213+
///
10214+
/// Variables that are declared with the 'const' modifier will return `false`
10215+
/// even though they are implicitly final.
1026910216
bool get isFinal {
1027010217
return hasModifier(Modifier.FINAL);
1027110218
}
@@ -10275,12 +10222,28 @@ abstract class VariableFragmentImpl extends FragmentImpl
1027510222
setModifier(Modifier.FINAL, isFinal);
1027610223
}
1027710224

10225+
/// Whether the variable uses late evaluation semantics.
10226+
///
10227+
/// This will always return `false` unless the experiment 'non-nullable' is
10228+
/// enabled.
10229+
bool get isLate {
10230+
return hasModifier(Modifier.LATE);
10231+
}
10232+
1027810233
/// Set whether this variable is late.
1027910234
set isLate(bool isLate) {
1028010235
setModifier(Modifier.LATE, isLate);
1028110236
}
1028210237

10283-
@override
10238+
/// Whether the element is a static variable, as per section 8 of the Dart
10239+
/// Language Specification:
10240+
///
10241+
/// > A static variable is a variable that is not associated with a particular
10242+
/// > instance, but rather with an entire library or class. Static variables
10243+
/// > include library variables and class variables. Class variables are
10244+
/// > variables whose declaration is immediately nested inside a class
10245+
/// > declaration and includes the modifier static. A library variable is
10246+
/// > implicitly static.
1028410247
bool get isStatic => hasModifier(Modifier.STATIC);
1028510248

1028610249
set isStatic(bool isStatic) {
@@ -10290,7 +10253,8 @@ abstract class VariableFragmentImpl extends FragmentImpl
1029010253
@override
1029110254
int get offset => nameOffset;
1029210255

10293-
@override
10256+
/// The declared type of this variable.
10257+
// TODO(scheglov): make it nullable and turn into field
1029410258
TypeImpl get type => _type!;
1029510259

1029610260
set type(TypeImpl type) {

0 commit comments

Comments
 (0)