mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:56:57 +00:00
fc1b1ecc71
Change-Id: Idbcc965a27e9ffeedf5e0a1068b019de4193070f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127745 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
79 lines
1.6 KiB
Dart
79 lines
1.6 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
// noSuchMethod does not overwrite actual implementations, so if an
|
|
// implemetation of a member exists that doesn't fulfill the interface it's
|
|
// an error.
|
|
// On the other hand, if no implementation exists,
|
|
// noSuchMethod will take its place and everything is okay.
|
|
|
|
class B {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 02: compile-time error
|
|
) =>
|
|
x;
|
|
}
|
|
|
|
class C extends B {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 01: compile-time error
|
|
);
|
|
bar();
|
|
|
|
noSuchMethod(i) {
|
|
print("No such method!");
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
abstract class D {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 03: ok
|
|
);
|
|
}
|
|
|
|
abstract class E {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 04: ok
|
|
);
|
|
}
|
|
|
|
class F extends D implements E {
|
|
noSuchMethod(i) {
|
|
print("No such method!");
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
class G {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 05: ok
|
|
) =>
|
|
x;
|
|
}
|
|
|
|
class H {
|
|
foo(int x, // force formatter to not combine these lines.
|
|
{int y} //# 06: compile-time error
|
|
) =>
|
|
x;
|
|
}
|
|
|
|
class I extends G implements H {
|
|
noSuchMethod(i) {
|
|
print("No such method: $i!");
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
main() {
|
|
var c = new C();
|
|
c.foo(123);
|
|
c.bar();
|
|
var f = new F();
|
|
f.foo(42);
|
|
var i = new I();
|
|
i.foo(42);
|
|
}
|