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

Side by Side Diff: lib/src/checker/rules.dart

Issue 1348453004: fix some errors in our SDK, mostly around numbers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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 | « lib/runtime/dart_runtime.js ('k') | lib/src/codegen/js_codegen.dart » ('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 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.checker.rules; 5 library dev_compiler.src.checker.rules;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/resolver.dart'; 9 import 'package:analyzer/src/generated/resolver.dart';
10 10
(...skipping 19 matching lines...) Expand all
30 bool isGroundType(DartType t) => true; 30 bool isGroundType(DartType t) => true;
31 // TODO(vsm): The default implementation is not ignoring the return type, 31 // TODO(vsm): The default implementation is not ignoring the return type,
32 // only the restricted override is. 32 // only the restricted override is.
33 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2, 33 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2,
34 {bool fuzzyArrows: true, bool ignoreReturn: false}) => 34 {bool fuzzyArrows: true, bool ignoreReturn: false}) =>
35 isSubTypeOf(f1, f2); 35 isSubTypeOf(f1, f2);
36 36
37 bool isBoolType(DartType t) => t == provider.boolType; 37 bool isBoolType(DartType t) => t == provider.boolType;
38 bool isDoubleType(DartType t) => t == provider.doubleType; 38 bool isDoubleType(DartType t) => t == provider.doubleType;
39 bool isIntType(DartType t) => t == provider.intType; 39 bool isIntType(DartType t) => t == provider.intType;
40 bool isNumType(DartType t) => t == provider.intType.superclass; 40 bool isNumType(DartType t) => t == provider.numType;
41
42 /// Returns true if this is any kind of object represented by `Number` in JS.
43 ///
44 /// In practice, this is 4 types: num, int, double, and JSNumber.
45 ///
46 /// JSNumber is the type that actually "implements" all numbers, hence it's
47 /// a subtype of int and double (and num). It's in our "dart:_interceptors".
48 bool isNumberInJS(DartType t) => isSubTypeOf(t, provider.numType);
49
41 bool isStringType(DartType t) => t == provider.stringType; 50 bool isStringType(DartType t) => t == provider.stringType;
42 bool isNonNullableType(DartType t) => false; 51 bool isNonNullableType(DartType t) => false;
43 bool maybeNonNullableType(DartType t) => false; 52 bool maybeNonNullableType(DartType t) => false;
44 53
45 StaticInfo checkAssignment(Expression expr, DartType t); 54 StaticInfo checkAssignment(Expression expr, DartType t);
46 55
47 DartType getStaticType(Expression expr) => expr.staticType; 56 DartType getStaticType(Expression expr) => expr.staticType;
48 57
49 /// Given a type t, if t is an interface type with a call method 58 /// Given a type t, if t is an interface type with a call method
50 /// defined, return the function type for the call method, otherwise 59 /// defined, return the function type for the call method, otherwise
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 var entries = e.entries; 847 var entries = e.entries;
839 bool inferEntry(MapLiteralEntry entry) { 848 bool inferEntry(MapLiteralEntry entry) {
840 return _inferExpression(entry.key, kType, errors) && 849 return _inferExpression(entry.key, kType, errors) &&
841 _inferExpression(entry.value, vType, errors); 850 _inferExpression(entry.value, vType, errors);
842 } 851 }
843 var b = entries.every(inferEntry); 852 var b = entries.every(inferEntry);
844 if (b) annotateMapLiteral(e, targs); 853 if (b) annotateMapLiteral(e, targs);
845 return b; 854 return b;
846 } 855 }
847 } 856 }
OLDNEW
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698