@@ -144,29 +144,35 @@ getterChild(value, childKey) {
144
144
}
145
145
}
146
146
147
- if (isInterface (value, Getter ) && value.containsKey (childKey)) {
148
- return [true , value[childKey]];
149
- } else {
150
- InstanceMirror instanceMirror = reflect (value);
151
- Symbol curSym = new Symbol (childKey);
152
- try {
153
- // maybe it is a member field?
154
- return [true , instanceMirror.getField (curSym).reflectee];
155
- } catch (e) {
156
- // maybe it is a member method?
157
- if (instanceMirror.type.members.containsKey (curSym)) {
158
- MethodMirror methodMirror = instanceMirror.type.members[curSym];
159
- return [true , _relaxFnArgs ((args) {
160
- if (args == null ) args = [];
161
- try {
162
- return instanceMirror.invoke (curSym, args).reflectee;
163
- } catch (e) {
164
- throw "$e \n\n ${e .stacktrace }" ;
165
- }
166
- })];
167
- }
168
- return [false , null ];
147
+ // TODO: replace with isInterface(value, Getter) when dart:mirrors
148
+ // can support mixins.
149
+ try {
150
+ // containsKey() might not return a boolean, so explicitly test
151
+ // against true.
152
+ if (value.containsKey (childKey) == true ) {
153
+ return [true , value[childKey]];
169
154
}
155
+ } on NoSuchMethodError catch (e) {}
156
+
157
+ InstanceMirror instanceMirror = reflect (value);
158
+ Symbol curSym = new Symbol (childKey);
159
+ try {
160
+ // maybe it is a member field?
161
+ return [true , instanceMirror.getField (curSym).reflectee];
162
+ } catch (e) {
163
+ // maybe it is a member method?
164
+ if (instanceMirror.type.members.containsKey (curSym)) {
165
+ MethodMirror methodMirror = instanceMirror.type.members[curSym];
166
+ return [true , _relaxFnArgs ((args) {
167
+ if (args == null ) args = [];
168
+ try {
169
+ return instanceMirror.invoke (curSym, args).reflectee;
170
+ } catch (e) {
171
+ throw "$e \n\n ${e .stacktrace }" ;
172
+ }
173
+ })];
174
+ }
175
+ return [false , null ];
170
176
}
171
177
}
172
178
@@ -195,10 +201,13 @@ getter(scope, locals, path) {
195
201
}
196
202
197
203
setterChild (obj, childKey, value) {
198
- if (isInterface (obj, Setter )) {
204
+ // TODO: replace with isInterface(value, Setter) when dart:mirrors
205
+ // can support mixins.
206
+ try {
199
207
obj[childKey] = value;
200
208
return value;
201
- }
209
+ } on NoSuchMethodError catch (e) {}
210
+
202
211
InstanceMirror instanceMirror = reflect (obj);
203
212
Symbol curSym = new Symbol (childKey);
204
213
try {
0 commit comments