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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2638393004: Fix subtyping check on number (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test/browser/language_tests.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 5606 matching lines...) Expand 10 before | Expand all | Expand 10 after
5617 } 5617 }
5618 return node..sourceInformation = original; 5618 return node..sourceInformation = original;
5619 } 5619 }
5620 5620
5621 /// Returns true if this is any kind of object represented by `Number` in JS. 5621 /// Returns true if this is any kind of object represented by `Number` in JS.
5622 /// 5622 ///
5623 /// In practice, this is 4 types: num, int, double, and JSNumber. 5623 /// In practice, this is 4 types: num, int, double, and JSNumber.
5624 /// 5624 ///
5625 /// JSNumber is the type that actually "implements" all numbers, hence it's 5625 /// JSNumber is the type that actually "implements" all numbers, hence it's
5626 /// a subtype of int and double (and num). It's in our "dart:_interceptors". 5626 /// a subtype of int and double (and num). It's in our "dart:_interceptors".
5627 bool _isNumberInJS(DartType t) => rules.isSubtypeOf(t, types.numType); 5627 bool _isNumberInJS(DartType t) =>
5628 rules.isSubtypeOf(t, types.numType) &&
5629 !rules.isSubtypeOf(t, types.nullType);
5628 5630
5629 /// Return true if this is one of the methods/properties on all Dart Objects 5631 /// Return true if this is one of the methods/properties on all Dart Objects
5630 /// (toString, hashCode, noSuchMethod, runtimeType). 5632 /// (toString, hashCode, noSuchMethod, runtimeType).
5631 /// 5633 ///
5632 /// Operator == is excluded, as it is handled as part of the equality binary 5634 /// Operator == is excluded, as it is handled as part of the equality binary
5633 /// operator. 5635 /// operator.
5634 bool isObjectMember(String name) { 5636 bool isObjectMember(String name) {
5635 // We could look these up on Object, but we have hard coded runtime helpers 5637 // We could look these up on Object, but we have hard coded runtime helpers
5636 // so it's not really providing any benefit. 5638 // so it's not really providing any benefit.
5637 switch (name) { 5639 switch (name) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
5831 if (targetIdentifier.staticElement is! PrefixElement) return false; 5833 if (targetIdentifier.staticElement is! PrefixElement) return false;
5832 var prefix = targetIdentifier.staticElement as PrefixElement; 5834 var prefix = targetIdentifier.staticElement as PrefixElement;
5833 5835
5834 // The library the prefix is referring to must come from a deferred import. 5836 // The library the prefix is referring to must come from a deferred import.
5835 var containingLibrary = resolutionMap 5837 var containingLibrary = resolutionMap
5836 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5838 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5837 .library; 5839 .library;
5838 var imports = containingLibrary.getImportsWithPrefix(prefix); 5840 var imports = containingLibrary.getImportsWithPrefix(prefix);
5839 return imports.length == 1 && imports[0].isDeferred; 5841 return imports.length == 1 && imports[0].isDeferred;
5840 } 5842 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test/browser/language_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698