| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 test.parameter_of_mixin_app_constructor; | 5 library test.parameter_of_mixin_app_constructor; |
| 6 | 6 |
| 7 @MirrorsUsed(targets: "test.parameter_of_mixin_app_constructor") | 7 @MirrorsUsed(targets: "test.parameter_of_mixin_app_constructor") |
| 8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 9 import 'stringify.dart'; | 9 import 'stringify.dart'; |
| 10 | 10 |
| 11 class MapView { | 11 class MapView { |
| 12 final _map; | 12 final _map; |
| 13 MapView(map) : this._map = map; | 13 MapView(map) : this._map = map; |
| 14 } | 14 } |
| 15 | 15 |
| 16 abstract class UnmodifiableMapMixin { | 16 abstract class UnmodifiableMapMixin { |
| 17 someFunctionality() {} | 17 someFunctionality() {} |
| 18 } | 18 } |
| 19 | 19 |
| 20 class UnmodifiableMapView1 extends MapView with UnmodifiableMapMixin { | 20 class UnmodifiableMapView1 extends MapView with UnmodifiableMapMixin { |
| 21 UnmodifiableMapView1(map1) : super(map1); | 21 UnmodifiableMapView1(map1) : super(map1); |
| 22 } | 22 } |
| 23 | 23 |
| 24 class UnmodifiableMapView2 = MapView with UnmodifiableMapMixin; | 24 class UnmodifiableMapView2 = MapView with UnmodifiableMapMixin; |
| 25 | 25 |
| 26 class S { | 26 class S { |
| 27 S(int p1, String p2); | 27 S(int p1, String p2); |
| 28 } | 28 } |
| 29 | 29 |
| 30 class M1 { } | 30 class M1 {} |
| 31 class M2 { } | 31 |
| 32 class M3 { } | 32 class M2 {} |
| 33 |
| 34 class M3 {} |
| 33 | 35 |
| 34 class MorePlumbing = S with M1, M2, M3; | 36 class MorePlumbing = S with M1, M2, M3; |
| 35 | 37 |
| 36 soleConstructorOf(ClassMirror cm) { | 38 soleConstructorOf(ClassMirror cm) { |
| 37 return cm.declarations.values | 39 return cm.declarations.values |
| 38 .where((dm) => dm is MethodMirror && dm.isConstructor).single; | 40 .where((dm) => dm is MethodMirror && dm.isConstructor) |
| 41 .single; |
| 39 } | 42 } |
| 40 | 43 |
| 41 main() { | 44 main() { |
| 42 ClassMirror umv1 = reflectClass(UnmodifiableMapView1); | 45 ClassMirror umv1 = reflectClass(UnmodifiableMapView1); |
| 43 expect('[Parameter(s(map1) in s(UnmodifiableMapView1),' | 46 expect( |
| 44 ' type = Type(s(dynamic), top-level))]', | 47 '[Parameter(s(map1) in s(UnmodifiableMapView1),' |
| 45 soleConstructorOf(umv1).parameters); | 48 ' type = Type(s(dynamic), top-level))]', |
| 46 expect('[Parameter(s(map) in s(test.parameter_of_mixin_app_constructor.MapView
' | 49 soleConstructorOf(umv1).parameters); |
| 47 ' with test.parameter_of_mixin_app_constructor.UnmodifiableMapMixin),' | 50 expect( |
| 48 ' final, type = Type(s(dynamic), top-level))]', | 51 '[Parameter(s(map) in s(test.parameter_of_mixin_app_constructor.MapView' |
| 49 soleConstructorOf(umv1.superclass).parameters); | 52 ' with test.parameter_of_mixin_app_constructor.UnmodifiableMapMixin),' |
| 50 expect('[Parameter(s(map) in s(MapView),' | 53 ' final, type = Type(s(dynamic), top-level))]', |
| 51 ' type = Type(s(dynamic), top-level))]', | 54 soleConstructorOf(umv1.superclass).parameters); |
| 52 soleConstructorOf(umv1.superclass.superclass).parameters); | 55 expect( |
| 56 '[Parameter(s(map) in s(MapView),' |
| 57 ' type = Type(s(dynamic), top-level))]', |
| 58 soleConstructorOf(umv1.superclass.superclass).parameters); |
| 53 expect('[]', | 59 expect('[]', |
| 54 soleConstructorOf(umv1.superclass.superclass.superclass).parameters); | 60 soleConstructorOf(umv1.superclass.superclass.superclass).parameters); |
| 55 | 61 |
| 56 ClassMirror umv2 = reflectClass(UnmodifiableMapView2); | 62 ClassMirror umv2 = reflectClass(UnmodifiableMapView2); |
| 57 expect('[Parameter(s(map) in s(UnmodifiableMapView2),' | 63 expect( |
| 58 ' final, type = Type(s(dynamic), top-level))]', | 64 '[Parameter(s(map) in s(UnmodifiableMapView2),' |
| 59 soleConstructorOf(umv2).parameters); | 65 ' final, type = Type(s(dynamic), top-level))]', |
| 60 expect('[Parameter(s(map) in s(MapView),' | 66 soleConstructorOf(umv2).parameters); |
| 61 ' type = Type(s(dynamic), top-level))]', | 67 expect( |
| 62 soleConstructorOf(umv2.superclass).parameters); | 68 '[Parameter(s(map) in s(MapView),' |
| 63 expect('[]', | 69 ' type = Type(s(dynamic), top-level))]', |
| 64 soleConstructorOf(umv2.superclass.superclass).parameters); | 70 soleConstructorOf(umv2.superclass).parameters); |
| 71 expect('[]', soleConstructorOf(umv2.superclass.superclass).parameters); |
| 65 | 72 |
| 66 ClassMirror mp = reflectClass(MorePlumbing); | 73 ClassMirror mp = reflectClass(MorePlumbing); |
| 67 expect('[Parameter(s(p1) in s(MorePlumbing),' | 74 expect( |
| 68 ' final, type = Type(s(dynamic), top-level)),' | 75 '[Parameter(s(p1) in s(MorePlumbing),' |
| 69 ' Parameter(s(p2) in s(MorePlumbing),' | 76 ' final, type = Type(s(dynamic), top-level)),' |
| 70 ' final, type = Type(s(dynamic), top-level))]', | 77 ' Parameter(s(p2) in s(MorePlumbing),' |
| 71 soleConstructorOf(mp).parameters); | 78 ' final, type = Type(s(dynamic), top-level))]', |
| 72 expect('[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' | 79 soleConstructorOf(mp).parameters); |
| 73 ' with test.parameter_of_mixin_app_constructor.M1,' | 80 expect( |
| 74 ' test.parameter_of_mixin_app_constructor.M2),' | 81 '[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' |
| 75 ' final, type = Type(s(dynamic), top-level)),' | 82 ' with test.parameter_of_mixin_app_constructor.M1,' |
| 76 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' | 83 ' test.parameter_of_mixin_app_constructor.M2),' |
| 77 ' with test.parameter_of_mixin_app_constructor.M1,' | 84 ' final, type = Type(s(dynamic), top-level)),' |
| 78 ' test.parameter_of_mixin_app_constructor.M2),' | 85 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' |
| 79 ' final, type = Type(s(dynamic), top-level))]', | 86 ' with test.parameter_of_mixin_app_constructor.M1,' |
| 80 soleConstructorOf(mp.superclass).parameters); | 87 ' test.parameter_of_mixin_app_constructor.M2),' |
| 81 expect('[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' | 88 ' final, type = Type(s(dynamic), top-level))]', |
| 82 ' with test.parameter_of_mixin_app_constructor.M1),' | 89 soleConstructorOf(mp.superclass).parameters); |
| 83 ' final, type = Type(s(dynamic), top-level)),' | 90 expect( |
| 84 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' | 91 '[Parameter(s(p1) in s(test.parameter_of_mixin_app_constructor.S' |
| 85 ' with test.parameter_of_mixin_app_constructor.M1),' | 92 ' with test.parameter_of_mixin_app_constructor.M1),' |
| 86 ' final, type = Type(s(dynamic), top-level))]', | 93 ' final, type = Type(s(dynamic), top-level)),' |
| 87 soleConstructorOf(mp.superclass.superclass).parameters); | 94 ' Parameter(s(p2) in s(test.parameter_of_mixin_app_constructor.S' |
| 88 expect('[Parameter(s(p1) in s(S),' | 95 ' with test.parameter_of_mixin_app_constructor.M1),' |
| 89 ' type = Class(s(int) in s(dart.core), top-level)),' | 96 ' final, type = Type(s(dynamic), top-level))]', |
| 90 ' Parameter(s(p2) in s(S),' | 97 soleConstructorOf(mp.superclass.superclass).parameters); |
| 91 ' type = Class(s(String) in s(dart.core), top-level))]', | 98 expect( |
| 92 soleConstructorOf(mp.superclass.superclass.superclass).parameters); | 99 '[Parameter(s(p1) in s(S),' |
| 93 expect('[]', | 100 ' type = Class(s(int) in s(dart.core), top-level)),' |
| 94 soleConstructorOf(mp.superclass.superclass.superclass.superclass).param
eters); | 101 ' Parameter(s(p2) in s(S),' |
| 102 ' type = Class(s(String) in s(dart.core), top-level))]', |
| 103 soleConstructorOf(mp.superclass.superclass.superclass).parameters); |
| 104 expect( |
| 105 '[]', |
| 106 soleConstructorOf(mp.superclass.superclass.superclass.superclass) |
| 107 .parameters); |
| 95 } | 108 } |
| OLD | NEW |