Skip to content

Commit 7dc5a42

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Change substitute methods to return TypeImpl.
The following methods are changed so that they return `TypeImpl` rather than `DartType`: - `FreshTypeParameters.substitute` - `Substitution.substituteType` - `_NullSubstitution.substituteType` This is part of a larger arc of work to change the analyzer's use of the shared code so that the type parameters it supplies are not part of the analyzer public API. See #59763. Change-Id: Iaf4959cd7f6428d1dbe1b15089f7e2a30eff3495 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405080 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent b069a13 commit 7dc5a42

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11001,7 +11001,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl
1100111001
? NullabilitySuffix.question
1100211002
: nullabilitySuffix;
1100311003

11004-
if (type is FunctionType) {
11004+
if (type is FunctionTypeImpl) {
1100511005
return FunctionTypeImpl(
1100611006
typeFormals: type.typeFormals,
1100711007
parameters: type.parameters,
@@ -11032,7 +11032,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl
1103211032
typeArguments: typeArguments,
1103311033
),
1103411034
);
11035-
} else if (type is TypeParameterType) {
11035+
} else if (type is TypeParameterTypeImpl) {
1103611036
return TypeParameterTypeImpl(
1103711037
element: type.element,
1103811038
nullabilitySuffix: resultNullability,
@@ -11042,7 +11042,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl
1104211042
),
1104311043
);
1104411044
} else {
11045-
return (type as TypeImpl).withNullability(resultNullability);
11045+
return type.withNullability(resultNullability);
1104611046
}
1104711047
}
1104811048

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class FreshTypeParameters {
180180
);
181181
}
182182

183-
DartType substitute(DartType type) => substitution.substituteType(type);
183+
TypeImpl substitute(DartType type) => substitution.substituteType(type);
184184
}
185185

186186
/// Substitution that is based on the [map].
@@ -205,9 +205,9 @@ abstract class Substitution {
205205
return types.map(mapInterfaceType);
206206
}
207207

208-
DartType substituteType(DartType type, {bool contravariant = false}) {
208+
TypeImpl substituteType(DartType type, {bool contravariant = false}) {
209209
var visitor = _TopSubstitutor(this, contravariant);
210-
return type.accept(visitor);
210+
return type.accept(visitor) as TypeImpl;
211211
}
212212

213213
/// Substitutes both variables from [first] and [second], favoring those from
@@ -390,7 +390,8 @@ class _NullSubstitution extends MapSubstitution {
390390
}
391391

392392
@override
393-
DartType substituteType(DartType type, {bool contravariant = false}) => type;
393+
TypeImpl substituteType(DartType type, {bool contravariant = false}) =>
394+
type as TypeImpl;
394395

395396
@override
396397
String toString() => "Substitution.empty";

0 commit comments

Comments
 (0)