[_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 <johnniwinther@google.com> Auto-Submit: Paul Berry <paulberry@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
@@ -70,16 +70,6 @@ abstract interface class SharedRecordType implements SharedType {
|
||||
List<SharedNamedType> get sortedNamedTypesShared;
|
||||
}
|
||||
|
||||
/// Common interface for data structures used by the implementations to
|
||||
/// represent a generic type parameter.
|
||||
abstract interface class SharedTypeParameter {
|
||||
/// The bound of the type parameter.
|
||||
SharedType? get boundShared;
|
||||
|
||||
/// The name of the type parameter, for display to the user.
|
||||
String get displayName;
|
||||
}
|
||||
|
||||
/// Common interface for data structures used by the implementations to
|
||||
/// represent a type.
|
||||
abstract interface class SharedType {
|
||||
@@ -97,6 +87,16 @@ abstract interface class SharedType {
|
||||
bool isStructurallyEqualTo(covariant SharedType other);
|
||||
}
|
||||
|
||||
/// Common interface for data structures used by the implementations to
|
||||
/// represent a generic type parameter.
|
||||
abstract interface class SharedTypeParameter {
|
||||
/// The bound of the type parameter.
|
||||
SharedType? get boundShared;
|
||||
|
||||
/// The name of the type parameter, for display to the user.
|
||||
String get displayName;
|
||||
}
|
||||
|
||||
/// Common interface for data structures used by the implementations to
|
||||
/// represent the unknown type schema (`_`).
|
||||
///
|
||||
@@ -154,6 +154,13 @@ extension type SharedRecordTypeView(SharedRecordType _typeStructure)
|
||||
}
|
||||
}
|
||||
|
||||
extension type SharedTypeParameterView(SharedTypeParameter _typeParameter)
|
||||
implements Object {
|
||||
TypeParameter unwrapTypeParameterViewAsTypeParameterStructure<
|
||||
TypeParameter extends SharedTypeParameter>() =>
|
||||
_typeParameter as TypeParameter;
|
||||
}
|
||||
|
||||
extension type SharedTypeSchemaView(SharedType _typeStructure)
|
||||
implements Object {
|
||||
NullabilitySuffix get nullabilitySuffix => _typeStructure.nullabilitySuffix;
|
||||
@@ -179,13 +186,6 @@ extension type SharedTypeView(SharedType _typeStructure) implements Object {
|
||||
_typeStructure as TypeStructure;
|
||||
}
|
||||
|
||||
extension type SharedTypeParameterView(SharedTypeParameter _typeParameter)
|
||||
implements Object {
|
||||
TypeParameter unwrapTypeParameterViewAsTypeParameterStructure<
|
||||
TypeParameter extends SharedTypeParameter>() =>
|
||||
_typeParameter as TypeParameter;
|
||||
}
|
||||
|
||||
/// Note that there is no `SharedUnknownTypeView`, only
|
||||
/// [SharedUnknownTypeSchemaView], since we want to restrict
|
||||
/// [SharedUnknownType] from appearing in type views and
|
||||
|
||||
@@ -28,8 +28,8 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer.dart'
|
||||
as shared;
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer.dart'
|
||||
hide MapPatternEntry, RecordPatternField;
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart';
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.dart';
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart';
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/variable_bindings.dart';
|
||||
import 'package:_fe_analyzer_shared/src/types/shared_type.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -1241,6 +1241,46 @@ class Do extends Statement {
|
||||
}
|
||||
}
|
||||
|
||||
// Represents the entire dot shorthand expression.
|
||||
// e.g. `.current.errorZone`
|
||||
class DotShorthand extends Expression {
|
||||
final Expression expr;
|
||||
|
||||
DotShorthand._(this.expr, {required super.location});
|
||||
|
||||
@override
|
||||
void preVisit(PreVisitor visitor) {
|
||||
expr.preVisit(visitor);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '$expr';
|
||||
|
||||
@override
|
||||
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
|
||||
return h.typeAnalyzer.analyzeDotShorthandExpression(expr, schema);
|
||||
}
|
||||
}
|
||||
|
||||
// Represents the head of a dot shorthand.
|
||||
// e.g. `.zero`
|
||||
class DotShorthandHead extends Expression {
|
||||
final String name;
|
||||
|
||||
DotShorthandHead._(this.name, {required super.location});
|
||||
|
||||
@override
|
||||
void preVisit(PreVisitor visitor) {}
|
||||
|
||||
@override
|
||||
String toString() => '.$name';
|
||||
|
||||
@override
|
||||
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
|
||||
return h.typeAnalyzer.analyzeDotShorthandHeadExpression(this, name, schema);
|
||||
}
|
||||
}
|
||||
|
||||
class Equal extends Expression {
|
||||
final Expression lhs;
|
||||
final Expression rhs;
|
||||
@@ -2732,6 +2772,23 @@ class MiniAstOperations
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
TypeConstraintGenerator<Var, Type, String, Node>
|
||||
createTypeConstraintGenerator(
|
||||
{required TypeConstraintGenerationDataForTesting?
|
||||
typeConstraintGenerationDataForTesting,
|
||||
required List<SharedTypeParameterView> typeParametersToInfer,
|
||||
required TypeAnalyzerOperations<Var, Type, String>
|
||||
typeAnalyzerOperations,
|
||||
required bool inferenceUsingBoundsIsEnabled}) {
|
||||
return TypeConstraintGatherer({
|
||||
for (var typeParameter in typeParametersToInfer)
|
||||
typeParameter
|
||||
.unwrapTypeParameterViewAsTypeParameterStructure<TypeParameter>()
|
||||
.name
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the downward inference result of a type with the given [name],
|
||||
/// in the [context]. For example infer `List<int>` from `Iterable<int>`.
|
||||
Type downwardInfer(String name, Type context) {
|
||||
@@ -3181,23 +3238,6 @@ class MiniAstOperations
|
||||
Type withNullabilitySuffixInternal(Type type, NullabilitySuffix modifier) {
|
||||
return type.withNullability(modifier);
|
||||
}
|
||||
|
||||
@override
|
||||
TypeConstraintGenerator<Var, Type, String, Node>
|
||||
createTypeConstraintGenerator(
|
||||
{required TypeConstraintGenerationDataForTesting?
|
||||
typeConstraintGenerationDataForTesting,
|
||||
required List<SharedTypeParameterView> typeParametersToInfer,
|
||||
required TypeAnalyzerOperations<Var, Type, String>
|
||||
typeAnalyzerOperations,
|
||||
required bool inferenceUsingBoundsIsEnabled}) {
|
||||
return TypeConstraintGatherer({
|
||||
for (var typeParameter in typeParametersToInfer)
|
||||
typeParameter
|
||||
.unwrapTypeParameterViewAsTypeParameterStructure<TypeParameter>()
|
||||
.name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Representation of an expression or statement in the pseudo-Dart language
|
||||
@@ -3386,46 +3426,6 @@ class ObjectPattern extends Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
// Represents the head of a dot shorthand.
|
||||
// e.g. `.zero`
|
||||
class DotShorthandHead extends Expression {
|
||||
final String name;
|
||||
|
||||
DotShorthandHead._(this.name, {required super.location});
|
||||
|
||||
@override
|
||||
void preVisit(PreVisitor visitor) {}
|
||||
|
||||
@override
|
||||
String toString() => '.$name';
|
||||
|
||||
@override
|
||||
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
|
||||
return h.typeAnalyzer.analyzeDotShorthandHeadExpression(this, name, schema);
|
||||
}
|
||||
}
|
||||
|
||||
// Represents the entire dot shorthand expression.
|
||||
// e.g. `.current.errorZone`
|
||||
class DotShorthand extends Expression {
|
||||
final Expression expr;
|
||||
|
||||
DotShorthand._(this.expr, {required super.location});
|
||||
|
||||
@override
|
||||
void preVisit(PreVisitor visitor) {
|
||||
expr.preVisit(visitor);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '$expr';
|
||||
|
||||
@override
|
||||
ExpressionTypeAnalysisResult visit(Harness h, SharedTypeSchemaView schema) {
|
||||
return h.typeAnalyzer.analyzeDotShorthandExpression(expr, schema);
|
||||
}
|
||||
}
|
||||
|
||||
class ParenthesizedExpression extends Expression {
|
||||
final Expression expr;
|
||||
|
||||
@@ -3920,6 +3920,14 @@ mixin ProtoCollectionElement<Self extends ProtoCollectionElement<dynamic>> {
|
||||
/// variable).
|
||||
mixin ProtoExpression
|
||||
implements ProtoStatement<Expression>, ProtoCollectionElement<Expression> {
|
||||
/// If `this` is an expression `x`, creates a dot shorthand wrapper around
|
||||
/// `x`.
|
||||
Expression get dotShorthand {
|
||||
var location = computeLocation();
|
||||
return new DotShorthand._(asExpression(location: location),
|
||||
location: location);
|
||||
}
|
||||
|
||||
/// If `this` is an expression `x`, creates the expression `x!`.
|
||||
Expression get nonNullAssert {
|
||||
var location = computeLocation();
|
||||
@@ -3933,14 +3941,6 @@ mixin ProtoExpression
|
||||
return new Not._(asExpression(location: location), location: location);
|
||||
}
|
||||
|
||||
/// If `this` is an expression `x`, creates a dot shorthand wrapper around
|
||||
/// `x`.
|
||||
Expression get dotShorthand {
|
||||
var location = computeLocation();
|
||||
return new DotShorthand._(asExpression(location: location),
|
||||
location: location);
|
||||
}
|
||||
|
||||
/// If `this` is an expression `x`, creates the expression `(x)`.
|
||||
Expression get parenthesized {
|
||||
var location = computeLocation();
|
||||
@@ -5560,6 +5560,19 @@ class _MiniAstTypeAnalyzer
|
||||
flow.doStatement_end(condition);
|
||||
}
|
||||
|
||||
ExpressionTypeAnalysisResult analyzeDotShorthandExpression(
|
||||
Expression expression, SharedTypeSchemaView schema) {
|
||||
var type = analyzeDotShorthand(expression, schema);
|
||||
return new ExpressionTypeAnalysisResult(type: type);
|
||||
}
|
||||
|
||||
ExpressionTypeAnalysisResult analyzeDotShorthandHeadExpression(
|
||||
Expression node, String name, SharedTypeSchemaView schema) {
|
||||
_irBuilder.atom(name, Kind.expression, location: node.location);
|
||||
return new ExpressionTypeAnalysisResult(
|
||||
type: SharedTypeView(getDotShorthandContext().unwrapTypeSchemaView()));
|
||||
}
|
||||
|
||||
void analyzeExpressionStatement(Expression expression) {
|
||||
analyzeExpression(expression, operations.unknownType);
|
||||
}
|
||||
@@ -5645,19 +5658,6 @@ class _MiniAstTypeAnalyzer
|
||||
return new ExpressionTypeAnalysisResult(type: SharedTypeView(nullType));
|
||||
}
|
||||
|
||||
ExpressionTypeAnalysisResult analyzeDotShorthandHeadExpression(
|
||||
Expression node, String name, SharedTypeSchemaView schema) {
|
||||
_irBuilder.atom(name, Kind.expression, location: node.location);
|
||||
return new ExpressionTypeAnalysisResult(
|
||||
type: SharedTypeView(getDotShorthandContext().unwrapTypeSchemaView()));
|
||||
}
|
||||
|
||||
ExpressionTypeAnalysisResult analyzeDotShorthandExpression(
|
||||
Expression expression, SharedTypeSchemaView schema) {
|
||||
var type = analyzeDotShorthand(expression, schema);
|
||||
return new ExpressionTypeAnalysisResult(type: type);
|
||||
}
|
||||
|
||||
ExpressionTypeAnalysisResult analyzeParenthesizedExpression(
|
||||
Expression node, Expression expression, SharedTypeSchemaView schema) {
|
||||
var type = analyzeExpression(expression, schema);
|
||||
|
||||
Reference in New Issue
Block a user