| 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 14 matching lines...) Expand all Loading... |
| 25 bool isSubTypeOf(DartType t1, DartType t2); | 25 bool isSubTypeOf(DartType t1, DartType t2); |
| 26 bool isAssignable(DartType t1, DartType t2); | 26 bool isAssignable(DartType t1, DartType t2); |
| 27 | 27 |
| 28 bool isGroundType(DartType t) => true; | 28 bool isGroundType(DartType t) => true; |
| 29 // TODO(vsm): The default implementation is not ignoring the return type, | 29 // TODO(vsm): The default implementation is not ignoring the return type, |
| 30 // only the restricted override is. | 30 // only the restricted override is. |
| 31 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2, | 31 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2, |
| 32 {bool fuzzyArrows: true, bool ignoreReturn: false}) => | 32 {bool fuzzyArrows: true, bool ignoreReturn: false}) => |
| 33 isSubTypeOf(f1, f2); | 33 isSubTypeOf(f1, f2); |
| 34 | 34 |
| 35 bool isBoolType(DartType t) => t == provider.boolType; | |
| 36 bool isDoubleType(DartType t) => t == provider.doubleType; | |
| 37 bool isIntType(DartType t) => t == provider.intType; | |
| 38 bool isNumType(DartType t) => t == provider.numType; | |
| 39 | |
| 40 /// Returns true if this is any kind of object represented by `Number` in JS. | |
| 41 /// | |
| 42 /// In practice, this is 4 types: num, int, double, and JSNumber. | |
| 43 /// | |
| 44 /// JSNumber is the type that actually "implements" all numbers, hence it's | |
| 45 /// a subtype of int and double (and num). It's in our "dart:_interceptors". | |
| 46 bool isNumberInJS(DartType t) => isSubTypeOf(t, provider.numType); | |
| 47 | |
| 48 bool isStringType(DartType t) => t == provider.stringType; | |
| 49 bool isNonNullableType(DartType t) => false; | 35 bool isNonNullableType(DartType t) => false; |
| 50 bool maybeNonNullableType(DartType t) => false; | 36 bool maybeNonNullableType(DartType t) => false; |
| 51 | 37 |
| 52 StaticInfo checkAssignment(Expression expr, DartType t); | 38 StaticInfo checkAssignment(Expression expr, DartType t); |
| 53 | 39 |
| 54 DartType getStaticType(Expression expr) => expr.staticType; | 40 DartType getStaticType(Expression expr) => expr.staticType; |
| 55 | 41 |
| 56 /// Given a type t, if t is an interface type with a call method | 42 /// Given a type t, if t is an interface type with a call method |
| 57 /// defined, return the function type for the call method, otherwise | 43 /// defined, return the function type for the call method, otherwise |
| 58 /// return null. | 44 /// return null. |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 var entries = e.entries; | 797 var entries = e.entries; |
| 812 bool inferEntry(MapLiteralEntry entry) { | 798 bool inferEntry(MapLiteralEntry entry) { |
| 813 return _inferExpression(entry.key, kType, errors) && | 799 return _inferExpression(entry.key, kType, errors) && |
| 814 _inferExpression(entry.value, vType, errors); | 800 _inferExpression(entry.value, vType, errors); |
| 815 } | 801 } |
| 816 var b = entries.every(inferEntry); | 802 var b = entries.every(inferEntry); |
| 817 if (b) annotateMapLiteral(e, targs); | 803 if (b) annotateMapLiteral(e, targs); |
| 818 return b; | 804 return b; |
| 819 } | 805 } |
| 820 } | 806 } |
| OLD | NEW |