[cfe] Remove ExtensionFragment.extensionThisType
This is no longer needed since the extension on type has now been computed before extension member builders are created.
Change-Id: I9a199bbed9fc6e5ee907b74cd5ff7d5515afea00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398100
Reviewed-by: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/lib/src/fragment/extension.dart b/pkg/front_end/lib/src/fragment/extension.dart
index 562f439..840c0d5 100644
--- a/pkg/front_end/lib/src/fragment/extension.dart
+++ b/pkg/front_end/lib/src/fragment/extension.dart
@@ -10,12 +10,6 @@
@override
final int fileOffset;
- /// The type of `this` in instance methods declared in extension declarations.
- ///
- /// Instance methods declared in extension declarations methods are extended
- /// with a synthesized parameter of this type.
- TypeBuilder? _extensionThisType;
-
SourceExtensionBuilder? _builder;
late final List<MetadataBuilder>? metadata;
@@ -56,35 +50,6 @@
DeclarationFragmentKind get kind =>
DeclarationFragmentKind.extensionDeclaration;
- /// Registers the 'extension this type' of the extension declaration prepared
- /// for by this builder.
- ///
- /// See [extensionThisType] for terminology.
- void registerExtensionThisType(TypeBuilder type) {
- assert(_extensionThisType == null,
- "Extension this type has already been set.");
- _extensionThisType = type;
- }
-
- // Coverage-ignore(suite): Not run.
- /// Returns the 'extension this type' of the extension declaration prepared
- /// for by this builder.
- ///
- /// The 'extension this type' is the type mentioned in the on-clause of the
- /// extension declaration. For instance `B` in this extension declaration:
- ///
- /// extension A on B {
- /// B method() => this;
- /// }
- ///
- /// The 'extension this type' is the type if `this` expression in instance
- /// methods declared in extension declarations.
- TypeBuilder get extensionThisType {
- assert(_extensionThisType != null,
- "DeclarationBuilder.extensionThisType has not been set on $this.");
- return _extensionThisType!;
- }
-
@override
String toString() => '$runtimeType($name,$fileUri,$fileOffset)';
}
diff --git a/pkg/front_end/lib/src/source/builder_factory.dart b/pkg/front_end/lib/src/source/builder_factory.dart
index fc271f2..a2997dd 100644
--- a/pkg/front_end/lib/src/source/builder_factory.dart
+++ b/pkg/front_end/lib/src/source/builder_factory.dart
@@ -123,7 +123,7 @@
void beginExtensionDeclaration(String? name, int charOffset,
List<NominalParameterBuilder>? typeParameters);
- void beginExtensionBody(TypeBuilder extensionThisType);
+ void beginExtensionBody();
void endExtensionDeclaration(String? name);
diff --git a/pkg/front_end/lib/src/source/outline_builder.dart b/pkg/front_end/lib/src/source/outline_builder.dart
index 8e76559..90d2479 100644
--- a/pkg/front_end/lib/src/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/source/outline_builder.dart
@@ -1108,14 +1108,7 @@
assert(checkState(token, [
unionOfKinds([ValueKinds.ParserRecovery, ValueKinds.TypeBuilder])
]));
- Object? extensionThisType = peek();
- _builderFactory.beginExtensionBody(extensionThisType is TypeBuilder
- ? extensionThisType
- : new InvalidTypeBuilderImpl(
- uri,
- extensionThisType is ParserRecovery
- ? extensionThisType.charOffset
- : TreeNode.noOffset));
+ _builderFactory.beginExtensionBody();
break;
case DeclarationKind.ExtensionType:
declarationContext = DeclarationContext.ExtensionTypeBody;
diff --git a/pkg/front_end/lib/src/source/source_builder_factory.dart b/pkg/front_end/lib/src/source/source_builder_factory.dart
index aad1b87..1772026 100644
--- a/pkg/front_end/lib/src/source/source_builder_factory.dart
+++ b/pkg/front_end/lib/src/source/source_builder_factory.dart
@@ -354,14 +354,11 @@
}
@override
- void beginExtensionBody(TypeBuilder? extensionThisType) {
+ void beginExtensionBody() {
ExtensionFragment declarationFragment =
_declarationFragments.current as ExtensionFragment;
_typeScopes.push(new TypeScope(TypeScopeKind.extensionDeclaration,
declarationFragment.bodyScope, _typeScopes.current));
- if (extensionThisType != null) {
- declarationFragment.registerExtensionThisType(extensionThisType);
- }
}
@override