| 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 mixin_typevariable_test; | 5 library mixin_typevariable_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/src/dart_types.dart'; |
| 11 import "package:compiler/implementation/elements/elements.dart" | 11 import "package:compiler/src/elements/elements.dart" |
| 12 show Element, ClassElement; | 12 show Element, ClassElement; |
| 13 | 13 |
| 14 void main() { | 14 void main() { |
| 15 testMixinSupertypes(); | 15 testMixinSupertypes(); |
| 16 testNonTrivialSubstitutions(); | 16 testNonTrivialSubstitutions(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void testMixinSupertypes() { | 19 void testMixinSupertypes() { |
| 20 asyncTest(() => TypeEnvironment.create(r""" | 20 asyncTest(() => TypeEnvironment.create(r""" |
| 21 class S<S_T> {} | 21 class S<S_T> {} |
| 22 class M1<M1_T> {} | 22 class M1<M1_T> {} |
| 23 class M2<M2_T> {} | 23 class M2<M2_T> {} |
| 24 class M3<M3_T> {} | 24 class M3<M3_T> {} |
| 25 | 25 |
| 26 class C1<C1_T> extends S<C1_T> with M1<C1_T>, M2<C1_T>, M3<C1_T> {} | 26 class C1<C1_T> extends S<C1_T> with M1<C1_T>, M2<C1_T>, M3<C1_T> {} |
| 27 class C2<C2_T> = S<C2_T> with M1<C2_T>, M2<C2_T>, M3<C2_T>; | 27 class C2<C2_T> = S<C2_T> with M1<C2_T>, M2<C2_T>, M3<C2_T>; |
| 28 """, expectNoWarningsOrErrors: true).then((env) { | 28 """, expectNoWarningsOrErrors: true).then((env) { |
| 29 | 29 |
| 30 ClassElement Object = env.getElement('Object'); | 30 ClassElement Object = env.getElement('Object'); |
| 31 ClassElement S = env.getElement('S'); | 31 ClassElement S = env.getElement('S'); |
| 32 ClassElement M1 = env.getElement('M1'); | 32 ClassElement M1 = env.getElement('M1'); |
| 33 ClassElement M2 = env.getElement('M2'); | 33 ClassElement M2 = env.getElement('M2'); |
| 34 ClassElement M3 = env.getElement('M3'); | 34 ClassElement M3 = env.getElement('M3'); |
| 35 ClassElement C1 = env.getElement('C1'); | 35 ClassElement C1 = env.getElement('C1'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 testSupertypes(C2_S_M1_M2); | 70 testSupertypes(C2_S_M1_M2); |
| 71 testSupertypes(C2); | 71 testSupertypes(C2); |
| 72 })); | 72 })); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void testNonTrivialSubstitutions() { | 75 void testNonTrivialSubstitutions() { |
| 76 asyncTest(() => TypeEnvironment.create(r""" | 76 asyncTest(() => TypeEnvironment.create(r""" |
| 77 class _ {} | 77 class _ {} |
| 78 class A<A_T> {} | 78 class A<A_T> {} |
| 79 class B<B_T, B_S> {} | 79 class B<B_T, B_S> {} |
| 80 | 80 |
| 81 class C1<C1_T> extends A with B {} | 81 class C1<C1_T> extends A with B {} |
| 82 class C2<C2_T> = A with B; | 82 class C2<C2_T> = A with B; |
| 83 | 83 |
| 84 class D1<D1_T> extends A<D1_T> with B<D1_T, A<D1_T>> {} | 84 class D1<D1_T> extends A<D1_T> with B<D1_T, A<D1_T>> {} |
| 85 class D2<D2_T> = A<D2_T> with B<D2_T, A<D2_T>>; | 85 class D2<D2_T> = A<D2_T> with B<D2_T, A<D2_T>>; |
| 86 | 86 |
| 87 class E1<E1_T> extends A<_> with B<_, A<_>> {} | 87 class E1<E1_T> extends A<_> with B<_, A<_>> {} |
| 88 class E2<E2_T> = A<_> with B<_, A<_>>; | 88 class E2<E2_T> = A<_> with B<_, A<_>>; |
| 89 | 89 |
| 90 class F1<F1_T> extends A<_> with B<_, B<F1_T, _>> {} | 90 class F1<F1_T> extends A<_> with B<_, B<F1_T, _>> {} |
| 91 class F2<F2_T> = A<_> with B<_, B<F2_T, _>>; | 91 class F2<F2_T> = A<_> with B<_, B<F2_T, _>>; |
| 92 """, expectNoWarningsOrErrors: true).then((env) { | 92 """, expectNoWarningsOrErrors: true).then((env) { |
| 93 DartType _dynamic = env['dynamic']; | 93 DartType _dynamic = env['dynamic']; |
| 94 DartType _ = env['_']; | 94 DartType _ = env['_']; |
| 95 | 95 |
| 96 ClassElement Object = env.getElement('Object'); | 96 ClassElement Object = env.getElement('Object'); |
| 97 ClassElement A = env.getElement('A'); | 97 ClassElement A = env.getElement('A'); |
| 98 ClassElement B = env.getElement('B'); | 98 ClassElement B = env.getElement('B'); |
| 99 ClassElement C1 = env.getElement('C1'); | 99 ClassElement C1 = env.getElement('C1'); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 testSupertypes(E2, {A: [_], B: [_, instantiate(A, [_])]}); | 149 testSupertypes(E2, {A: [_], B: [_, instantiate(A, [_])]}); |
| 150 | 150 |
| 151 DartType F1_T = F1.typeVariables.first; | 151 DartType F1_T = F1.typeVariables.first; |
| 152 testSupertypes(F1, {A: [_], B: [_, instantiate(B, [F1_T, _])]}); | 152 testSupertypes(F1, {A: [_], B: [_, instantiate(B, [F1_T, _])]}); |
| 153 DartType F1_superclass_T = F1.superclass.typeVariables.first; | 153 DartType F1_superclass_T = F1.superclass.typeVariables.first; |
| 154 testSupertypes(F1.superclass, {A: [_], B: [_, instantiate(B, [F1_superclass_
T, _])]}); | 154 testSupertypes(F1.superclass, {A: [_], B: [_, instantiate(B, [F1_superclass_
T, _])]}); |
| 155 DartType F2_T = F2.typeVariables.first; | 155 DartType F2_T = F2.typeVariables.first; |
| 156 testSupertypes(F2, {A: [_], B: [_, instantiate(B, [F2_T, _])]}); | 156 testSupertypes(F2, {A: [_], B: [_, instantiate(B, [F2_T, _])]}); |
| 157 })); | 157 })); |
| 158 } | 158 } |
| OLD | NEW |