Skip to content

Commit fdc4697

Browse files
committed
Elements. Deprecate ExecutableElement.
Change-Id: Ic66c9df46bfcfe93d2e6bd93315e298eee694533 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418831 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent b18ffd3 commit fdc4697

File tree

5 files changed

+15
-35
lines changed

5 files changed

+15
-35
lines changed

pkg/analyzer/api.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,7 +3268,7 @@ package:analyzer/dart/element/element.dart:
32683268
visitTypeParameterElement (method: R? Function(TypeParameterElement))
32693269
EnumElement (class extends Object implements InterfaceElement, deprecated):
32703270
new (constructor: EnumElement Function())
3271-
ExecutableElement (class extends Object implements FunctionTypedElement):
3271+
ExecutableElement (class extends Object implements FunctionTypedElement, deprecated):
32723272
new (constructor: ExecutableElement Function())
32733273
declaration (getter: ExecutableElement)
32743274
displayName (getter: String)
@@ -3367,7 +3367,7 @@ package:analyzer/dart/element/element.dart:
33673367
variables (getter: List<PatternVariableElement>)
33683368
LabelElement (class extends Object implements Element):
33693369
new (constructor: LabelElement Function())
3370-
enclosingElement3 (getter: ExecutableElement)
3370+
enclosingElement3 (getter: ExecutableElement, deprecated)
33713371
name (getter: String)
33723372
LibraryElement (class extends Object implements _ExistingElement):
33733373
new (constructor: LibraryElement Function())

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ abstract class EnumElement implements InterfaceElement {}
10961096
/// constructors, getters, and setters.
10971097
///
10981098
/// Clients may not extend, implement or mix-in this class.
1099+
@Deprecated('Use ExecutableElement2 instead')
10991100
abstract class ExecutableElement implements FunctionTypedElement {
11001101
@override
11011102
ExecutableElement get declaration;
@@ -1631,6 +1632,7 @@ abstract class JoinPatternVariableElement implements PatternVariableElement {
16311632
///
16321633
/// Clients may not extend, implement or mix-in this class.
16331634
abstract class LabelElement implements Element {
1635+
@Deprecated(elementModelDeprecationMsg)
16341636
@override
16351637
ExecutableElement get enclosingElement3;
16361638

@@ -1807,6 +1809,7 @@ class LibraryLanguageVersion {
18071809
}
18081810

18091811
/// An element that can be (but is not required to be) defined within a method
1812+
// ignore:deprecated_member_use_from_same_package
18101813
/// or function (an [ExecutableElement]).
18111814
///
18121815
/// Clients may not extend, implement or mix-in this class.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,7 +3610,6 @@ abstract class ExecutableElement2OrMember implements ExecutableElement2 {
36103610
FunctionTypeImpl get type;
36113611
}
36123612

3613-
/// A base class for concrete implementations of an [ExecutableElement].
36143613
abstract class ExecutableElementImpl extends _ExistingElementImpl
36153614
with AugmentableFragment, TypeParameterizedElementMixin
36163615
implements ExecutableElementOrMember, ExecutableFragment {
@@ -3849,7 +3848,10 @@ abstract class ExecutableElementImpl2 extends FunctionTypedElementImpl2
38493848
/// Common base class for all analyzer-internal classes that implement
38503849
/// `ExecutableElement`.
38513850
abstract class ExecutableElementOrMember
3852-
implements ExecutableElement, ElementOrMember {
3851+
implements
3852+
// ignore:deprecated_member_use_from_same_package
3853+
ExecutableElement,
3854+
ElementOrMember {
38533855
@override
38543856
List<ParameterElementMixin> get parameters;
38553857

@@ -7771,7 +7773,7 @@ class LocalFunctionFragmentImpl extends FunctionElementImpl
77717773
@override
77727774
bool get _includeNameOffsetInIdentifier {
77737775
return super._includeNameOffsetInIdentifier ||
7774-
enclosingElement3 is ExecutableElement ||
7776+
enclosingElement3 is ExecutableFragment ||
77757777
enclosingElement3 is VariableElement;
77767778
}
77777779
}
@@ -8668,7 +8670,7 @@ enum Modifier {
86688670
HAS_SINCE_SDK_VERSION_VALUE,
86698671

86708672
/// Indicates that the associated element did not have an explicit type
8671-
/// associated with it. If the element is an [ExecutableElement], then the
8673+
/// associated with it. If the element is an [ExecutableElement2], then the
86728674
/// type being referred to is the return type.
86738675
IMPLICIT_TYPE,
86748676

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class InheritanceManager3 {
170170
@experimental
171171
ExecutableElement2? getInherited3(InterfaceType type, Name name) {
172172
var element = getInherited(type, name);
173-
return element.asElement2;
173+
return element?.asElement2;
174174
}
175175

176176
/// Returns the most specific signature of the member with the given [name]

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

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -323,28 +323,6 @@ extension ExecutableElement2Extension on ExecutableElement2 {
323323
}
324324
}
325325

326-
extension ExecutableElement2OrNullExtension on ExecutableElement2? {
327-
ExecutableElement? get asElement {
328-
return this?.asElement;
329-
}
330-
}
331-
332-
extension ExecutableElementExtension on ExecutableElement {
333-
ExecutableElement2OrMember get asElement2 {
334-
return switch (this) {
335-
ExecutableFragment(:var element) => element,
336-
ExecutableMember member => member,
337-
_ => throw UnsupportedError('Unsupported type: $runtimeType'),
338-
}
339-
// TODO(paulberry): eliminate this cast by using impl types in the
340-
// switch patterns above.
341-
as ExecutableElement2OrMember;
342-
}
343-
344-
ExecutableElementImpl get declarationImpl =>
345-
declaration as ExecutableElementImpl;
346-
}
347-
348326
extension ExecutableElementImpl2Extension on ExecutableElementImpl2 {
349327
ExecutableElementImpl get asElement {
350328
return lastFragment;
@@ -366,13 +344,10 @@ extension ExecutableElementOrMemberExtension on ExecutableElementOrMember {
366344
};
367345
}
368346

369-
ElementImpl get enclosingElementImpl => enclosingElement3 as ElementImpl;
370-
}
347+
ExecutableElementImpl get declarationImpl =>
348+
declaration as ExecutableElementImpl;
371349

372-
extension ExecutableElementOrNullExtension on ExecutableElement? {
373-
ExecutableElement2? get asElement2 {
374-
return this?.asElement2;
375-
}
350+
ElementImpl get enclosingElementImpl => enclosingElement3 as ElementImpl;
376351
}
377352

378353
extension ExtensionElementImpl2Extension on ExtensionElementImpl2 {

0 commit comments

Comments
 (0)