| 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 subtype_test; | 5 library subtype_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 'type_test_helper.dart'; | 9 import 'type_test_helper.dart'; |
| 10 import 'package:compiler/implementation/dart_types.dart'; | 10 import 'package:compiler/implementation/dart_types.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 Expect.isNotNull(member); | 37 Expect.isNotNull(member); |
| 38 DartType memberType = member.type; | 38 DartType memberType = member.type; |
| 39 Expect.equals(expectedType, memberType, | 39 Expect.equals(expectedType, memberType, |
| 40 'Wrong member type for $receiverType.$memberName.'); | 40 'Wrong member type for $receiverType.$memberName.'); |
| 41 } | 41 } |
| 42 | 42 |
| 43 DartType int_ = env['int']; | 43 DartType int_ = env['int']; |
| 44 DartType String_ = env['String']; | 44 DartType String_ = env['String']; |
| 45 | 45 |
| 46 ClassElement A = env.getElement('A'); | 46 ClassElement A = env.getElement('A'); |
| 47 DartType T = A.typeVariables.head; | 47 DartType T = A.typeVariables.first; |
| 48 DartType A_T = A.thisType; | 48 DartType A_T = A.thisType; |
| 49 expect(A_T, 'foo', T); | 49 expect(A_T, 'foo', T); |
| 50 | 50 |
| 51 DartType A_int = instantiate(A, [int_]); | 51 DartType A_int = instantiate(A, [int_]); |
| 52 expect(A_int, 'foo', int_); | 52 expect(A_int, 'foo', int_); |
| 53 | 53 |
| 54 ClassElement B = env.getElement('B'); | 54 ClassElement B = env.getElement('B'); |
| 55 DartType S = B.typeVariables.head; | 55 DartType S = B.typeVariables.first; |
| 56 DartType B_S = B.thisType; | 56 DartType B_S = B.thisType; |
| 57 expect(B_S, 'foo', instantiate(A, [S])); | 57 expect(B_S, 'foo', instantiate(A, [S])); |
| 58 expect(B_S, 'bar', S); | 58 expect(B_S, 'bar', S); |
| 59 | 59 |
| 60 DartType B_int = instantiate(B, [int_]); | 60 DartType B_int = instantiate(B, [int_]); |
| 61 expect(B_int, 'foo', A_int); | 61 expect(B_int, 'foo', A_int); |
| 62 expect(B_int, 'bar', int_); | 62 expect(B_int, 'bar', int_); |
| 63 | 63 |
| 64 ClassElement C = env.getElement('C'); | 64 ClassElement C = env.getElement('C'); |
| 65 DartType U = C.typeVariables.head; | 65 DartType U = C.typeVariables.first; |
| 66 DartType C_U = C.thisType; | 66 DartType C_U = C.thisType; |
| 67 expect(C_U, 'foo', instantiate(A, [String_])); | 67 expect(C_U, 'foo', instantiate(A, [String_])); |
| 68 expect(C_U, 'bar', String_); | 68 expect(C_U, 'bar', String_); |
| 69 expect(C_U, 'baz', U); | 69 expect(C_U, 'baz', U); |
| 70 expect(C_U, 'boz', instantiate(B, [U])); | 70 expect(C_U, 'boz', instantiate(B, [U])); |
| 71 | 71 |
| 72 DartType C_int = instantiate(C, [int_]); | 72 DartType C_int = instantiate(C, [int_]); |
| 73 expect(C_int, 'foo', instantiate(A, [String_])); | 73 expect(C_int, 'foo', instantiate(A, [String_])); |
| 74 expect(C_int, 'bar', String_); | 74 expect(C_int, 'bar', String_); |
| 75 expect(C_int, 'baz', int_); | 75 expect(C_int, 'baz', int_); |
| 76 expect(C_int, 'boz', instantiate(B, [int_])); | 76 expect(C_int, 'boz', instantiate(B, [int_])); |
| 77 })); | 77 })); |
| 78 } | 78 } |
| 79 | 79 |
| OLD | NEW |