mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
84e3c8b50f
Closes https://github.com/dart-lang/sdk/pull/50920 GitOrigin-RevId: fa87531bd0f52b69485c9d02ff9e44a4a29c6a91 Change-Id: I0ae8574a5b77087895e004079f221201bb550cf3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278535 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: 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
|
|
// implementation 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);
|
|
}
|