Skip to content

Commit 240d87e

Browse files
stereotype441Commit Queue
authored andcommitted
[_fe_analyzer_shared] Change signature of extension type constructors.
The constructors for `SharedTypeView<TypeStructure>` and `SharedTypeSchemaView<TypeStructure>` are changed so that they accept `TypeStructure` rather than `SharedTypeStructure<TypeStructure>`. For context, I'm currently in the middle of migrating the analyzer so that it passes a type argument of `TypeImpl` instead of `DartType` when using generic types that accept a `TypeStructure` type argument. The purpose of this change is to ensure that when a given use of `SharedTypeView` or `SharedTypeSchemaView` has its type argument changed to `TypeImpl`, the type checker will ensure that the corresponding constructor argument satisfies `TypeImpl`. There is no change to runtime behavior. Change-Id: I34d540312b567e390e7dfa535806051e0d5f2868 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404900 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 9b7dc37 commit 240d87e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ extension type SharedRecordTypeView<
193193
}
194194

195195
extension type SharedTypeSchemaView<
196-
TypeStructure extends SharedTypeStructure<TypeStructure>>(
196+
TypeStructure extends SharedTypeStructure<TypeStructure>>._(
197197
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
198+
SharedTypeSchemaView(TypeStructure typeStructure) : this._(typeStructure);
199+
198200
NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;
199201

200202
String getDisplayString() => _typeStructure.getDisplayString();
@@ -203,8 +205,10 @@ extension type SharedTypeSchemaView<
203205
}
204206

205207
extension type SharedTypeView<
206-
TypeStructure extends SharedTypeStructure<TypeStructure>>(
208+
TypeStructure extends SharedTypeStructure<TypeStructure>>._(
207209
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
210+
SharedTypeView(TypeStructure typeStructure) : this._(typeStructure);
211+
208212
NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;
209213

210214
String getDisplayString() => _typeStructure.getDisplayString();
@@ -248,8 +252,7 @@ extension type SharedVoidTypeView<
248252
/// [SharedTypeStructureExtension] as follows:
249253
/// return e.foo()?.wrapSharedTypeView();
250254
extension SharedTypeStructureExtension<
251-
TypeStructure extends SharedTypeStructure<TypeStructure>>
252-
on SharedTypeStructure<TypeStructure> {
255+
TypeStructure extends SharedTypeStructure<TypeStructure>> on TypeStructure {
253256
SharedTypeSchemaView<TypeStructure> wrapSharedTypeSchemaView() {
254257
return new SharedTypeSchemaView(this);
255258
}
@@ -261,8 +264,8 @@ extension SharedTypeStructureExtension<
261264

262265
extension SharedTypeStructureMapEntryExtension<
263266
TypeStructure extends SharedTypeStructure<TypeStructure>> on ({
264-
SharedTypeStructure<TypeStructure> keyType,
265-
SharedTypeStructure<TypeStructure> valueType
267+
TypeStructure keyType,
268+
TypeStructure valueType
266269
}) {
267270
({
268271
SharedTypeView<TypeStructure> keyType,

0 commit comments

Comments
 (0)