Skip to content

Commit c5a72dc

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Fix for write/read of EnumSet when compiled to JavaScript.
Change-Id: I1ab2d69649f610bbc91389ac9623a89019c9d6b2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444760 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 31005f3 commit c5a72dc

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 8.1.1-dev
2+
* Fix for `EnumSet` usage when compiled to JavaScript.
3+
14
## 8.1.0
25
* Add `DartObject.constructorInvocation` with the constructor and arguments.
36
* Make `PropertyAccessorElement.variable` non-nullable.

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ abstract class ElementImpl implements Element {
19741974
}
19751975

19761976
void readModifiers(SummaryDataReader reader) {
1977-
_modifiers = EnumSet(reader.readInt64());
1977+
_modifiers = EnumSet.read(reader);
19781978
}
19791979

19801980
/// Update [modifier] of this element to [value].
@@ -3675,7 +3675,7 @@ abstract class FragmentImpl implements Fragment {
36753675
bool hasModifier(Modifier modifier) => _modifiers[modifier];
36763676

36773677
void readModifiers(SummaryDataReader reader) {
3678-
_modifiers = EnumSet(reader.readInt64());
3678+
_modifiers = EnumSet.read(reader);
36793679
}
36803680

36813681
/// Set the code range for this element.

pkg/analyzer/lib/src/generated/utilities_collection_js.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
/// Provides [EnumSet] which works when compiled to JS.
66
library;
77

8+
import 'package:analyzer/src/summary2/data_reader.dart';
9+
import 'package:analyzer/src/summary2/data_writer.dart';
10+
811
/// The set of [Enum] values, up to `60` constants.
912
extension type EnumSet<T extends Enum>((int, int) _bits) {
1013
EnumSet.empty() : this((0, 0));
1114

15+
factory EnumSet.read(SummaryDataReader reader) {
16+
return EnumSet((reader.readInt64(), reader.readInt64()));
17+
}
18+
1219
/// Whether [constant] is present.
1320
bool operator [](T constant) {
1421
var index = constant.index;
@@ -42,6 +49,11 @@ extension type EnumSet<T extends Enum>((int, int) _bits) {
4249
}
4350
}
4451

52+
void write(BufferedSink writer) {
53+
writer.writeInt64(_bits.$1);
54+
writer.writeInt64(_bits.$2);
55+
}
56+
4557
/// Throws an exception if the [index] does not fit the storage.
4658
static void _checkIndex(int index) {
4759
if (index < 0 || index > 60) {

pkg/analyzer/lib/src/generated/utilities_collection_native.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
/// available.
77
library;
88

9+
import 'package:analyzer/src/summary2/data_reader.dart';
910
import 'package:analyzer/src/summary2/data_writer.dart';
1011

1112
/// The set of [Enum] values, backed by [int].
1213
extension type EnumSet<T extends Enum>(int _bits) {
1314
EnumSet.empty() : this(0);
1415

16+
factory EnumSet.read(SummaryDataReader reader) {
17+
return EnumSet(reader.readInt64());
18+
}
19+
1520
/// Whether [constant] is present.
1621
bool operator [](T constant) {
1722
var index = constant.index;

pkg/analyzer/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: analyzer
2-
version: 8.1.0
2+
version: 8.1.1-dev
33
description: >-
44
This package provides a library that performs static analysis of Dart code.
55
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer

0 commit comments

Comments
 (0)