This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree 3 files changed +23
-4
lines changed
3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ main(arguments) {
90
90
'a().name' ,
91
91
'a[x()]()' ,
92
92
'boo' ,
93
+ 'getNoSuchMethod' ,
93
94
'[].count(' ,
94
95
'false' ,
95
96
'false && run()' ,
Original file line number Diff line number Diff line change @@ -89,10 +89,14 @@ abstract class AccessReflective {
89
89
_cachedValue = mirror;
90
90
return result;
91
91
} on NoSuchMethodError catch (e) {
92
- var result = createInvokeClosure (mirror, symbol);
93
- if (result == null ) rethrow ;
94
- _cachedKind = CACHED_VALUE ;
95
- return _cachedValue = result;
92
+ if (isNoSuchMethodDueToGetField (e)) {
93
+ var result = createInvokeClosure (mirror, symbol);
94
+ if (result == null ) rethrow ;
95
+ _cachedKind = CACHED_VALUE ;
96
+ return _cachedValue = result;
97
+ } else {
98
+ rethrow ;
99
+ }
96
100
} on UnsupportedError catch (e) {
97
101
var result = createInvokeClosure (mirror, symbol);
98
102
if (result == null ) rethrow ;
@@ -101,6 +105,12 @@ abstract class AccessReflective {
101
105
}
102
106
}
103
107
108
+ bool isNoSuchMethodDueToGetField (NoSuchMethodError e) {
109
+ var msg = e.toString ();
110
+ return msg.indexOf ("has no instance getter '$name '." ) != - 1 || // Dart VM
111
+ msg.indexOf ('Cannot call "$name \$ ' ) != - 1 ; // Dart2JS
112
+ }
113
+
104
114
_assign (scope, holder, value) {
105
115
if (holder is Map ) {
106
116
holder[name] = value;
Original file line number Diff line number Diff line change @@ -286,6 +286,13 @@ main() {
286
286
});
287
287
288
288
289
+ it ('should pass noSuchMethExceptions through getters' , () {
290
+ expect (() {
291
+ parser ('getNoSuchMethod' ).eval (new ScopeWithErrors ());
292
+ }).toThrow ("iDontExist" );
293
+ });
294
+
295
+
289
296
it ('should pass exceptions through methods' , () {
290
297
expect (() {
291
298
parser ('foo()' ).eval (new ScopeWithErrors ());
@@ -936,6 +943,7 @@ class BracketButNotMap {
936
943
class ScopeWithErrors {
937
944
String get boo { throw "boo to you" ; }
938
945
String foo () { throw "foo to you" ; }
946
+ get getNoSuchMethod => null .iDontExist ();
939
947
}
940
948
941
949
@NgFilter (name: 'increment' )
You can’t perform that action at this time.
0 commit comments