| 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 |
| 11 import 'package:dev_compiler/src/info.dart'; | 11 import 'package:dev_compiler/src/info.dart'; |
| 12 import 'package:dev_compiler/src/options.dart'; | |
| 13 import 'package:dev_compiler/src/utils.dart' as utils; | 12 import 'package:dev_compiler/src/utils.dart' as utils; |
| 13 import 'package:dev_compiler/strong_mode.dart' show StrongModeOptions; |
| 14 | 14 |
| 15 abstract class TypeRules { | 15 abstract class TypeRules { |
| 16 final TypeProvider provider; | 16 final TypeProvider provider; |
| 17 LibraryInfo currentLibraryInfo = null; | 17 LibraryInfo currentLibraryInfo = null; |
| 18 | 18 |
| 19 /// Map of fields / properties / methods on Object. | 19 /// Map of fields / properties / methods on Object. |
| 20 final Map<String, DartType> objectMembers; | 20 final Map<String, DartType> objectMembers; |
| 21 | 21 |
| 22 TypeRules(TypeProvider provider) | 22 TypeRules(TypeProvider provider) |
| 23 : provider = provider, | 23 : provider = provider, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 /// By default, all invocations are dynamic in Dart. | 109 /// By default, all invocations are dynamic in Dart. |
| 110 bool isDynamic(DartType t) => true; | 110 bool isDynamic(DartType t) => true; |
| 111 bool isDynamicTarget(Expression expr) => true; | 111 bool isDynamicTarget(Expression expr) => true; |
| 112 bool isDynamicCall(Expression call) => true; | 112 bool isDynamicCall(Expression call) => true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 typedef void MissingTypeReporter(Expression expr); | 115 typedef void MissingTypeReporter(Expression expr); |
| 116 | 116 |
| 117 class RestrictedRules extends TypeRules { | 117 class RestrictedRules extends TypeRules { |
| 118 MissingTypeReporter reportMissingType = null; | 118 MissingTypeReporter reportMissingType = null; |
| 119 final RulesOptions options; | 119 final StrongModeOptions options; |
| 120 final List<DartType> _nonnullableTypes; | 120 final List<DartType> _nonnullableTypes; |
| 121 DownwardsInference inferrer; | 121 DownwardsInference inferrer; |
| 122 | 122 |
| 123 DartType _typeFromName(String name) { | 123 DartType _typeFromName(String name) { |
| 124 switch (name) { | 124 switch (name) { |
| 125 case 'int': | 125 case 'int': |
| 126 return provider.intType; | 126 return provider.intType; |
| 127 case 'double': | 127 case 'double': |
| 128 return provider.doubleType; | 128 return provider.doubleType; |
| 129 case 'num': | 129 case 'num': |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 var entries = e.entries; | 778 var entries = e.entries; |
| 779 bool inferEntry(MapLiteralEntry entry) { | 779 bool inferEntry(MapLiteralEntry entry) { |
| 780 return _inferExpression(entry.key, kType, errors) && | 780 return _inferExpression(entry.key, kType, errors) && |
| 781 _inferExpression(entry.value, vType, errors); | 781 _inferExpression(entry.value, vType, errors); |
| 782 } | 782 } |
| 783 var b = entries.every(inferEntry); | 783 var b = entries.every(inferEntry); |
| 784 if (b) annotateMapLiteral(e, targs); | 784 if (b) annotateMapLiteral(e, targs); |
| 785 return b; | 785 return b; |
| 786 } | 786 } |
| 787 } | 787 } |
| OLD | NEW |