From bd7ef48815e75de934206beb9d98fe3f47001088 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Wed, 22 May 2024 14:27:51 +0000 Subject: [PATCH] Change SharedRecordType abstract getters to return lists. Previously these abstract getters were typed as returning iterables. Although in principle, changing the return types to lists constrains the implementations more, in practice it makes no difference because the only implementations are in the CFE, analzyer, and the mini_types shared tests, and those implementations already return lists anyhow. Changing the abstact getters to return lists will simplify future work by allowing code that interacts with the base SharedRecordType class to index into the lists rather than having to iterate through them. Change-Id: Ia257400dbb7c89aabc468be15a939e6baa36e191 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367500 Commit-Queue: Paul Berry Reviewed-by: Chloe Stefantsova Reviewed-by: Konstantin Shcheglov --- pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart | 4 ++-- pkg/analyzer/lib/src/dart/element/type.dart | 2 +- pkg/kernel/lib/ast.dart | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart b/pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart index 23b42704120..fc8be8f77ae 100644 --- a/pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart +++ b/pkg/_fe_analyzer_shared/lib/src/types/shared_type.dart @@ -24,9 +24,9 @@ abstract interface class SharedNamedType { /// represent a record type. abstract interface class SharedRecordType implements SharedType { - Iterable> get namedTypes; + List> get namedTypes; - Iterable get positionalTypes; + List get positionalTypes; } /// Common interface for data structures used by the implementations to diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 0c3185753f3..041a2eefff2 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -1131,7 +1131,7 @@ class RecordTypeImpl extends TypeImpl implements RecordType { String? get name => null; @override - Iterable> get namedTypes => namedFields; + List> get namedTypes => namedFields; @override bool operator ==(Object other) { diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index 78909f92d7b..4a7c0f6e569 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart @@ -12871,7 +12871,7 @@ class RecordType extends DartType implements SharedRecordType { "in a RecordType: ${named}"); @override - Iterable> get namedTypes => named; + List> get namedTypes => named; @override Nullability get nullability => declaredNullability; @@ -12888,7 +12888,7 @@ class RecordType extends DartType implements SharedRecordType { }; @override - Iterable get positionalTypes => positional; + List get positionalTypes => positional; @override R accept(DartTypeVisitor v) {