This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -162,10 +162,18 @@ getterChild(value, childKey) {
162
162
InstanceMirror instanceMirror = reflect (value);
163
163
Symbol curSym = new Symbol (childKey);
164
164
165
+ // TODO(deboer): I don't like this try block.
166
+ // It should be replaced with a if(instanceMirror.hasField(curSym)) block.
167
+ // But hasField doesn't exist. Checking the variables + getters maps almost
168
+ // works, but it doesn't support mixins.
165
169
try {
166
170
// maybe it is a member field?
167
171
return [true , instanceMirror.getField (curSym).reflectee];
168
172
} on NoSuchMethodError catch (e) {
173
+ // TODO(deboer): I want a NoSuchInstanceGetter error instead.
174
+ if (! e.toString ().contains ('has no instance getter' )) {
175
+ rethrow ;
176
+ }
169
177
// maybe it is a member method?
170
178
if (instanceMirror.type.members.containsKey (curSym)) {
171
179
MethodMirror methodMirror = instanceMirror.type.members[curSym];
Original file line number Diff line number Diff line change @@ -426,6 +426,13 @@ main() {
426
426
Parser .parse ('foo()' )(new ScopeWithErrors ());
427
427
}).toThrow ('foo to you' );
428
428
});
429
+
430
+
431
+ it ('should throw on NoSuchMethod exceptions in getters' , () {
432
+ expect (() {
433
+ Parser .parse ('nsm' )(new NSMGetter ());
434
+ }).toThrow ('method not found: \' notAMethod\' ' );
435
+ });
429
436
});
430
437
431
438
describe ('setters' , () {
@@ -908,3 +915,8 @@ class ScopeWithErrors {
908
915
String get boo => throw "boo to you" ;
909
916
String foo () => throw "foo to you" ;
910
917
}
918
+
919
+ class NSMGetter {
920
+ var obj;
921
+ String get nsm => obj.notAMethod;
922
+ }
You can’t perform that action at this time.
0 commit comments