Skip to content

Commit 4ce44bf

Browse files
fshcheglovCommit Queue
authored andcommitted
Deprecated getGetter2, getMethod2, getSetter2, lookUpConstructor2, lookUpGetter3, lookUpMethod3, and lookUpSetter3
Change-Id: I677b5fbf061946b5be10eea6873c959c4681c4a5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436022 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 2f601f5 commit 4ce44bf

17 files changed

+229
-46
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
* Deprecate `ExtensionTypeElement.representation2`, use `representation` instead.
5353
* Deprecate `ExtensionTypeFragment.primaryConstructor2`, use `primaryConstructor` instead.
5454
* Deprecate `ExtensionTypeFragment.representation2`, use `representation` instead.
55+
* Deprecate `InterfaceType.getGetter2`, use `getGetter` instead.
56+
* Deprecate `InterfaceType.getMethod2`, use `getMethod` instead.
57+
* Deprecate `InterfaceType.getSetter2`, use `getSetter` instead.
58+
* Deprecate `InterfaceType.lookUpConstructor2`, use `lookUpConstructor` instead.
59+
* Deprecate `InterfaceType.lookUpGetter3`, use `lookUpGetter` instead.
60+
* Deprecate `InterfaceType.lookUpMethod3`, use `lookUpMethod` instead.
61+
* Deprecate `InterfaceType.lookUpSetter3`, use `lookUpSetter` instead.
5562

5663
## 7.4.1
5764
* Restore `InstanceElement.augmented` getter.

pkg/analyzer/api.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,13 +4396,20 @@ package:analyzer/dart/element/type.dart:
43964396
setters (getter: List<SetterElement>, experimental)
43974397
superclass (getter: InterfaceType?)
43984398
superclassConstraints (getter: List<InterfaceType>)
4399-
getGetter2 (method: GetterElement? Function(String))
4400-
getMethod2 (method: MethodElement? Function(String))
4401-
getSetter2 (method: SetterElement? Function(String))
4402-
lookUpConstructor2 (method: ConstructorElement? Function(String?, LibraryElement))
4403-
lookUpGetter3 (method: GetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4404-
lookUpMethod3 (method: MethodElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4405-
lookUpSetter3 (method: SetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4399+
getGetter (method: GetterElement? Function(String))
4400+
getGetter2 (method: GetterElement? Function(String), deprecated)
4401+
getMethod (method: MethodElement? Function(String))
4402+
getMethod2 (method: MethodElement? Function(String), deprecated)
4403+
getSetter (method: SetterElement? Function(String))
4404+
getSetter2 (method: SetterElement? Function(String), deprecated)
4405+
lookUpConstructor (method: ConstructorElement? Function(String?, LibraryElement))
4406+
lookUpConstructor2 (method: ConstructorElement? Function(String?, LibraryElement), deprecated)
4407+
lookUpGetter (method: GetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4408+
lookUpGetter3 (method: GetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}), deprecated)
4409+
lookUpMethod (method: MethodElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4410+
lookUpMethod3 (method: MethodElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}), deprecated)
4411+
lookUpSetter (method: SetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}))
4412+
lookUpSetter3 (method: SetterElement? Function(String, LibraryElement, {bool concrete, bool inherited, bool recoveryStatic}), deprecated)
44064413
InvalidType (class extends Object implements DartType):
44074414
new (constructor: InvalidType Function())
44084415
NeverType (class extends Object implements DartType):

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,34 @@ abstract class InterfaceType implements ParameterizedType {
315315
/// Return the element representing the getter with the given [name] that is
316316
/// declared in this class, or `null` if this class does not declare a getter
317317
/// with the given name.
318+
GetterElement? getGetter(String name);
319+
320+
/// Return the element representing the getter with the given [name] that is
321+
/// declared in this class, or `null` if this class does not declare a getter
322+
/// with the given name.
323+
@Deprecated('Use getGetter instead')
318324
GetterElement? getGetter2(String name);
319325

320326
/// Return the element representing the method with the given [name] that is
321327
/// declared in this class, or `null` if this class does not declare a method
322328
/// with the given name.
329+
MethodElement? getMethod(String name);
330+
331+
/// Return the element representing the method with the given [name] that is
332+
/// declared in this class, or `null` if this class does not declare a method
333+
/// with the given name.
334+
@Deprecated('Use getMethod instead')
323335
MethodElement? getMethod2(String name);
324336

325337
/// Return the element representing the setter with the given [name] that is
326338
/// declared in this class, or `null` if this class does not declare a setter
327339
/// with the given name.
340+
SetterElement? getSetter(String name);
341+
342+
/// Return the element representing the setter with the given [name] that is
343+
/// declared in this class, or `null` if this class does not declare a setter
344+
/// with the given name.
345+
@Deprecated('Use getSetter instead')
328346
SetterElement? getSetter2(String name);
329347

330348
/// Return the element representing the constructor that results from looking
@@ -337,6 +355,19 @@ abstract class InterfaceType implements ParameterizedType {
337355
/// <i>T<i>. Otherwise, if <i>q</i> is not defined or not accessible, a
338356
/// NoSuchMethodException is thrown.
339357
/// </blockquote>
358+
ConstructorElement? lookUpConstructor(String? name, LibraryElement library);
359+
360+
/// Return the element representing the constructor that results from looking
361+
/// up the constructor with the given [name] in this class with respect to the
362+
/// given [library], or `null` if the look up fails. The behavior of this
363+
/// method is defined by the Dart Language Specification in section 12.11.1:
364+
/// <blockquote>
365+
/// If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be
366+
/// the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor
367+
/// <i>T<i>. Otherwise, if <i>q</i> is not defined or not accessible, a
368+
/// NoSuchMethodException is thrown.
369+
/// </blockquote>
370+
@Deprecated('Use lookUpConstructor instead')
340371
ConstructorElement? lookUpConstructor2(String? name, LibraryElement library);
341372

342373
/// Return the getter with the given [name].
@@ -349,6 +380,25 @@ abstract class InterfaceType implements ParameterizedType {
349380
///
350381
/// If [recoveryStatic] is `true`, then static getters of the class,
351382
/// and its superclasses are considered. Clients should not use it.
383+
GetterElement? lookUpGetter(
384+
String name,
385+
LibraryElement library, {
386+
bool concrete = false,
387+
bool inherited = false,
388+
bool recoveryStatic = false,
389+
});
390+
391+
/// Return the getter with the given [name].
392+
///
393+
/// If [concrete] is `true`, then the concrete implementation is returned,
394+
/// from this type, or its superclass.
395+
///
396+
/// If [inherited] is `true`, then only getters from the superclass are
397+
/// considered.
398+
///
399+
/// If [recoveryStatic] is `true`, then static getters of the class,
400+
/// and its superclasses are considered. Clients should not use it.
401+
@Deprecated('Use lookUpGetter instead')
352402
GetterElement? lookUpGetter3(
353403
String name,
354404
LibraryElement library, {
@@ -367,6 +417,25 @@ abstract class InterfaceType implements ParameterizedType {
367417
///
368418
/// If [recoveryStatic] is `true`, then static methods of the class,
369419
/// and its superclasses are considered. Clients should not use it.
420+
MethodElement? lookUpMethod(
421+
String name,
422+
LibraryElement library, {
423+
bool concrete = false,
424+
bool inherited = false,
425+
bool recoveryStatic = false,
426+
});
427+
428+
/// Return the method with the given [name].
429+
///
430+
/// If [concrete] is `true`, then the concrete implementation is returned,
431+
/// from this type, or its superclass.
432+
///
433+
/// If [inherited] is `true`, then only methods from the superclass are
434+
/// considered.
435+
///
436+
/// If [recoveryStatic] is `true`, then static methods of the class,
437+
/// and its superclasses are considered. Clients should not use it.
438+
@Deprecated('Use lookUpMethod instead')
370439
MethodElement? lookUpMethod3(
371440
String name,
372441
LibraryElement library, {
@@ -385,6 +454,25 @@ abstract class InterfaceType implements ParameterizedType {
385454
///
386455
/// If [recoveryStatic] is `true`, then static setters of the class,
387456
/// and its superclasses are considered. Clients should not use it.
457+
SetterElement? lookUpSetter(
458+
String name,
459+
LibraryElement library, {
460+
bool concrete = false,
461+
bool inherited = false,
462+
bool recoveryStatic = false,
463+
});
464+
465+
/// Return the setter with the given [name].
466+
///
467+
/// If [concrete] is `true`, then the concrete implementation is returned,
468+
/// from this type, or its superclass.
469+
///
470+
/// If [inherited] is `true`, then only setters from the superclass are
471+
/// considered.
472+
///
473+
/// If [recoveryStatic] is `true`, then static setters of the class,
474+
/// and its superclasses are considered. Clients should not use it.
475+
@Deprecated('Use lookUpSetter instead')
388476
SetterElement? lookUpSetter3(
389477
String name,
390478
LibraryElement library, {

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,7 @@ class _InstanceCreationEvaluator {
31483148
);
31493149
}
31503150
_fieldMap[fieldName] = evaluationResult;
3151-
var getter = definingType.getGetter2(fieldName);
3151+
var getter = definingType.getGetter(fieldName);
31523152
if (getter != null) {
31533153
var field = getter.variable3;
31543154
if (field == null) {
@@ -3441,7 +3441,7 @@ class _InstanceCreationEvaluator {
34413441
if (superclass != null && !superclass.isDartCoreObject) {
34423442
var superConstructor =
34433443
superclass
3444-
.lookUpConstructor2(superName, _constructor.library2)
3444+
.lookUpConstructor(superName, _constructor.library2)
34453445
?.asElement;
34463446
if (superConstructor == null) {
34473447
return null;

pkg/analyzer/lib/src/dart/constant/value.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,13 +1583,13 @@ class GenericState extends InstanceState {
15831583
var element = type.element3;
15841584
var library = element.library2;
15851585

1586-
var eqEq = type.lookUpMethod3('==', library, concrete: true);
1586+
var eqEq = type.lookUpMethod('==', library, concrete: true);
15871587
if (!isFromDartCoreObject(eqEq)) {
15881588
return false;
15891589
}
15901590

15911591
if (featureSet.isEnabled(Feature.patterns)) {
1592-
var hash = type.lookUpGetter3('hashCode', library, concrete: true);
1592+
var hash = type.lookUpGetter('hashCode', library, concrete: true);
15931593
if (!isFromDartCoreObject(hash)) {
15941594
return false;
15951595
}

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

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,25 +881,43 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
881881
}
882882

883883
@override
884-
GetterElement2OrMember? getGetter2(String getterName) {
884+
GetterElement2OrMember? getGetter(String getterName) {
885885
var element = element3.getGetter(getterName);
886886
return element != null ? GetterMember.forTargetType(element, this) : null;
887887
}
888888

889+
@Deprecated('Use getGetter instead')
889890
@override
890-
MethodElement2OrMember? getMethod2(String methodName) {
891+
GetterElement2OrMember? getGetter2(String getterName) {
892+
return getGetter(getterName);
893+
}
894+
895+
@override
896+
MethodElement2OrMember? getMethod(String methodName) {
891897
var element = element3.getMethod(methodName);
892898
return element != null ? MethodMember.forTargetType(element, this) : null;
893899
}
894900

901+
@Deprecated('Use getMethod instead')
895902
@override
896-
SetterElement2OrMember? getSetter2(String setterName) {
903+
MethodElement2OrMember? getMethod2(String methodName) {
904+
return getMethod(methodName);
905+
}
906+
907+
@override
908+
SetterElement2OrMember? getSetter(String setterName) {
897909
var element = element3.getSetter(setterName);
898910
return element != null ? SetterMember.forTargetType(element, this) : null;
899911
}
900912

913+
@Deprecated('Use getSetter instead')
901914
@override
902-
ConstructorElementMixin2? lookUpConstructor2(
915+
SetterElement2OrMember? getSetter2(String setterName) {
916+
return getSetter(setterName);
917+
}
918+
919+
@override
920+
ConstructorElementMixin2? lookUpConstructor(
903921
String? constructorName,
904922
LibraryElement library,
905923
) {
@@ -919,8 +937,17 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
919937
return ConstructorMember.from2(constructorElement, this);
920938
}
921939

940+
@Deprecated('Use lookUpConstructor instead')
922941
@override
923-
GetterElement2OrMember? lookUpGetter3(
942+
ConstructorElementMixin2? lookUpConstructor2(
943+
String? constructorName,
944+
LibraryElement library,
945+
) {
946+
return lookUpConstructor(constructorName, library);
947+
}
948+
949+
@override
950+
GetterElement2OrMember? lookUpGetter(
924951
String name,
925952
LibraryElement library, {
926953
bool concrete = false,
@@ -957,8 +984,26 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
957984
return null;
958985
}
959986

987+
@Deprecated('Use lookUpGetter instead')
960988
@override
961-
MethodElement2OrMember? lookUpMethod3(
989+
GetterElement2OrMember? lookUpGetter3(
990+
String name,
991+
LibraryElement library, {
992+
bool concrete = false,
993+
bool inherited = false,
994+
bool recoveryStatic = false,
995+
}) {
996+
return lookUpGetter(
997+
name,
998+
library,
999+
concrete: concrete,
1000+
inherited: inherited,
1001+
recoveryStatic: recoveryStatic,
1002+
);
1003+
}
1004+
1005+
@override
1006+
MethodElement2OrMember? lookUpMethod(
9621007
String name,
9631008
LibraryElement library, {
9641009
bool concrete = false,
@@ -995,8 +1040,26 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
9951040
return null;
9961041
}
9971042

1043+
@Deprecated('Use lookUpMethod instead')
9981044
@override
999-
SetterElement2OrMember? lookUpSetter3(
1045+
MethodElement2OrMember? lookUpMethod3(
1046+
String name,
1047+
LibraryElement library, {
1048+
bool concrete = false,
1049+
bool inherited = false,
1050+
bool recoveryStatic = false,
1051+
}) {
1052+
return lookUpMethod(
1053+
name,
1054+
library,
1055+
concrete: concrete,
1056+
inherited: inherited,
1057+
recoveryStatic: recoveryStatic,
1058+
);
1059+
}
1060+
1061+
@override
1062+
SetterElement2OrMember? lookUpSetter(
10001063
String name,
10011064
LibraryElement library, {
10021065
bool concrete = false,
@@ -1033,6 +1096,24 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
10331096
return null;
10341097
}
10351098

1099+
@Deprecated('Use lookUpSetter instead')
1100+
@override
1101+
SetterElement2OrMember? lookUpSetter3(
1102+
String name,
1103+
LibraryElement library, {
1104+
bool concrete = false,
1105+
bool inherited = false,
1106+
bool recoveryStatic = false,
1107+
}) {
1108+
return lookUpSetter(
1109+
name,
1110+
library,
1111+
concrete: concrete,
1112+
inherited: inherited,
1113+
recoveryStatic: recoveryStatic,
1114+
);
1115+
}
1116+
10361117
@Deprecated('Use referencesAny2() instead')
10371118
@override
10381119
bool referencesAny(Set<TypeParameterFragmentImpl> parameters) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ class TypeSystemImpl implements TypeSystem {
539539
FunctionTypeImpl? getCallMethodType(DartType t) {
540540
if (t is InterfaceTypeImpl) {
541541
return t
542-
.lookUpMethod3(MethodElement.CALL_METHOD_NAME, t.element3.library2)
542+
.lookUpMethod(MethodElement.CALL_METHOD_NAME, t.element3.library2)
543543
?.type;
544544
}
545545
return null;

pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class AnnotationResolver {
414414
List<WhyNotPromotedGetter> whyNotPromotedArguments, {
415415
required TypeConstraintGenerationDataForTesting? dataForTesting,
416416
}) {
417-
var constructorElement = aliasedType.lookUpConstructor2(
417+
var constructorElement = aliasedType.lookUpConstructor(
418418
constructorName?.name,
419419
_definingLibrary,
420420
);

pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class FunctionReferenceResolver {
175175
}
176176
// Otherwise, a 'call' method on the interface, or on an applicable
177177
// extension method applies.
178-
return type.lookUpMethod3(
178+
return type.lookUpMethod(
179179
MethodElement.CALL_METHOD_NAME,
180180
type.element3.library2,
181181
) ??

pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class InvocationInferenceHelper {
109109
var aliasedType = typeElement.aliasedType;
110110
if (aliasedType is InterfaceTypeImpl) {
111111
var constructorIdentifier = constructorName;
112-
rawElement = aliasedType.lookUpConstructor2(
112+
rawElement = aliasedType.lookUpConstructor(
113113
constructorIdentifier?.name,
114114
definingLibrary,
115115
);

0 commit comments

Comments
 (0)