2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // @dart = 2.10
6
-
7
5
import '../../common/elements.dart' show CommonElements;
8
6
import '../../constants/values.dart' ;
9
7
import '../../elements/entities.dart' ;
10
8
import '../../elements/names.dart' ;
11
9
import '../../elements/types.dart' ;
12
10
import '../../ir/class_relation.dart' ;
13
11
import '../../universe/selector.dart' ;
14
- import '../../world .dart' ;
12
+ import '../../world_interfaces .dart' ;
15
13
import '../abstract_value_domain.dart' ;
16
14
17
15
/// This class is used to store bits information about class entities.
@@ -172,7 +170,7 @@ class PowersetBitsDomain {
172
170
173
171
// TODO(coam): This currently returns null if we are not sure if it's a primitive.
174
172
// It could be improved because we can also tell when we're certain it's not a primitive.
175
- PrimitiveConstantValue getPrimitiveValue (int value) {
173
+ PrimitiveConstantValue ? getPrimitiveValue (int value) {
176
174
if (isDefinitelyTrue (value)) {
177
175
return TrueConstantValue ();
178
176
}
@@ -355,7 +353,7 @@ class PowersetBitsDomain {
355
353
}
356
354
357
355
ClassInfo _computeClassInfo (ClassEntity cls) {
358
- ClassInfo classInfo = _storedClassInfo[cls];
356
+ ClassInfo ? classInfo = _storedClassInfo[cls];
359
357
if (classInfo != null ) {
360
358
return classInfo;
361
359
}
@@ -442,7 +440,10 @@ class PowersetBitsDomain {
442
440
}
443
441
444
442
int createFromStaticType (DartType type,
445
- {ClassRelation classRelation = ClassRelation .subtype, bool nullable}) {
443
+ {ClassRelation classRelation = ClassRelation .subtype,
444
+ required bool nullable}) {
445
+ // TODO(48820): Remove after sound null safety is enabled.
446
+ // ignore: unnecessary_null_comparison
446
447
assert (nullable != null );
447
448
448
449
if ((classRelation == ClassRelation .subtype ||
@@ -481,8 +482,6 @@ class PowersetBitsDomain {
481
482
482
483
int _createFromStaticType (
483
484
DartType type, ClassRelation classRelation, bool nullable) {
484
- assert (nullable != null );
485
-
486
485
int finish (int value, bool isPrecise) {
487
486
// [isPrecise] is ignored since we only treat singleton partitions as
488
487
// precise.
@@ -576,26 +575,21 @@ class PowersetBitsDomain {
576
575
577
576
int get emptyType => powersetBottom;
578
577
579
- int _constMapType;
580
- int get constMapType => _constMapType ?? =
578
+ late final int constMapType =
581
579
createNonNullSubtype (commonElements.constMapLiteralClass);
582
580
583
581
int get constSetType => otherValue;
584
582
585
- int _constListType;
586
- int get constListType => _constListType ?? =
583
+ late final int constListType =
587
584
createNonNullExact (commonElements.jsUnmodifiableArrayClass);
588
585
589
- int _fixedListType;
590
- int get fixedListType =>
591
- _fixedListType ?? = createNonNullExact (commonElements.jsFixedArrayClass);
586
+ late final int fixedListType =
587
+ createNonNullExact (commonElements.jsFixedArrayClass);
592
588
593
- int _growableListType;
594
- int get growableListType => _growableListType ?? =
589
+ late final int growableListType =
595
590
createNonNullExact (commonElements.jsExtendableArrayClass);
596
591
597
- int _mutableArrayType;
598
- int get mutableArrayType => _mutableArrayType ?? =
592
+ late final int mutableArrayType =
599
593
createNonNullSubtype (commonElements.jsMutableArrayClass);
600
594
601
595
int get nullType => nullValue;
@@ -605,43 +599,30 @@ class PowersetBitsDomain {
605
599
// TODO(fishythefish): Support tracking late sentinels in the powerset domain.
606
600
int get lateSentinelType => powersetBottom;
607
601
608
- int _mapType;
609
- int get mapType =>
610
- _mapType ?? = createNonNullSubtype (commonElements.mapLiteralClass);
602
+ late final int mapType = createNonNullSubtype (commonElements.mapLiteralClass);
611
603
612
- int _setType;
613
- int get setType =>
614
- _setType ?? = createNonNullSubtype (commonElements.setLiteralClass);
604
+ late final int setType = createNonNullSubtype (commonElements.setLiteralClass);
615
605
616
- int _listType;
617
- int get listType =>
618
- _listType ?? = createNonNullExact (commonElements.jsArrayClass);
606
+ late final int listType = createNonNullExact (commonElements.jsArrayClass);
619
607
620
- int _stringType;
621
- int get stringType =>
622
- _stringType ?? = createNonNullSubtype (commonElements.jsStringClass);
608
+ late final int stringType =
609
+ createNonNullSubtype (commonElements.jsStringClass);
623
610
624
- int _numType;
625
- int get numType =>
626
- _numType ?? = createNonNullSubclass (commonElements.jsNumberClass);
611
+ late final int numType = createNonNullSubclass (commonElements.jsNumberClass);
627
612
628
- int _numNotIntType;
629
- int get numNotIntType =>
630
- _numNotIntType ?? = createNonNullExact (commonElements.jsNumNotIntClass);
613
+ late final int numNotIntType =
614
+ createNonNullExact (commonElements.jsNumNotIntClass);
631
615
632
- int _intType;
633
- int get intType =>
634
- _intType ?? = createNonNullSubtype (commonElements.jsIntClass);
616
+ late final int intType = createNonNullSubtype (commonElements.jsIntClass);
635
617
636
618
int get positiveIntType => intType;
637
619
int get uint32Type => intType;
638
620
int get uint31Type => intType;
639
621
640
622
int get boolType => boolValue;
641
623
642
- int _functionType;
643
- int get functionType =>
644
- _functionType ?? = createNonNullSubtype (commonElements.functionClass);
624
+ late final int functionType =
625
+ createNonNullSubtype (commonElements.functionClass);
645
626
646
627
int get typeType => otherValue;
647
628
}
0 commit comments