| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_substitution_test; | 5 library type_substitution_test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/elements/resolution_types.dart'; | 9 import 'package:compiler/src/elements/resolution_types.dart'; |
| 10 import 'compiler_helper.dart'; | 10 import 'compiler_helper.dart'; |
| 11 import 'type_test_helper.dart'; | 11 import 'type_test_helper.dart'; |
| 12 | 12 |
| 13 ResolutionDartType getType(compiler, String name) { | 13 ResolutionDartType getType(compiler, String name) { |
| 14 var clazz = findElement(compiler, "Class"); | 14 var clazz = findElement(compiler, "Class"); |
| 15 clazz.ensureResolved(compiler.resolution); | 15 clazz.ensureResolved(compiler.resolution); |
| 16 var element = clazz.buildScope().lookup(name); | 16 var element = clazz.buildScope().lookup(name); |
| 17 Expect.isNotNull(element); | 17 Expect.isNotNull(element); |
| 18 Expect.equals(element.kind, ElementKind.FUNCTION); | 18 Expect.equals(element.kind, ElementKind.FUNCTION); |
| 19 element.computeType(compiler.resolution); | 19 element.computeType(compiler.resolution); |
| 20 FunctionSignature signature = element.functionSignature; | 20 FunctionSignature signature = element.functionSignature; |
| 21 | 21 |
| 22 // Function signatures are used to be to provide void types (only occuring as | 22 // Function signatures are used to be to provide void types (only occurring as |
| 23 // as return types) and (inlined) function types (only occuring as method | 23 // as return types) and (inlined) function types (only occurring as method |
| 24 // parameter types). | 24 // parameter types). |
| 25 // | 25 // |
| 26 // Only a single type is used from each signature. That is, it is not the | 26 // Only a single type is used from each signature. That is, it is not the |
| 27 // intention to check the whole signatures against eachother. | 27 // intention to check the whole signatures against eachother. |
| 28 if (signature.requiredParameterCount == 0) { | 28 if (signature.requiredParameterCount == 0) { |
| 29 // If parameters is empty, use return type. | 29 // If parameters is empty, use return type. |
| 30 return signature.type.returnType; | 30 return signature.type.returnType; |
| 31 } else { | 31 } else { |
| 32 // Otherwise use the first argument type. | 32 // Otherwise use the first argument type. |
| 33 return signature.requiredParameters.first.type; | 33 return signature.requiredParameters.first.type; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 ResolutionDartType Typedef1 = getType(compiler, "Typedef1c"); | 248 ResolutionDartType Typedef1 = getType(compiler, "Typedef1c"); |
| 249 Expect.isNotNull(Typedef1); | 249 Expect.isNotNull(Typedef1); |
| 250 ResolutionDartType Function_dynamic_dynamic = | 250 ResolutionDartType Function_dynamic_dynamic = |
| 251 getType(compiler, "Function1c"); | 251 getType(compiler, "Function1c"); |
| 252 Expect.isNotNull(Function_dynamic_dynamic); | 252 Expect.isNotNull(Function_dynamic_dynamic); |
| 253 ResolutionDartType unalias2 = Typedef1.unaliased; | 253 ResolutionDartType unalias2 = Typedef1.unaliased; |
| 254 Expect.equals(Function_dynamic_dynamic, unalias2, | 254 Expect.equals(Function_dynamic_dynamic, unalias2, |
| 255 '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic'); | 255 '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic'); |
| 256 })); | 256 })); |
| 257 } | 257 } |
| OLD | NEW |