Skip to content

Commit 875af7c

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Deprecated TypeProvider.futureType2/listType2/etc
Change-Id: Ia994be1e29b4d96b89d714beafcb9256a0cb4de6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184641 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent d352bc2 commit 875af7c

34 files changed

+204
-126
lines changed

pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ DartType impliedDartTypeWithName(TypeProvider typeProvider, String name) {
5353
} else if (numNames.contains(name)) {
5454
return typeProvider.numType;
5555
} else if (listNames.contains(name)) {
56-
return typeProvider.listType2(typeProvider.dynamicType);
56+
return typeProvider.listType(typeProvider.dynamicType);
5757
} else if (stringNames.contains(name)) {
5858
return typeProvider.stringType;
5959
} else if (name == 'iterator') {
6060
return typeProvider.iterableDynamicType;
6161
} else if (name == 'map') {
62-
return typeProvider.mapType2(
62+
return typeProvider.mapType(
6363
typeProvider.dynamicType, typeProvider.dynamicType);
6464
}
6565
return null;
@@ -890,7 +890,7 @@ class _ContextTypeVisitor extends SimpleAstVisitor<DartType> {
890890
if (currentNode.isSet) {
891891
return typeProvider.iterableDynamicType;
892892
}
893-
return typeProvider.mapType2(
893+
return typeProvider.mapType(
894894
typeProvider.dynamicType, typeProvider.dynamicType);
895895
}
896896
currentNode = currentNode.parent;

pkg/analysis_server/lib/src/services/correction/dart/add_null_check.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class AddNullCheck extends CorrectionProducer {
4545
toType = parent.realTarget.staticType;
4646
} else if (parent is ForEachPartsWithDeclaration) {
4747
toType =
48-
typeProvider.iterableType2(parent.loopVariable.declaredElement.type);
48+
typeProvider.iterableType(parent.loopVariable.declaredElement.type);
4949
} else if (parent is ForEachPartsWithIdentifier) {
50-
toType = typeProvider.iterableType2(parent.identifier.staticType);
50+
toType = typeProvider.iterableType(parent.identifier.staticType);
5151
} else if (parent is SpreadElement) {
5252
var literal = parent.thisOrAncestorOfType<TypedLiteral>();
5353
if (literal is ListLiteral) {

pkg/analysis_server/lib/src/services/refactoring/extract_method.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
762762
} else if (_returnType == null) {
763763
variableType = null;
764764
if (_hasAwait) {
765-
var futureVoid = typeProvider.futureType2(typeProvider.voidType);
765+
var futureVoid = typeProvider.futureType(typeProvider.voidType);
766766
returnType = _getTypeCode(futureVoid);
767767
} else {
768768
returnType = 'void';
@@ -778,7 +778,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
778778
variableType = _getTypeCode(_returnType);
779779
if (_hasAwait) {
780780
if (_returnType.element != typeProvider.futureElement) {
781-
returnType = _getTypeCode(typeProvider.futureType2(_returnType));
781+
returnType = _getTypeCode(typeProvider.futureType(_returnType));
782782
}
783783
} else {
784784
returnType = variableType;

pkg/analyzer/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0-dev
2+
* Deprecated `TypeProvider.futureType2()`, `iterableType2()`, etc.
3+
Use corresponding `TypeProvider.futureType()`, `iterableType()`, etc.
4+
15
## 1.0.0
26
* Stable null safety release.
37
* Updated dependencies to null safe releases.

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,76 @@ abstract class TypeProvider {
127127

128128
/// Return the instantiation of the built-in class `FutureOr` with the
129129
/// given [valueType]. The type has the nullability suffix of this provider.
130+
InterfaceType futureOrType(DartType valueType);
131+
132+
/// Return the instantiation of the built-in class `FutureOr` with the
133+
/// given [valueType]. The type has the nullability suffix of this provider.
134+
@Deprecated('Use futureOrType instead')
130135
InterfaceType futureOrType2(DartType valueType);
131136

132137
/// Return the instantiation of the built-in class `Future` with the
133138
/// given [valueType]. The type has the nullability suffix of this provider.
139+
InterfaceType futureType(DartType valueType);
140+
141+
/// Return the instantiation of the built-in class `Future` with the
142+
/// given [valueType]. The type has the nullability suffix of this provider.
143+
@Deprecated('Use futureType instead')
134144
InterfaceType futureType2(DartType valueType);
135145

136-
/// Return 'true' if [id] is the name of a getter on the Object type.
146+
/// Return 'true' if [id] is the name of a getter on the `Object` type.
137147
bool isObjectGetter(String id);
138148

139-
/// Return 'true' if [id] is the name of a method or getter on the Object
149+
/// Return 'true' if [id] is the name of a method or getter on the `Object`
140150
/// type.
141151
bool isObjectMember(String id);
142152

143-
/// Return 'true' if [id] is the name of a method on the Object type.
153+
/// Return 'true' if [id] is the name of a method on the `Object` type.
144154
bool isObjectMethod(String id);
145155

146156
/// Return the instantiation of the built-in class `Iterable` with the
147157
/// given [elementType]. The type has the nullability suffix of this provider.
158+
InterfaceType iterableType(DartType elementType);
159+
160+
/// Return the instantiation of the built-in class `Iterable` with the
161+
/// given [elementType]. The type has the nullability suffix of this provider.
162+
@Deprecated('Use iterableType instead')
148163
InterfaceType iterableType2(DartType elementType);
149164

150165
/// Return the instantiation of the built-in class `List` with the
151166
/// given [elementType]. The type has the nullability suffix of this provider.
167+
InterfaceType listType(DartType elementType);
168+
169+
/// Return the instantiation of the built-in class `List` with the
170+
/// given [elementType]. The type has the nullability suffix of this provider.
171+
@Deprecated('Use listType instead')
152172
InterfaceType listType2(DartType elementType);
153173

154174
/// Return the instantiation of the built-in class `List` with the
155175
/// given [keyType] and [valueType]. The type has the nullability suffix of
156176
/// this provider.
177+
InterfaceType mapType(DartType keyType, DartType valueType);
178+
179+
/// Return the instantiation of the built-in class `List` with the
180+
/// given [keyType] and [valueType]. The type has the nullability suffix of
181+
/// this provider.
182+
@Deprecated('Use mapType instead')
157183
InterfaceType mapType2(DartType keyType, DartType valueType);
158184

159185
/// Return the instantiation of the built-in class `Set` with the
160186
/// given [elementType]. The type has the nullability suffix of this provider.
187+
InterfaceType setType(DartType elementType);
188+
189+
/// Return the instantiation of the built-in class `Set` with the
190+
/// given [elementType]. The type has the nullability suffix of this provider.
191+
@Deprecated('Use setType instead')
161192
InterfaceType setType2(DartType elementType);
162193

163194
/// Return the instantiation of the built-in class `Stream` with the
164195
/// given [elementType]. The type has the nullability suffix of this provider.
196+
InterfaceType streamType(DartType elementType);
197+
198+
/// Return the instantiation of the built-in class `Stream` with the
199+
/// given [elementType]. The type has the nullability suffix of this provider.
200+
@Deprecated('Use streamType instead')
165201
InterfaceType streamType2(DartType elementType);
166202
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
11601160
nodeType is InterfaceType && nodeType.typeArguments.isNotEmpty
11611161
? nodeType.typeArguments[0]
11621162
: _typeProvider.dynamicType;
1163-
InterfaceType listType = _typeProvider.listType2(elementType);
1163+
InterfaceType listType = _typeProvider.listType(elementType);
11641164
return DartObjectImpl(typeSystem, listType, ListState(list));
11651165
}
11661166

@@ -1301,7 +1301,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
13011301
valueType = typeArguments[1];
13021302
}
13031303
}
1304-
InterfaceType mapType = _typeProvider.mapType2(keyType, valueType);
1304+
InterfaceType mapType = _typeProvider.mapType(keyType, valueType);
13051305
return DartObjectImpl(typeSystem, mapType, MapState(map));
13061306
} else {
13071307
if (!node.isConst) {
@@ -1322,7 +1322,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
13221322
nodeType is InterfaceType && nodeType.typeArguments.isNotEmpty
13231323
? nodeType.typeArguments[0]
13241324
: _typeProvider.dynamicType;
1325-
InterfaceType setType = _typeProvider.setType2(elementType);
1325+
InterfaceType setType = _typeProvider.setType(elementType);
13261326
return DartObjectImpl(typeSystem, setType, SetState(set));
13271327
}
13281328
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ class ConstFieldElementImpl_EnumValues extends ConstFieldElementImpl_ofEnum {
17811781
@override
17821782
InterfaceType get typeInternal {
17831783
if (_type == null) {
1784-
return _type = library.typeProvider.listType2(_enum.thisType);
1784+
return _type = library.typeProvider.listType(_enum.thisType);
17851785
}
17861786
return _type as InterfaceType;
17871787
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ class GreatestLowerBoundHelper {
226226
if (T2 is InterfaceTypeImpl && T2.isDartAsyncFutureOr) {
227227
var S2 = T2.typeArguments[0];
228228
var S = getGreatestLowerBound(S1, S2);
229-
return _typeProvider.futureOrType2(S);
229+
return _typeProvider.futureOrType(S);
230230
}
231231
// DOWN(FutureOr<S1>, Future<S2>) = Future(S)
232232
// S = DOWN(S1, S2)
233233
if (T2 is InterfaceTypeImpl && T2.isDartAsyncFuture) {
234234
var S2 = T2.typeArguments[0];
235235
var S = getGreatestLowerBound(S1, S2);
236-
return _typeProvider.futureType2(S);
236+
return _typeProvider.futureType(S);
237237
}
238238
// DOWN(FutureOr<S1>, T2) = DOWN(S1, T2)
239239
return getGreatestLowerBound(S1, T2);
@@ -247,7 +247,7 @@ class GreatestLowerBoundHelper {
247247
if (T1 is InterfaceTypeImpl && T1.isDartAsyncFuture) {
248248
var S1 = T1.typeArguments[0];
249249
var S = getGreatestLowerBound(S1, S2);
250-
return _typeProvider.futureType2(S);
250+
return _typeProvider.futureType(S);
251251
}
252252
// DOWN(T1, FutureOr<S2>) = DOWN(T1, S2)
253253
return getGreatestLowerBound(T1, S2);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,31 +853,31 @@ class LeastUpperBoundHelper {
853853
// UP(FutureOr<T1>, FutureOr<T2>) = FutureOr<T3> where T3 = UP(T1, T2)
854854
if (T1_futureOr != null && T2_futureOr != null) {
855855
var T3 = getLeastUpperBound(T1_futureOr, T2_futureOr);
856-
return _typeSystem.typeProvider.futureOrType2(T3);
856+
return _typeSystem.typeProvider.futureOrType(T3);
857857
}
858858

859859
// UP(Future<T1>, FutureOr<T2>) = FutureOr<T3> where T3 = UP(T1, T2)
860860
if (T1_future != null && T2_futureOr != null) {
861861
var T3 = getLeastUpperBound(T1_future, T2_futureOr);
862-
return _typeSystem.typeProvider.futureOrType2(T3);
862+
return _typeSystem.typeProvider.futureOrType(T3);
863863
}
864864

865865
// UP(FutureOr<T1>, Future<T2>) = FutureOr<T3> where T3 = UP(T1, T2)
866866
if (T1_futureOr != null && T2_future != null) {
867867
var T3 = getLeastUpperBound(T1_futureOr, T2_future);
868-
return _typeSystem.typeProvider.futureOrType2(T3);
868+
return _typeSystem.typeProvider.futureOrType(T3);
869869
}
870870

871871
// UP(T1, FutureOr<T2>) = FutureOr<T3> where T3 = UP(T1, T2)
872872
if (T2_futureOr != null) {
873873
var T3 = getLeastUpperBound(T1, T2_futureOr);
874-
return _typeSystem.typeProvider.futureOrType2(T3);
874+
return _typeSystem.typeProvider.futureOrType(T3);
875875
}
876876

877877
// UP(FutureOr<T1>, T2) = FutureOr<T3> where T3 = UP(T1, T2)
878878
if (T1_futureOr != null) {
879879
var T3 = getLeastUpperBound(T1_futureOr, T2);
880-
return _typeSystem.typeProvider.futureOrType2(T3);
880+
return _typeSystem.typeProvider.futureOrType(T3);
881881
}
882882

883883
return null;

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

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,61 +369,103 @@ class TypeProviderImpl extends TypeProviderBase {
369369
}
370370

371371
@override
372-
InterfaceType futureOrType2(DartType valueType) {
372+
InterfaceType futureOrType(DartType valueType) {
373373
return futureOrElement.instantiate(
374374
typeArguments: [valueType],
375375
nullabilitySuffix: _nullabilitySuffix,
376376
);
377377
}
378378

379+
@Deprecated('Use futureOrType instead')
379380
@override
380-
InterfaceType futureType2(DartType valueType) {
381+
InterfaceType futureOrType2(DartType valueType) {
382+
return futureOrType(valueType);
383+
}
384+
385+
@override
386+
InterfaceType futureType(DartType valueType) {
381387
return futureElement.instantiate(
382388
typeArguments: [valueType],
383389
nullabilitySuffix: _nullabilitySuffix,
384390
);
385391
}
386392

393+
@Deprecated('Use futureType instead')
387394
@override
388-
InterfaceType iterableType2(DartType elementType) {
395+
InterfaceType futureType2(DartType valueType) {
396+
return futureType(valueType);
397+
}
398+
399+
@override
400+
InterfaceType iterableType(DartType elementType) {
389401
return iterableElement.instantiate(
390402
typeArguments: [elementType],
391403
nullabilitySuffix: _nullabilitySuffix,
392404
);
393405
}
394406

407+
@Deprecated('Use iterableType instead')
395408
@override
396-
InterfaceType listType2(DartType elementType) {
409+
InterfaceType iterableType2(DartType elementType) {
410+
return iterableType(elementType);
411+
}
412+
413+
@override
414+
InterfaceType listType(DartType elementType) {
397415
return listElement.instantiate(
398416
typeArguments: [elementType],
399417
nullabilitySuffix: _nullabilitySuffix,
400418
);
401419
}
402420

421+
@Deprecated('Use listType instead')
403422
@override
404-
InterfaceType mapType2(DartType keyType, DartType valueType) {
423+
InterfaceType listType2(DartType elementType) {
424+
return listType(elementType);
425+
}
426+
427+
@override
428+
InterfaceType mapType(DartType keyType, DartType valueType) {
405429
return mapElement.instantiate(
406430
typeArguments: [keyType, valueType],
407431
nullabilitySuffix: _nullabilitySuffix,
408432
);
409433
}
410434

435+
@Deprecated('Use mapType instead')
411436
@override
412-
InterfaceType setType2(DartType elementType) {
437+
InterfaceType mapType2(DartType keyType, DartType valueType) {
438+
return mapType(keyType, valueType);
439+
}
440+
441+
@override
442+
InterfaceType setType(DartType elementType) {
413443
return setElement.instantiate(
414444
typeArguments: [elementType],
415445
nullabilitySuffix: _nullabilitySuffix,
416446
);
417447
}
418448

449+
@Deprecated('Use setType instead')
419450
@override
420-
InterfaceType streamType2(DartType elementType) {
451+
InterfaceType setType2(DartType elementType) {
452+
return setType(elementType);
453+
}
454+
455+
@override
456+
InterfaceType streamType(DartType elementType) {
421457
return streamElement.instantiate(
422458
typeArguments: [elementType],
423459
nullabilitySuffix: _nullabilitySuffix,
424460
);
425461
}
426462

463+
@Deprecated('Use streamType instead')
464+
@override
465+
InterfaceType streamType2(DartType elementType) {
466+
return streamType(elementType);
467+
}
468+
427469
/// Return the class with the given [name] from the given [library], or
428470
/// throw a [StateError] if there is no class with the given name.
429471
ClassElement _getClassElement(LibraryElement library, String name) {

0 commit comments

Comments
 (0)