| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.type_algebra; | 4 library kernel.type_algebra; |
| 5 | 5 |
| 6 import 'ast.dart'; | 6 import 'ast.dart'; |
| 7 | 7 |
| 8 /// Returns a type where all occurrences of the given type parameters have been | 8 /// Returns a type where all occurrences of the given type parameters have been |
| 9 /// replaced with the corresponding types. | 9 /// replaced with the corresponding types. |
| 10 /// | 10 /// |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 int depth = 0; | 355 int depth = 0; |
| 356 bool isInfinite = false; | 356 bool isInfinite = false; |
| 357 | 357 |
| 358 _DeepTypeSubstitutor(Map<TypeParameter, DartType> substitution, | 358 _DeepTypeSubstitutor(Map<TypeParameter, DartType> substitution, |
| 359 [_DeepTypeSubstitutor outer]) | 359 [_DeepTypeSubstitutor outer]) |
| 360 : super(outer) { | 360 : super(outer) { |
| 361 this.substitution.addAll(substitution); | 361 this.substitution.addAll(substitution); |
| 362 } | 362 } |
| 363 | 363 |
| 364 @override | 364 @override |
| 365 _TypeSubstitutor newInnerEnvironment() { | 365 _DeepTypeSubstitutor newInnerEnvironment() { |
| 366 return new _DeepTypeSubstitutor(<TypeParameter, DartType>{}, this); | 366 return new _DeepTypeSubstitutor(<TypeParameter, DartType>{}, this); |
| 367 } | 367 } |
| 368 | 368 |
| 369 @override | 369 @override |
| 370 DartType visitTypeParameterType(TypeParameterType node) { | 370 DartType visitTypeParameterType(TypeParameterType node) { |
| 371 DartType replacement = getSubstitute(node.parameter); | 371 DartType replacement = getSubstitute(node.parameter); |
| 372 if (replacement == null) return node; | 372 if (replacement == null) return node; |
| 373 if (isInfinite) return replacement; | 373 if (isInfinite) return replacement; |
| 374 ++depth; | 374 ++depth; |
| 375 if (depth > substitution.length) { | 375 if (depth > substitution.length) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } | 576 } |
| 577 | 577 |
| 578 Map<dynamic/*=K*/, dynamic/*=W*/ > _mapValues/*<K,V,W>*/( | 578 Map<dynamic/*=K*/, dynamic/*=W*/ > _mapValues/*<K,V,W>*/( |
| 579 Map<dynamic/*=K*/, dynamic/*=V*/ > map, dynamic/*=W*/ fn(dynamic/*=V*/)) { | 579 Map<dynamic/*=K*/, dynamic/*=V*/ > map, dynamic/*=W*/ fn(dynamic/*=V*/)) { |
| 580 Map<dynamic/*=K*/, dynamic/*=W*/ > result = {}; | 580 Map<dynamic/*=K*/, dynamic/*=W*/ > result = {}; |
| 581 map.forEach((key, value) { | 581 map.forEach((key, value) { |
| 582 result[key] = fn(value); | 582 result[key] = fn(value); |
| 583 }); | 583 }); |
| 584 return result; | 584 return result; |
| 585 } | 585 } |
| OLD | NEW |