Skip to content

Commit 30270ba

Browse files
committed
Elements. Deprecate InterfaceElement.
Change-Id: I59d5a7d98ebde932f411ba3f6e17da43ebf662e8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418940 Reviewed-by: Paul Berry <[email protected]>
1 parent 1a08dac commit 30270ba

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

pkg/analyzer/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,7 @@ package:analyzer/dart/element/element.dart:
33373337
isAugmentation (getter: bool)
33383338
methods (getter: List<MethodElement>)
33393339
thisType (getter: DartType)
3340-
InterfaceElement (class extends Object implements InstanceElement):
3340+
InterfaceElement (class extends Object implements InstanceElement, deprecated):
33413341
new (constructor: InterfaceElement Function())
33423342
allSupertypes (getter: List<InterfaceType>)
33433343
constructors (getter: List<ConstructorElement>, deprecated)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ abstract class InstanceElement
13491349
/// An element that defines an [InterfaceType].
13501350
///
13511351
/// Clients may not extend, implement or mix-in this class.
1352+
@Deprecated('Use InterfaceElement2 instead')
13521353
abstract class InterfaceElement implements InstanceElement {
13531354
/// All the supertypes defined for this element and its supertypes.
13541355
///

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,6 @@ class ClassElementImpl extends ClassOrMixinElementImpl
218218
return false;
219219
}
220220

221-
/// Return `true` if the class has a concrete `noSuchMethod()` method distinct
222-
/// from the one declared in class `Object`, as per the Dart Language
223-
/// Specification (section 10.4).
224-
bool get hasNoSuchMethod {
225-
MethodElement? method = lookUpConcreteMethod(
226-
FunctionElement.NO_SUCH_METHOD_METHOD_NAME, library);
227-
var definingClass = method?.enclosingElement3 as ClassElementImpl?;
228-
return definingClass != null && !definingClass.isDartCoreObject;
229-
}
230-
231221
@override
232222
bool get isAbstract {
233223
return hasModifier(Modifier.ABSTRACT);
@@ -5939,7 +5929,10 @@ abstract class InstanceElementImpl2 extends ElementImpl2
59395929
}
59405930

59415931
abstract class InterfaceElementImpl extends InstanceElementImpl
5942-
implements InterfaceElement, InterfaceFragment {
5932+
implements
5933+
// ignore:deprecated_member_use_from_same_package
5934+
InterfaceElement,
5935+
InterfaceFragment {
59435936
/// A list containing all of the mixins that are applied to the class being
59445937
/// extended in order to derive the superclass of this class.
59455938
List<InterfaceTypeImpl> _mixins = const [];
@@ -6152,6 +6145,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
61526145
);
61536146
}
61546147

6148+
@Deprecated('Use InterfaceElementImpl2 instead')
61556149
@override
61566150
MethodElement? lookUpConcreteMethod(
61576151
String methodName, LibraryElement library) {
@@ -6167,6 +6161,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
61676161
.firstWhereOrNull((getter) => getter.isAccessibleIn(library));
61686162
}
61696163

6164+
@Deprecated('Use InterfaceElementImpl2 instead')
61706165
@override
61716166
PropertyAccessorElement? lookUpInheritedConcreteGetter(
61726167
String getterName, LibraryElement library) {
@@ -6188,6 +6183,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
61886183
}
61896184
}
61906185

6186+
@Deprecated('Use InterfaceElementImpl2 instead')
61916187
@override
61926188
MethodElement? lookUpInheritedConcreteMethod(
61936189
String methodName, LibraryElement library) {
@@ -6209,6 +6205,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
62096205
setter.enclosingElement3 != this);
62106206
}
62116207

6208+
@Deprecated('Use InterfaceElementImpl2 instead')
62126209
@override
62136210
MethodElement? lookUpInheritedMethod(
62146211
String methodName, LibraryElement library) {
@@ -6238,6 +6235,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
62386235
/// This method should be used only for error recovery during analysis,
62396236
/// when instance access to a static class member, defined in this class,
62406237
/// or a superclass.
6238+
@Deprecated('Use InterfaceElementImpl2 instead')
62416239
PropertyAccessorElementOrMember? lookupStaticGetter(
62426240
String name, LibraryElement library) {
62436241
return _implementationsOfGetter(name).firstWhereOrNull(
@@ -6249,6 +6247,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
62496247
/// This method should be used only for error recovery during analysis,
62506248
/// when instance access to a static class member, defined in this class,
62516249
/// or a superclass.
6250+
@Deprecated('Use InterfaceElementImpl2 instead')
62526251
MethodElementOrMember? lookupStaticMethod(
62536252
String name, LibraryElement library) {
62546253
return _implementationsOfMethod(name).firstWhereOrNull(
@@ -6285,6 +6284,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
62856284
/// The getters are returned based on the depth of their defining class; if
62866285
/// this class contains a definition of the getter it will occur first, if
62876286
/// Object contains a definition of the getter it will occur last.
6287+
@Deprecated('Use InterfaceElementImpl2 instead')
62886288
Iterable<PropertyAccessorElementOrMember> _implementationsOfGetter(
62896289
String getterName) sync* {
62906290
var visitedClasses = <InterfaceElement>{};
@@ -6315,6 +6315,7 @@ abstract class InterfaceElementImpl extends InstanceElementImpl
63156315
/// The methods are returned based on the depth of their defining class; if
63166316
/// this class contains a definition of the method it will occur first, if
63176317
/// Object contains a definition of the method it will occur last.
6318+
@Deprecated('Use InterfaceElementImpl2 instead')
63186319
Iterable<MethodElementOrMember> _implementationsOfMethod(
63196320
String methodName) sync* {
63206321
var visitedClasses = <InterfaceElement>{};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ class TypeProviderImpl extends TypeProviderBase {
593593
@Deprecated('Use isNonSubtypableClass2() instead')
594594
@override
595595
bool isNonSubtypableClass(InterfaceElement element) {
596-
return isNonSubtypableClass2(element.asElement2);
596+
element as InterfaceElementImpl;
597+
return isNonSubtypableClass2(element.element);
597598
}
598599

599600
@override

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,18 +483,6 @@ extension InstanceElementImplExtension on InstanceElementImpl {
483483
}
484484
}
485485

486-
extension InterfaceElement2Extension on InterfaceElement2 {
487-
InterfaceElement get asElement {
488-
return firstFragment as InterfaceElement;
489-
}
490-
}
491-
492-
extension InterfaceElementExtension on InterfaceElement {
493-
InterfaceElement2 get asElement2 {
494-
return (this as InterfaceElementImpl).element;
495-
}
496-
}
497-
498486
extension InterfaceElementImpl2Extension on InterfaceElementImpl2 {
499487
InterfaceElementImpl get asElement {
500488
return firstFragment;

0 commit comments

Comments
 (0)