Skip to content

Commit

Permalink
[_fe_analyzer_shared] Change signature of extension type constructors.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
stereotype441 authored and Commit Queue committed Jan 17, 2025
1 parent 9b7dc37 commit 240d87e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ extension type SharedRecordTypeView<
}

extension type SharedTypeSchemaView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
TypeStructure extends SharedTypeStructure<TypeStructure>>._(
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
SharedTypeSchemaView(TypeStructure typeStructure) : this._(typeStructure);

NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;

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

extension type SharedTypeView<
TypeStructure extends SharedTypeStructure<TypeStructure>>(
TypeStructure extends SharedTypeStructure<TypeStructure>>._(
SharedTypeStructure<TypeStructure> _typeStructure) implements Object {
SharedTypeView(TypeStructure typeStructure) : this._(typeStructure);

NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;

String getDisplayString() => _typeStructure.getDisplayString();
Expand Down Expand Up @@ -248,8 +252,7 @@ extension type SharedVoidTypeView<
/// [SharedTypeStructureExtension] as follows:
/// return e.foo()?.wrapSharedTypeView();
extension SharedTypeStructureExtension<
TypeStructure extends SharedTypeStructure<TypeStructure>>
on SharedTypeStructure<TypeStructure> {
TypeStructure extends SharedTypeStructure<TypeStructure>> on TypeStructure {
SharedTypeSchemaView<TypeStructure> wrapSharedTypeSchemaView() {
return new SharedTypeSchemaView(this);
}
Expand All @@ -261,8 +264,8 @@ extension SharedTypeStructureExtension<

extension SharedTypeStructureMapEntryExtension<
TypeStructure extends SharedTypeStructure<TypeStructure>> on ({
SharedTypeStructure<TypeStructure> keyType,
SharedTypeStructure<TypeStructure> valueType
TypeStructure keyType,
TypeStructure valueType
}) {
({
SharedTypeView<TypeStructure> keyType,
Expand Down

0 comments on commit 240d87e

Please sign in to comment.