mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:51:18 +00:00
5d8b1a1d8c
Review URL: https://codereview.chromium.org//14251021 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21636 260f80e4-7a28-3924-810f-c04153c831b5
71 lines
1.7 KiB
Dart
71 lines
1.7 KiB
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "dart:mirrors" show reflect;
|
|
import "package:expect/expect.dart";
|
|
|
|
// Checks that noSuchMethod is resolved in the super class and not in the
|
|
// current class.
|
|
|
|
class C {
|
|
E e = new E();
|
|
|
|
bool noSuchMethod(Invocation im) {
|
|
if (im.memberName == const Symbol('foo')) {
|
|
return im.positionalArguments.isEmpty &&
|
|
im.namedArguments.isEmpty &&
|
|
reflect(e).delegate(im);
|
|
}
|
|
if (im.memberName == const Symbol('bar')) {
|
|
return im.positionalArguments.length == 1 &&
|
|
im.namedArguments.isEmpty &&
|
|
reflect(e).delegate(im);
|
|
}
|
|
if (im.memberName == const Symbol('baz')) {
|
|
return im.positionalArguments.isEmpty &&
|
|
im.namedArguments.length == 1 &&
|
|
reflect(e).delegate(im);
|
|
}
|
|
if (im.memberName == const Symbol('boz')) {
|
|
return im.positionalArguments.length == 1 &&
|
|
im.namedArguments.length == 1 &&
|
|
reflect(e).delegate(im);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
class D extends C {
|
|
bool noSuchMethod(Invocation im) {
|
|
return false;
|
|
}
|
|
test1() {
|
|
return super.foo();
|
|
}
|
|
test2() {
|
|
return super.bar(1);
|
|
}
|
|
test3() {
|
|
return super.baz(b: 2);
|
|
}
|
|
test4() {
|
|
return super.boz(1, c: 2);
|
|
}
|
|
}
|
|
|
|
class E {
|
|
bool foo() => true;
|
|
bool bar(int a) => a == 1;
|
|
bool baz({int b}) => b == 2;
|
|
bool boz(int a, {int c}) => a == 1 && c == 2;
|
|
}
|
|
|
|
main() {
|
|
var d = new D();
|
|
Expect.isTrue(d.test1());
|
|
Expect.isTrue(d.test2());
|
|
Expect.isTrue(d.test3());
|
|
Expect.isTrue(d.test4());
|
|
}
|