| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |