Skip to content

Commit 49c5541

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Pass type parameter scope to function fragments
Change-Id: I6846737be23c5bab4f4ca78b6c0948d27afb1a96 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390880 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent 2704820 commit 49c5541

File tree

12 files changed

+64
-77
lines changed

12 files changed

+64
-77
lines changed

pkg/front_end/lib/src/fragment/constructor.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ConstructorFragment implements Fragment, FunctionFragment {
1515
final List<MetadataBuilder>? metadata;
1616
final OmittedTypeBuilder returnType;
1717
final List<NominalParameterBuilder>? typeParameters;
18+
final LookupScope typeParameterScope;
1819
final List<FormalParameterBuilder>? formals;
1920
final String? nativeMethodName;
2021
final bool forAbstractClassOrMixin;
@@ -33,6 +34,7 @@ class ConstructorFragment implements Fragment, FunctionFragment {
3334
required this.metadata,
3435
required this.returnType,
3536
required this.typeParameters,
37+
required this.typeParameterScope,
3638
required this.formals,
3739
required this.nativeMethodName,
3840
required this.forAbstractClassOrMixin,
@@ -92,8 +94,8 @@ class _ConstructorBodyBuildingContext implements FunctionBodyBuildingContext {
9294
}
9395

9496
@override
95-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
96-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
97+
LookupScope get typeParameterScope {
98+
return _fragment.typeParameterScope;
9799
}
98100

99101
@override

pkg/front_end/lib/src/fragment/factory.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class FactoryFragment implements Fragment, FunctionFragment {
1515
final List<MetadataBuilder>? metadata;
1616
final TypeBuilder returnType;
1717
final List<NominalParameterBuilder>? typeParameters;
18+
final LookupScope typeParameterScope;
1819
final List<FormalParameterBuilder>? formals;
1920
final AsyncMarker asyncModifier;
2021
final String? nativeMethodName;
@@ -33,6 +34,7 @@ class FactoryFragment implements Fragment, FunctionFragment {
3334
required this.metadata,
3435
required this.returnType,
3536
required this.typeParameters,
37+
required this.typeParameterScope,
3638
required this.formals,
3739
required this.asyncModifier,
3840
required this.nativeMethodName,
@@ -76,8 +78,8 @@ class _FactoryBodyBuildingContext implements FunctionBodyBuildingContext {
7678
}
7779

7880
@override
79-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
80-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
81+
LookupScope get typeParameterScope {
82+
return _fragment.typeParameterScope;
8183
}
8284

8385
@override

pkg/front_end/lib/src/fragment/function.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class FunctionBodyBuildingContext {
2323
required bool inMetadata,
2424
required bool inConstFields});
2525

26-
LookupScope computeTypeParameterScope(LookupScope enclosingScope);
26+
LookupScope get typeParameterScope;
2727

2828
LocalScope computeFormalParameterScope(LookupScope typeParameterScope);
2929

pkg/front_end/lib/src/fragment/getter.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class GetterFragment implements Fragment, FunctionFragment {
1616
final Modifiers modifiers;
1717
final TypeBuilder returnType;
1818
final List<NominalParameterBuilder>? typeParameters;
19+
final LookupScope typeParameterScope;
1920
final List<FormalParameterBuilder>? formals;
2021
final AsyncMarker asyncModifier;
2122
final String? nativeMethodName;
@@ -34,6 +35,7 @@ class GetterFragment implements Fragment, FunctionFragment {
3435
required this.modifiers,
3536
required this.returnType,
3637
required this.typeParameters,
38+
required this.typeParameterScope,
3739
required this.formals,
3840
required this.asyncModifier,
3941
required this.nativeMethodName});
@@ -79,8 +81,8 @@ class _GetterBodyBuildingContext implements FunctionBodyBuildingContext {
7981
}
8082

8183
@override
82-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
83-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
84+
LookupScope get typeParameterScope {
85+
return _fragment.typeParameterScope;
8486
}
8587

8688
@override

pkg/front_end/lib/src/fragment/method.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class MethodFragment implements Fragment, FunctionFragment {
1616
final Modifiers modifiers;
1717
final TypeBuilder returnType;
1818
final List<NominalParameterBuilder>? typeParameters;
19+
final LookupScope typeParameterScope;
1920
final List<FormalParameterBuilder>? formals;
2021
final ProcedureKind kind;
2122
final AsyncMarker asyncModifier;
@@ -35,6 +36,7 @@ class MethodFragment implements Fragment, FunctionFragment {
3536
required this.modifiers,
3637
required this.returnType,
3738
required this.typeParameters,
39+
required this.typeParameterScope,
3840
required this.formals,
3941
required this.kind,
4042
required this.asyncModifier,
@@ -81,8 +83,8 @@ class _MethodBodyBuildingContext implements FunctionBodyBuildingContext {
8183
}
8284

8385
@override
84-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
85-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
86+
LookupScope get typeParameterScope {
87+
return _fragment.typeParameterScope;
8688
}
8789

8890
@override

pkg/front_end/lib/src/fragment/primary_constructor.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class PrimaryConstructorFragment implements Fragment, FunctionFragment {
1313
final Modifiers modifiers;
1414
final OmittedTypeBuilder returnType;
1515
final List<NominalParameterBuilder>? typeParameters;
16+
final LookupScope typeParameterScope;
1617
final List<FormalParameterBuilder>? formals;
1718
final bool forAbstractClassOrMixin;
1819
Token? _beginInitializers;
@@ -28,6 +29,7 @@ class PrimaryConstructorFragment implements Fragment, FunctionFragment {
2829
required this.modifiers,
2930
required this.returnType,
3031
required this.typeParameters,
32+
required this.typeParameterScope,
3133
required this.formals,
3234
required this.forAbstractClassOrMixin,
3335
required Token? beginInitializers})
@@ -84,8 +86,8 @@ class _PrimaryConstructorBodyBuildingContext
8486
}
8587

8688
@override
87-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
88-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
89+
LookupScope get typeParameterScope {
90+
return _fragment.typeParameterScope;
8991
}
9092

9193
@override

pkg/front_end/lib/src/fragment/setter.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class SetterFragment implements Fragment, FunctionFragment {
1616
final Modifiers modifiers;
1717
final TypeBuilder returnType;
1818
final List<NominalParameterBuilder>? typeParameters;
19+
final LookupScope typeParameterScope;
1920
final List<FormalParameterBuilder>? formals;
2021
final AsyncMarker asyncModifier;
2122
final String? nativeMethodName;
@@ -34,6 +35,7 @@ class SetterFragment implements Fragment, FunctionFragment {
3435
required this.modifiers,
3536
required this.returnType,
3637
required this.typeParameters,
38+
required this.typeParameterScope,
3739
required this.formals,
3840
required this.asyncModifier,
3941
required this.nativeMethodName});
@@ -79,8 +81,8 @@ class _SetterBodyBuildingContext implements FunctionBodyBuildingContext {
7981
}
8082

8183
@override
82-
LookupScope computeTypeParameterScope(LookupScope enclosingScope) {
83-
return _fragment.builder.computeTypeParameterScope(enclosingScope);
84+
LookupScope get typeParameterScope {
85+
return _fragment.typeParameterScope;
8486
}
8587

8688
@override

pkg/front_end/lib/src/source/builder_factory.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ abstract class BuilderFactory {
137137

138138
void beginFactoryMethod();
139139

140-
void endFactoryMethod();
141-
142140
void endFactoryMethodForParserRecovery();
143141

144142
void beginFunctionType();
@@ -147,29 +145,21 @@ abstract class BuilderFactory {
147145

148146
void beginConstructor();
149147

150-
void endConstructor();
151-
152148
void endConstructorForParserRecovery(
153149
List<NominalParameterBuilder>? typeParameters);
154150

155151
void beginStaticMethod();
156152

157-
void endStaticMethod();
158-
159153
void endStaticMethodForParserRecovery(
160154
List<NominalParameterBuilder>? typeParameters);
161155

162156
void beginInstanceMethod();
163157

164-
void endInstanceMethod();
165-
166158
void endInstanceMethodForParserRecovery(
167159
List<NominalParameterBuilder>? typeParameters);
168160

169161
void beginTopLevelMethod();
170162

171-
void endTopLevelMethod();
172-
173163
void endTopLevelMethodForParserRecovery(
174164
List<NominalParameterBuilder>? typeParameters);
175165

pkg/front_end/lib/src/source/diet_listener.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ class DietListener extends StackListenerImpl {
904904
required bool inMetadata,
905905
required bool inConstFields}) {
906906
final LookupScope typeParameterScope =
907-
functionBodyBuildingContext.computeTypeParameterScope(memberScope);
907+
functionBodyBuildingContext.typeParameterScope;
908908
final LocalScope formalParameterScope = functionBodyBuildingContext
909909
.computeFormalParameterScope(typeParameterScope);
910910
return createListener(

pkg/front_end/lib/src/source/outline_builder.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,6 @@ class OutlineBuilder extends StackListenerImpl {
17501750
List<MetadataBuilder>? metadata = pop() as List<MetadataBuilder>?;
17511751
checkEmpty(beginToken.charOffset);
17521752
if (identifier is Identifier) {
1753-
_builderFactory.endTopLevelMethod();
17541753
final int startOffset = metadata?.first.atOffset ?? beginToken.charOffset;
17551754
int nameOffset = identifier.nameOffset;
17561755
int endOffset = endToken.charOffset;

0 commit comments

Comments
 (0)