Skip to content

Commit 7d62bdd

Browse files
stereotype441Commit Queue
authored andcommitted
[_fe_analyzer_shared] Sort declarations in mini_ast.dart and shared_type.dart.
There is no functional change. Change-Id: I1877d29efddd614688cd34506d5a496a472dea7e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414260 Reviewed-by: Johnni Winther <[email protected]> Auto-Submit: Paul Berry <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent a408293 commit 7d62bdd

File tree

2 files changed

+96
-96
lines changed

2 files changed

+96
-96
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,6 @@ abstract interface class SharedRecordType implements SharedType {
7070
List<SharedNamedType> get sortedNamedTypesShared;
7171
}
7272

73-
/// Common interface for data structures used by the implementations to
74-
/// represent a generic type parameter.
75-
abstract interface class SharedTypeParameter {
76-
/// The bound of the type parameter.
77-
SharedType? get boundShared;
78-
79-
/// The name of the type parameter, for display to the user.
80-
String get displayName;
81-
}
82-
8373
/// Common interface for data structures used by the implementations to
8474
/// represent a type.
8575
abstract interface class SharedType {
@@ -97,6 +87,16 @@ abstract interface class SharedType {
9787
bool isStructurallyEqualTo(covariant SharedType other);
9888
}
9989

90+
/// Common interface for data structures used by the implementations to
91+
/// represent a generic type parameter.
92+
abstract interface class SharedTypeParameter {
93+
/// The bound of the type parameter.
94+
SharedType? get boundShared;
95+
96+
/// The name of the type parameter, for display to the user.
97+
String get displayName;
98+
}
99+
100100
/// Common interface for data structures used by the implementations to
101101
/// represent the unknown type schema (`_`).
102102
///
@@ -154,6 +154,13 @@ extension type SharedRecordTypeView(SharedRecordType _typeStructure)
154154
}
155155
}
156156

157+
extension type SharedTypeParameterView(SharedTypeParameter _typeParameter)
158+
implements Object {
159+
TypeParameter unwrapTypeParameterViewAsTypeParameterStructure<
160+
TypeParameter extends SharedTypeParameter>() =>
161+
_typeParameter as TypeParameter;
162+
}
163+
157164
extension type SharedTypeSchemaView(SharedType _typeStructure)
158165
implements Object {
159166
NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;
@@ -179,13 +186,6 @@ extension type SharedTypeView(SharedType _typeStructure) implements Object {
179186
_typeStructure as TypeStructure;
180187
}
181188

182-
extension type SharedTypeParameterView(SharedTypeParameter _typeParameter)
183-
implements Object {
184-
TypeParameter unwrapTypeParameterViewAsTypeParameterStructure<
185-
TypeParameter extends SharedTypeParameter>() =>
186-
_typeParameter as TypeParameter;
187-
}
188-
189189
/// Note that there is no `SharedUnknownTypeView`, only
190190
/// [SharedUnknownTypeSchemaView], since we want to restrict
191191
/// [SharedUnknownType] from appearing in type views and

pkg/_fe_analyzer_shared/test/mini_ast.dart

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer.dart'
2828
as shared;
2929
import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer.dart'
3030
hide MapPatternEntry, RecordPatternField;
31-
import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart';
3231
import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.dart';
32+
import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart';
3333
import 'package:_fe_analyzer_shared/src/type_inference/variable_bindings.dart';
3434
import 'package:_fe_analyzer_shared/src/types/shared_type.dart';
3535
import 'package:test/test.dart';
@@ -1241,6 +1241,46 @@ class Do extends Statement {
12411241
}
12421242
}
12431243

1244+
// Represents the entire dot shorthand expression.
1245+
// e.g. `.current.errorZone`
1246+
class DotShorthand extends Expression {
1247+
final Expression expr;
1248+
1249+
DotShorthand._(this.expr, {required super.location});
1250+
1251+
@override
1252+
void preVisit(PreVisitor visitor) {
1253+
expr.preVisit(visitor);
1254+
}
1255+
1256+
@override
1257+
String toString() => '$expr';
1258+
1259+
@override
1260+
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
1261+
return h.typeAnalyzer.analyzeDotShorthandExpression(expr, schema);
1262+
}
1263+
}
1264+
1265+
// Represents the head of a dot shorthand.
1266+
// e.g. `.zero`
1267+
class DotShorthandHead extends Expression {
1268+
final String name;
1269+
1270+
DotShorthandHead._(this.name, {required super.location});
1271+
1272+
@override
1273+
void preVisit(PreVisitor visitor) {}
1274+
1275+
@override
1276+
String toString() => '.$name';
1277+
1278+
@override
1279+
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
1280+
return h.typeAnalyzer.analyzeDotShorthandHeadExpression(this, name, schema);
1281+
}
1282+
}
1283+
12441284
class Equal extends Expression {
12451285
final Expression lhs;
12461286
final Expression rhs;
@@ -2732,6 +2772,23 @@ class MiniAstOperations
27322772
}
27332773
}
27342774

2775+
@override
2776+
TypeConstraintGenerator<Var, Type, String, Node>
2777+
createTypeConstraintGenerator(
2778+
{required TypeConstraintGenerationDataForTesting?
2779+
typeConstraintGenerationDataForTesting,
2780+
required List<SharedTypeParameterView> typeParametersToInfer,
2781+
required TypeAnalyzerOperations<Var, Type, String>
2782+
typeAnalyzerOperations,
2783+
required bool inferenceUsingBoundsIsEnabled}) {
2784+
return TypeConstraintGatherer({
2785+
for (var typeParameter in typeParametersToInfer)
2786+
typeParameter
2787+
.unwrapTypeParameterViewAsTypeParameterStructure<TypeParameter>()
2788+
.name
2789+
});
2790+
}
2791+
27352792
/// Returns the downward inference result of a type with the given [name],
27362793
/// in the [context]. For example infer `List<int>` from `Iterable<int>`.
27372794
Type downwardInfer(String name, Type context) {
@@ -3181,23 +3238,6 @@ class MiniAstOperations
31813238
Type withNullabilitySuffixInternal(Type type, NullabilitySuffix modifier) {
31823239
return type.withNullability(modifier);
31833240
}
3184-
3185-
@override
3186-
TypeConstraintGenerator<Var, Type, String, Node>
3187-
createTypeConstraintGenerator(
3188-
{required TypeConstraintGenerationDataForTesting?
3189-
typeConstraintGenerationDataForTesting,
3190-
required List<SharedTypeParameterView> typeParametersToInfer,
3191-
required TypeAnalyzerOperations<Var, Type, String>
3192-
typeAnalyzerOperations,
3193-
required bool inferenceUsingBoundsIsEnabled}) {
3194-
return TypeConstraintGatherer({
3195-
for (var typeParameter in typeParametersToInfer)
3196-
typeParameter
3197-
.unwrapTypeParameterViewAsTypeParameterStructure<TypeParameter>()
3198-
.name
3199-
});
3200-
}
32013241
}
32023242

32033243
/// Representation of an expression or statement in the pseudo-Dart language
@@ -3386,46 +3426,6 @@ class ObjectPattern extends Pattern {
33863426
}
33873427
}
33883428

3389-
// Represents the head of a dot shorthand.
3390-
// e.g. `.zero`
3391-
class DotShorthandHead extends Expression {
3392-
final String name;
3393-
3394-
DotShorthandHead._(this.name, {required super.location});
3395-
3396-
@override
3397-
void preVisit(PreVisitor visitor) {}
3398-
3399-
@override
3400-
String toString() => '.$name';
3401-
3402-
@override
3403-
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
3404-
return h.typeAnalyzer.analyzeDotShorthandHeadExpression(this, name, schema);
3405-
}
3406-
}
3407-
3408-
// Represents the entire dot shorthand expression.
3409-
// e.g. `.current.errorZone`
3410-
class DotShorthand extends Expression {
3411-
final Expression expr;
3412-
3413-
DotShorthand._(this.expr, {required super.location});
3414-
3415-
@override
3416-
void preVisit(PreVisitor visitor) {
3417-
expr.preVisit(visitor);
3418-
}
3419-
3420-
@override
3421-
String toString() => '$expr';
3422-
3423-
@override
3424-
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
3425-
return h.typeAnalyzer.analyzeDotShorthandExpression(expr, schema);
3426-
}
3427-
}
3428-
34293429
class ParenthesizedExpression extends Expression {
34303430
final Expression expr;
34313431

@@ -3920,6 +3920,14 @@ mixin ProtoCollectionElement<Self extends ProtoCollectionElement<dynamic>> {
39203920
/// variable).
39213921
mixin ProtoExpression
39223922
implements ProtoStatement<Expression>, ProtoCollectionElement<Expression> {
3923+
/// If `this` is an expression `x`, creates a dot shorthand wrapper around
3924+
/// `x`.
3925+
Expression get dotShorthand {
3926+
var location = computeLocation();
3927+
return new DotShorthand._(asExpression(location: location),
3928+
location: location);
3929+
}
3930+
39233931
/// If `this` is an expression `x`, creates the expression `x!`.
39243932
Expression get nonNullAssert {
39253933
var location = computeLocation();
@@ -3933,14 +3941,6 @@ mixin ProtoExpression
39333941
return new Not._(asExpression(location: location), location: location);
39343942
}
39353943

3936-
/// If `this` is an expression `x`, creates a dot shorthand wrapper around
3937-
/// `x`.
3938-
Expression get dotShorthand {
3939-
var location = computeLocation();
3940-
return new DotShorthand._(asExpression(location: location),
3941-
location: location);
3942-
}
3943-
39443944
/// If `this` is an expression `x`, creates the expression `(x)`.
39453945
Expression get parenthesized {
39463946
var location = computeLocation();
@@ -5560,6 +5560,19 @@ class _MiniAstTypeAnalyzer
55605560
flow.doStatement_end(condition);
55615561
}
55625562

5563+
ExpressionTypeAnalysisResult analyzeDotShorthandExpression(
5564+
Expression expression, SharedTypeSchemaView schema) {
5565+
var type = analyzeDotShorthand(expression, schema);
5566+
return new ExpressionTypeAnalysisResult(type: type);
5567+
}
5568+
5569+
ExpressionTypeAnalysisResult analyzeDotShorthandHeadExpression(
5570+
Expression node, String name, SharedTypeSchemaView schema) {
5571+
_irBuilder.atom(name, Kind.expression, location: node.location);
5572+
return new ExpressionTypeAnalysisResult(
5573+
type: SharedTypeView(getDotShorthandContext().unwrapTypeSchemaView()));
5574+
}
5575+
55635576
void analyzeExpressionStatement(Expression expression) {
55645577
analyzeExpression(expression, operations.unknownType);
55655578
}
@@ -5645,19 +5658,6 @@ class _MiniAstTypeAnalyzer
56455658
return new ExpressionTypeAnalysisResult(type: SharedTypeView(nullType));
56465659
}
56475660

5648-
ExpressionTypeAnalysisResult analyzeDotShorthandHeadExpression(
5649-
Expression node, String name, SharedTypeSchemaView schema) {
5650-
_irBuilder.atom(name, Kind.expression, location: node.location);
5651-
return new ExpressionTypeAnalysisResult(
5652-
type: SharedTypeView(getDotShorthandContext().unwrapTypeSchemaView()));
5653-
}
5654-
5655-
ExpressionTypeAnalysisResult analyzeDotShorthandExpression(
5656-
Expression expression, SharedTypeSchemaView schema) {
5657-
var type = analyzeDotShorthand(expression, schema);
5658-
return new ExpressionTypeAnalysisResult(type: type);
5659-
}
5660-
56615661
ExpressionTypeAnalysisResult analyzeParenthesizedExpression(
56625662
Expression node, Expression expression, SharedTypeSchemaView schema) {
56635663
var type = analyzeExpression(expression, schema);

0 commit comments

Comments
 (0)