| Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| index b397a423677cc64cad0e42136bd039ecabcf2728..f36a38712d0dde4b3a9ad10056ca080e66b3cef9 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| @@ -2130,6 +2130,10 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| // Classes like JSUInt31 and JSUInt32 do not exist at runtime, so ensure
|
| // all the int classes get mapped tor their runtime class.
|
| singleClass = backend.jsIntClass;
|
| + } else if (lattice.isDefinitelyNum(value)) {
|
| + if (jsNumberClassSuffices(node)) {
|
| + singleClass = backend.jsNumberClass;
|
| + }
|
| } else if (lattice.isDefinitelyNativeList(value)) {
|
| // Ensure all the array subclasses get mapped to the array class.
|
| singleClass = backend.jsArrayClass;
|
| @@ -2155,6 +2159,27 @@ class TransformingVisitor extends DeepRecursiveVisitor {
|
| }
|
| return null;
|
| }
|
| +
|
| + bool jsNumberClassSuffices(Interceptor node) {
|
| + // No methods on JSNumber call 'down' to methods on JSInt or JSDouble. If
|
| + // all uses of the interceptor are for methods is defined only on JSNumber
|
| + // then JSNumber will suffice in place of choosing between JSInt or
|
| + // JSDouble.
|
| + for (Reference ref = node.firstRef; ref != null; ref = ref.next) {
|
| + if (ref.parent is InvokeMethod) {
|
| + InvokeMethod invoke = ref.parent;
|
| + if (invoke.receiver != ref) return false;
|
| + var interceptedClasses =
|
| + functionCompiler.glue.getInterceptedClassesOn(invoke.selector);
|
| + if (interceptedClasses.contains(backend.jsDoubleClass)) return false;
|
| + if (interceptedClasses.contains(backend.jsIntClass)) return false;
|
| + continue;
|
| + }
|
| + // Other uses need full distinction.
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| }
|
|
|
| /**
|
|
|