| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 type_test_helper; | 5 library type_test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; | 9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; |
| 10 import "compiler_helper.dart"; | 10 import "compiler_helper.dart"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool isSubtype(DartType T, DartType S) { | 66 bool isSubtype(DartType T, DartType S) { |
| 67 return compiler.types.isSubtype(T, S); | 67 return compiler.types.isSubtype(T, S); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool isMoreSpecific(DartType T, DartType S) { | 70 bool isMoreSpecific(DartType T, DartType S) { |
| 71 return compiler.types.isMoreSpecific(T, S); | 71 return compiler.types.isMoreSpecific(T, S); |
| 72 } | 72 } |
| 73 | 73 |
| 74 DartType computeLeastUpperBound(DartType T, DartType S) { |
| 75 return compiler.types.computeLeastUpperBound(T, S); |
| 76 } |
| 77 |
| 74 FunctionType functionType(DartType returnType, | 78 FunctionType functionType(DartType returnType, |
| 75 List<DartType> parameters, | 79 List<DartType> parameters, |
| 76 {List<DartType> optionalParameter, | 80 {List<DartType> optionalParameter, |
| 77 Map<String,DartType> namedParameters}) { | 81 Map<String,DartType> namedParameters}) { |
| 78 Link<DartType> parameterTypes = | 82 Link<DartType> parameterTypes = |
| 79 new Link<DartType>.fromList(parameters); | 83 new Link<DartType>.fromList(parameters); |
| 80 Link<DartType> optionalParameterTypes = optionalParameter != null | 84 Link<DartType> optionalParameterTypes = optionalParameter != null |
| 81 ? new Link<DartType>.fromList(optionalParameter) | 85 ? new Link<DartType>.fromList(optionalParameter) |
| 82 : const Link<DartType>(); | 86 : const Link<DartType>(); |
| 83 var namedParameterNames = new LinkBuilder<String>(); | 87 var namedParameterNames = new LinkBuilder<String>(); |
| 84 var namedParameterTypes = new LinkBuilder<DartType>(); | 88 var namedParameterTypes = new LinkBuilder<DartType>(); |
| 85 if (namedParameters != null) { | 89 if (namedParameters != null) { |
| 86 namedParameters.forEach((String name, DartType type) { | 90 namedParameters.forEach((String name, DartType type) { |
| 87 namedParameterNames.addLast(name); | 91 namedParameterNames.addLast(name); |
| 88 namedParameterTypes.addLast(type); | 92 namedParameterTypes.addLast(type); |
| 89 }); | 93 }); |
| 90 } | 94 } |
| 91 FunctionType type = new FunctionType( | 95 return new FunctionType( |
| 92 compiler.functionClass, | 96 compiler.functionClass, |
| 93 returnType, parameterTypes, optionalParameterTypes, | 97 returnType, parameterTypes, optionalParameterTypes, |
| 94 namedParameterNames.toLink(), namedParameterTypes.toLink()); | 98 namedParameterNames.toLink(), namedParameterTypes.toLink()); |
| 95 } | 99 } |
| 96 } | 100 } |
| OLD | NEW |