OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Checks that noSuchMethod is resolved in the super class and not in the | 5 // Checks that noSuchMethod is resolved in the super class and not in the |
6 // current class. | 6 // current class. |
7 | 7 |
8 class C { | 8 class C { |
| 9 E e = new E(); |
| 10 |
9 bool noSuchMethod(InvocationMirror im) { | 11 bool noSuchMethod(InvocationMirror im) { |
10 return true; | 12 if (im.memberName == 'foo') { |
| 13 return im.positionalArguments.isEmpty && |
| 14 im.namedArguments.isEmpty && |
| 15 im.invokeOn(e); |
| 16 } |
| 17 if (im.memberName == 'bar') { |
| 18 return im.positionalArguments.length == 1 && |
| 19 im.namedArguments.isEmpty && |
| 20 im.invokeOn(e); |
| 21 } |
| 22 if (im.memberName == 'baz') { |
| 23 return im.positionalArguments.isEmpty && |
| 24 im.namedArguments.length == 1 && |
| 25 im.invokeOn(e); |
| 26 } |
| 27 if (im.memberName == 'boz') { |
| 28 return im.positionalArguments.length == 1 && |
| 29 im.namedArguments.length == 1 && |
| 30 im.invokeOn(e); |
| 31 } |
| 32 return false; |
11 } | 33 } |
12 } | 34 } |
13 | 35 |
14 class D extends C { | 36 class D extends C { |
15 bool noSuchMethod(InvocationMirror im) { | 37 bool noSuchMethod(InvocationMirror im) { |
16 return false; | 38 return false; |
17 } | 39 } |
18 test() { | 40 test1() { |
19 return super.foo(); | 41 return super.foo(); |
20 } | 42 } |
| 43 test2() { |
| 44 return super.bar(1); |
| 45 } |
| 46 test3() { |
| 47 return super.baz(b: 2); |
| 48 } |
| 49 test4() { |
| 50 return super.boz(1, c: 2); |
| 51 } |
| 52 } |
| 53 |
| 54 class E { |
| 55 bool foo() => true; |
| 56 bool bar(int a) => a == 1; |
| 57 bool baz({int b}) => b == 2; |
| 58 bool boz(int a, {int c}) => a == 1 && c == 2; |
21 } | 59 } |
22 | 60 |
23 main() { | 61 main() { |
24 var d = new D(); | 62 var d = new D(); |
25 Expect.isTrue(d.test()); | 63 Expect.isTrue(d.test1()); |
| 64 Expect.isTrue(d.test2()); |
| 65 Expect.isTrue(d.test3()); |
| 66 Expect.isTrue(d.test4()); |
26 } | 67 } |
OLD | NEW |