Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Unified Diff: pkg/compiler/lib/src/cps_ir/type_mask_system.dart

Issue 1420563002: dart2js cps: More precise rewrite for indexables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_mask_system.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
index 2199a52146b651ec8542966781958fab3275d305..6910d46392df3b18538939d2143c30cd88b22459 100644
--- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart
@@ -46,6 +46,8 @@ class TypeMaskSystem {
TypeMask fixedLengthType;
TypeMask interceptorType;
+ TypeMask _indexableTypeTest;
+
ClassElement get jsNullClass => backend.jsNullClass;
// TODO(karlklose): remove compiler here.
@@ -71,8 +73,17 @@ class TypeMaskSystem {
TypeMask typedArray = nonNullSubclass(backend.typedArrayClass);
fixedLengthType = new TypeMask.unionOf(
- <TypeMask>[stringType, backend.fixedArrayType, typedArray],
- classWorld);
+ <TypeMask>[stringType, backend.fixedArrayType, typedArray],
+ classWorld);
+
+ // Make a TypeMask containing Indexable and (redundantly) subtypes of
+ // string because the type inference does not infer that all strings are
+ // indexables.
+ TypeMask indexable =
+ new TypeMask.nonNullSubtype(backend.jsIndexableClass, classWorld);
+ _indexableTypeTest = new TypeMask.unionOf(
+ <TypeMask>[indexable, anyString],
+ classWorld);
}
bool methodUsesReceiverArgument(FunctionElement function) {
@@ -256,7 +267,7 @@ class TypeMaskSystem {
bool isDefinitelyIndexable(TypeMask t, {bool allowNull: false}) {
if (!allowNull && t.isNullable) return false;
- return t.nonNullable().satisfies(backend.jsIndexableClass, classWorld);
+ return _indexableTypeTest.containsMask(t.nonNullable(), classWorld);
}
bool isDefinitelyMutableIndexable(TypeMask t, {bool allowNull: false}) {
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698