Skip to content

Commit 779e7bc

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Move hasEnclosingTypeParameterReference to elements.
Change-Id: I0e3b45170c6c716b61020367d45f0abb2de65285 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450367 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 1f59259 commit 779e7bc

File tree

4 files changed

+20
-50
lines changed

4 files changed

+20
-50
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ testFineAfterLibraryAnalyzerHook;
106106
// TODO(scheglov): Clean up the list of implicitly analyzed files.
107107
class AnalysisDriver {
108108
/// The version of data format, should be incremented on every format change.
109-
static const int DATA_VERSION = 557;
109+
static const int DATA_VERSION = 558;
110110

111111
/// The number of exception contexts allowed to write. Once this field is
112112
/// zero, we stop writing any new exception contexts in this process.

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

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,11 @@ abstract class ExecutableElementImpl extends FunctionTypedElementImpl
21792179
/// so for them this flag is always `false`.
21802180
@trackedIncludedInId
21812181
bool get hasEnclosingTypeParameterReference {
2182-
return _firstFragment.hasEnclosingTypeParameterReference;
2182+
return !hasModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE);
2183+
}
2184+
2185+
set hasEnclosingTypeParameterReference(bool value) {
2186+
setModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE, !value);
21832187
}
21842188

21852189
@override
@@ -2383,17 +2387,6 @@ abstract class ExecutableFragmentImpl extends FunctionTypedFragmentImpl
23832387
_formalParameters = formalParameters;
23842388
}
23852389

2386-
/// Whether the type of this fragment references a type parameter of the
2387-
/// enclosing element. This includes not only explicitly specified type
2388-
/// annotations, but also inferred types.
2389-
bool get hasEnclosingTypeParameterReference {
2390-
return !hasModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE);
2391-
}
2392-
2393-
set hasEnclosingTypeParameterReference(bool value) {
2394-
setModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE, !value);
2395-
}
2396-
23972390
/// Whether the executable element is an operator.
23982391
///
23992392
/// The test may be based on the name of the executable element, in which
@@ -2824,7 +2817,11 @@ class FieldElementImpl extends PropertyInducingElementImpl
28242817
/// annotations, but also inferred types.
28252818
@trackedIncludedInId
28262819
bool get hasEnclosingTypeParameterReference {
2827-
return _firstFragment.hasEnclosingTypeParameterReference;
2820+
return !hasModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE);
2821+
}
2822+
2823+
set hasEnclosingTypeParameterReference(bool value) {
2824+
setModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE, !value);
28282825
}
28292826

28302827
@override
@@ -3083,17 +3080,6 @@ class FieldFragmentImpl extends PropertyInducingFragmentImpl
30833080
return super.enclosingFragment as InstanceFragmentImpl;
30843081
}
30853082

3086-
/// Whether the type of this fragment references a type parameter of the
3087-
/// enclosing element. This includes not only explicitly specified type
3088-
/// annotations, but also inferred types.
3089-
bool get hasEnclosingTypeParameterReference {
3090-
return !hasModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE);
3091-
}
3092-
3093-
set hasEnclosingTypeParameterReference(bool value) {
3094-
setModifier(Modifier.NO_ENCLOSING_TYPE_PARAMETER_REFERENCE, !value);
3095-
}
3096-
30973083
@override
30983084
MetadataImpl get metadata {
30993085
_ensureReadResolution();

pkg/analyzer/lib/src/summary2/element_builder.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,6 @@ class FragmentBuilder extends ThrowingAstVisitor<void> {
12181218

12191219
// Build the 'values' field.
12201220
var valuesField = FieldFragmentImpl(name: 'values')
1221-
..hasEnclosingTypeParameterReference = false
12221221
..isConst = true
12231222
..isStatic = true
12241223
..isSynthetic = true;

pkg/analyzer/lib/src/summary2/enclosing_type_parameters_flag.dart

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class EnclosingTypeParameterReferenceFlag {
2121
for (var field in topElement.fields) {
2222
if (!field.isSynthetic || field.isEnumValues) {
2323
var result = _hasTypeParameterReference(topElement, field.type);
24-
field.firstFragment.hasEnclosingTypeParameterReference = result;
25-
field.getter?.firstFragment.hasEnclosingTypeParameterReference =
26-
result;
27-
field.setter?.firstFragment.hasEnclosingTypeParameterReference =
28-
result;
24+
field.hasEnclosingTypeParameterReference = result;
25+
field.getter?.hasEnclosingTypeParameterReference = result;
26+
field.setter?.hasEnclosingTypeParameterReference = result;
2927
}
3028
}
3129

@@ -36,40 +34,27 @@ class EnclosingTypeParameterReferenceFlag {
3634
topElement,
3735
propertyAccessor.type,
3836
);
39-
propertyAccessor
40-
.firstFragment
41-
.hasEnclosingTypeParameterReference =
42-
result;
37+
propertyAccessor.hasEnclosingTypeParameterReference = result;
4338
if (propertyAccessor.variable case FieldElementImpl field) {
44-
field.firstFragment.hasEnclosingTypeParameterReference =
45-
result;
39+
field.hasEnclosingTypeParameterReference = result;
4640
}
4741
}
4842
}
4943

5044
for (var method in topElement.methods) {
51-
method.firstFragment.hasEnclosingTypeParameterReference =
45+
method.hasEnclosingTypeParameterReference =
5246
_hasTypeParameterReference(topElement, method.type);
5347
}
5448
case PropertyAccessorElementImpl():
5549
// Top-level accessors don't have type parameters.
5650
if (!topElement.isSynthetic) {
57-
topElement.firstFragment.hasEnclosingTypeParameterReference =
58-
false;
51+
topElement.hasEnclosingTypeParameterReference = false;
5952
}
6053
case TopLevelVariableElementImpl():
6154
// Top-level variables dont have type parameters.
6255
if (!topElement.isSynthetic) {
63-
topElement
64-
.getter
65-
?.firstFragment
66-
.hasEnclosingTypeParameterReference =
67-
false;
68-
topElement
69-
.setter
70-
?.firstFragment
71-
.hasEnclosingTypeParameterReference =
72-
false;
56+
topElement.getter?.hasEnclosingTypeParameterReference = false;
57+
topElement.setter?.hasEnclosingTypeParameterReference = false;
7358
}
7459
}
7560
}

0 commit comments

Comments
 (0)