Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 90d5fdb

Browse files
author
Dart CI
committed
Version 2.18.0-142.0.dev
Merge commit 'd10f740398c6ee512aaad1ca06b38319a216b7c5' into 'dev'
2 parents 291a018 + d10f740 commit 90d5fdb

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed

pkg/compiler/lib/src/js_backend/annotations.dart

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.10
6-
75
library js_backend.backend.annotations;
86

97
import 'package:kernel/ast.dart' as ir;
@@ -14,7 +12,7 @@ import '../ir/annotations.dart';
1412
import '../ir/util.dart';
1513
import '../kernel/dart2js_target.dart';
1614
import '../options.dart';
17-
import '../serialization/serialization.dart';
15+
import '../serialization/serialization_interfaces.dart';
1816
import '../util/enumset.dart';
1917

2018
class PragmaAnnotation {
@@ -213,7 +211,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
213211
Map<PragmaAnnotation, EnumSet<PragmaAnnotation>> reportedExclusions = {};
214212
for (PragmaAnnotation annotation
215213
in annotations.iterable(PragmaAnnotation.values)) {
216-
Set<PragmaAnnotation> implies = PragmaAnnotation.implies[annotation];
214+
Set<PragmaAnnotation>? implies = PragmaAnnotation.implies[annotation];
217215
if (implies != null) {
218216
for (PragmaAnnotation other in implies) {
219217
if (annotations.contains(other)) {
@@ -225,7 +223,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
225223
}
226224
}
227225
}
228-
Set<PragmaAnnotation> excludes = PragmaAnnotation.excludes[annotation];
226+
Set<PragmaAnnotation>? excludes = PragmaAnnotation.excludes[annotation];
229227
if (excludes != null) {
230228
for (PragmaAnnotation other in excludes) {
231229
if (annotations.contains(other) &&
@@ -239,7 +237,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
239237
}
240238
}
241239
}
242-
Set<PragmaAnnotation> requires = PragmaAnnotation.requires[annotation];
240+
Set<PragmaAnnotation>? requires = PragmaAnnotation.requires[annotation];
243241
if (requires != null) {
244242
for (PragmaAnnotation other in requires) {
245243
if (!annotations.contains(other)) {
@@ -309,30 +307,30 @@ abstract class AnnotationsData {
309307
/// What should the compiler do with parameter type assertions in [member].
310308
///
311309
/// If [member] is `null`, the default policy is returned.
312-
CheckPolicy getParameterCheckPolicy(MemberEntity member);
310+
CheckPolicy getParameterCheckPolicy(MemberEntity? member);
313311

314312
/// What should the compiler do with implicit downcasts in [member].
315313
///
316314
/// If [member] is `null`, the default policy is returned.
317-
CheckPolicy getImplicitDowncastCheckPolicy(MemberEntity member);
315+
CheckPolicy getImplicitDowncastCheckPolicy(MemberEntity? member);
318316

319317
/// What the compiler should do with a boolean value in a condition context
320318
/// in [member] when the language specification says it is a runtime error for
321319
/// it to be null.
322320
///
323321
/// If [member] is `null`, the default policy is returned.
324-
CheckPolicy getConditionCheckPolicy(MemberEntity member);
322+
CheckPolicy getConditionCheckPolicy(MemberEntity? member);
325323

326324
/// Whether should the compiler do with explicit casts in [member].
327325
///
328326
/// If [member] is `null`, the default policy is returned.
329-
CheckPolicy getExplicitCastCheckPolicy(MemberEntity member);
327+
CheckPolicy getExplicitCastCheckPolicy(MemberEntity? member);
330328

331329
/// What should the compiler do with index bounds checks `[]`, `[]=` and
332330
/// `removeLast()` operations in the body of [member].
333331
///
334332
/// If [member] is `null`, the default policy is returned.
335-
CheckPolicy getIndexBoundsCheckPolicy(MemberEntity member);
333+
CheckPolicy getIndexBoundsCheckPolicy(MemberEntity? member);
336334
}
337335

338336
class AnnotationsDataImpl implements AnnotationsData {
@@ -378,7 +376,7 @@ class AnnotationsDataImpl implements AnnotationsData {
378376
}
379377

380378
bool _hasPragma(MemberEntity member, PragmaAnnotation annotation) {
381-
EnumSet<PragmaAnnotation> set = pragmaAnnotations[member];
379+
EnumSet<PragmaAnnotation>? set = pragmaAnnotations[member];
382380
return set != null && set.contains(annotation);
383381
}
384382

@@ -415,7 +413,7 @@ class AnnotationsDataImpl implements AnnotationsData {
415413
pragmaAnnotations
416414
.forEach((MemberEntity member, EnumSet<PragmaAnnotation> set) {
417415
if (set.contains(PragmaAnnotation.noInline)) {
418-
f(member);
416+
f(member as FunctionEntity);
419417
}
420418
});
421419
}
@@ -425,7 +423,7 @@ class AnnotationsDataImpl implements AnnotationsData {
425423
pragmaAnnotations
426424
.forEach((MemberEntity member, EnumSet<PragmaAnnotation> set) {
427425
if (set.contains(PragmaAnnotation.tryInline)) {
428-
f(member);
426+
f(member as FunctionEntity);
429427
}
430428
});
431429
}
@@ -435,7 +433,7 @@ class AnnotationsDataImpl implements AnnotationsData {
435433
pragmaAnnotations
436434
.forEach((MemberEntity member, EnumSet<PragmaAnnotation> set) {
437435
if (set.contains(PragmaAnnotation.noThrows)) {
438-
f(member);
436+
f(member as FunctionEntity);
439437
}
440438
});
441439
}
@@ -445,15 +443,15 @@ class AnnotationsDataImpl implements AnnotationsData {
445443
pragmaAnnotations
446444
.forEach((MemberEntity member, EnumSet<PragmaAnnotation> set) {
447445
if (set.contains(PragmaAnnotation.noSideEffects)) {
448-
f(member);
446+
f(member as FunctionEntity);
449447
}
450448
});
451449
}
452450

453451
@override
454-
CheckPolicy getParameterCheckPolicy(MemberEntity member) {
452+
CheckPolicy getParameterCheckPolicy(MemberEntity? member) {
455453
if (member != null) {
456-
EnumSet<PragmaAnnotation> annotations = pragmaAnnotations[member];
454+
EnumSet<PragmaAnnotation>? annotations = pragmaAnnotations[member];
457455
if (annotations != null) {
458456
if (annotations.contains(PragmaAnnotation.typesTrust)) {
459457
return CheckPolicy.trusted;
@@ -470,9 +468,9 @@ class AnnotationsDataImpl implements AnnotationsData {
470468
}
471469

472470
@override
473-
CheckPolicy getImplicitDowncastCheckPolicy(MemberEntity member) {
471+
CheckPolicy getImplicitDowncastCheckPolicy(MemberEntity? member) {
474472
if (member != null) {
475-
EnumSet<PragmaAnnotation> annotations = pragmaAnnotations[member];
473+
EnumSet<PragmaAnnotation>? annotations = pragmaAnnotations[member];
476474
if (annotations != null) {
477475
if (annotations.contains(PragmaAnnotation.typesTrust)) {
478476
return CheckPolicy.trusted;
@@ -489,9 +487,9 @@ class AnnotationsDataImpl implements AnnotationsData {
489487
}
490488

491489
@override
492-
CheckPolicy getConditionCheckPolicy(MemberEntity member) {
490+
CheckPolicy getConditionCheckPolicy(MemberEntity? member) {
493491
if (member != null) {
494-
EnumSet<PragmaAnnotation> annotations = pragmaAnnotations[member];
492+
EnumSet<PragmaAnnotation>? annotations = pragmaAnnotations[member];
495493
if (annotations != null) {
496494
if (annotations.contains(PragmaAnnotation.typesTrust)) {
497495
return CheckPolicy.trusted;
@@ -508,9 +506,9 @@ class AnnotationsDataImpl implements AnnotationsData {
508506
}
509507

510508
@override
511-
CheckPolicy getExplicitCastCheckPolicy(MemberEntity member) {
509+
CheckPolicy getExplicitCastCheckPolicy(MemberEntity? member) {
512510
if (member != null) {
513-
EnumSet<PragmaAnnotation> annotations = pragmaAnnotations[member];
511+
EnumSet<PragmaAnnotation>? annotations = pragmaAnnotations[member];
514512
if (annotations != null) {
515513
if (annotations.contains(PragmaAnnotation.asTrust)) {
516514
return CheckPolicy.trusted;
@@ -523,9 +521,9 @@ class AnnotationsDataImpl implements AnnotationsData {
523521
}
524522

525523
@override
526-
CheckPolicy getIndexBoundsCheckPolicy(MemberEntity member) {
524+
CheckPolicy getIndexBoundsCheckPolicy(MemberEntity? member) {
527525
if (member != null) {
528-
EnumSet<PragmaAnnotation> annotations = pragmaAnnotations[member];
526+
EnumSet<PragmaAnnotation>? annotations = pragmaAnnotations[member];
529527
if (annotations != null) {
530528
if (annotations.contains(PragmaAnnotation.indexBoundsTrust)) {
531529
return CheckPolicy.trusted;

pkg/compiler/lib/src/serialization/serialization_interfaces.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ abstract class DataSinkWriter {
6161
void writeTypeVariable(
6262
covariant TypeVariableEntity value); // IndexedTypeVariable
6363

64+
void writeMemberMap<V>(
65+
Map<MemberEntity, V>? map, void f(MemberEntity member, V value),
66+
{bool allowNull = false});
67+
6468
void writeLibrary(covariant LibraryEntity value); // IndexedLibrary
6569
void writeLibraryOrNull(covariant LibraryEntity? value); // IndexedLibrary
6670

@@ -101,6 +105,10 @@ abstract class DataSourceReader {
101105
ClassEntity? readClassOrNull(); // IndexedClass
102106
TypeVariableEntity readTypeVariable(); // IndexedTypeVariable
103107

108+
Map<K, V> readMemberMap<K extends MemberEntity, V>(V f(MemberEntity member));
109+
Map<K, V>? readMemberMapOrNull<K extends MemberEntity, V>(
110+
V f(MemberEntity member));
111+
104112
LibraryEntity readLibrary(); // IndexedLibrary;
105113
LibraryEntity? readLibraryOrNull(); // IndexedLibrary;
106114

pkg/compiler/lib/src/serialization/sink.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ class DataSinkWriter implements migrated.DataSinkWriter {
810810
///
811811
/// This is a convenience method to be used together with
812812
/// [DataSourceReader.readMemberMap].
813+
@override
813814
void writeMemberMap<V>(
814815
Map<MemberEntity, V> map, void f(MemberEntity member, V value),
815816
{bool allowNull = false}) {

pkg/compiler/lib/src/serialization/source.dart

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -975,15 +975,26 @@ class DataSourceReader implements migrated.DataSourceReader {
975975
}
976976

977977
/// Reads a map from indexed members to [V] values from this data source,
978-
/// calling [f] to read each value from the data source. If [emptyAsNull] is
979-
/// `true`, `null` is returned instead of an empty map.
978+
/// calling [f] to read each value from the data source.
980979
///
981980
/// This is a convenience method to be used together with
982981
/// [DataSinkWriter.writeMemberMap].
983-
Map<K, V> readMemberMap<K extends MemberEntity, V>(V f(MemberEntity member),
984-
{bool emptyAsNull = false}) {
982+
@override
983+
Map<K, V> readMemberMap<K extends MemberEntity, V>(V f(MemberEntity member)) {
984+
return readMemberMapOrNull<K, V>(f) ?? {};
985+
}
986+
987+
/// Reads a map from indexed members to [V] values from this data source,
988+
/// calling [f] to read each value from the data source.
989+
/// `null` is returned instead of an empty map.
990+
///
991+
/// This is a convenience method to be used together with
992+
/// [DataSinkWriter.writeMemberMap].
993+
@override
994+
Map<K, V> readMemberMapOrNull<K extends MemberEntity, V>(
995+
V f(MemberEntity member)) {
985996
int count = readInt();
986-
if (count == 0 && emptyAsNull) return null;
997+
if (count == 0) return null;
987998
Map<K, V> map = {};
988999
for (int i = 0; i < count; i++) {
9891000
MemberEntity member = readMember();

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 18
2929
PATCH 0
30-
PRERELEASE 141
30+
PRERELEASE 142
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)