mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
739852d99d
Change-Id: I3356296e72dfa07b0ac994da0ce96f766b182e80 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137722 Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
42 lines
1.2 KiB
Dart
42 lines
1.2 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.
|
|
// Dart test program to test arithmetic operations.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class C {
|
|
void Function() get call => () {};
|
|
}
|
|
|
|
class D {
|
|
get call => this;
|
|
}
|
|
|
|
// Recurs outside the try-block to avoid disabling inlining.
|
|
callD() {
|
|
dynamic d = new D();
|
|
d();
|
|
}
|
|
|
|
main() {
|
|
C c = new C();
|
|
dynamic d = c;
|
|
|
|
// The presence of a getter named `call` does not permit the class `C` to be
|
|
// implicitly called.
|
|
c(); //# 01: compile-time error
|
|
// Nor does it permit an implicit tear-off of `call`.
|
|
void Function() f = c; //# 02: compile-time error
|
|
// Nor does it permit a dynamic invocation of `call`.
|
|
Expect.throws(() => d()); //# 03: ok
|
|
// Same as previous line, but with a getter that can stack overflow if
|
|
// incorrect behavior is present. Merged from issue21159_test.
|
|
Expect.throwsNoSuchMethodError(() => callD()); //# 03: ok
|
|
|
|
// However, all these things are possible if `call` is mentioned explicitly.
|
|
c.call(); //# 04: ok
|
|
void Function() f = c.call; //# 05: ok
|
|
d.call(); //# 06: ok
|
|
}
|