mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:21:18 +00:00
bed5debbeb
Fixes #32156 Fixes #32157 Fixes #32426 This also fixes `implements Function` so it has no effect in Dart 2 (it is ignored for the purposes of subtyping.) Change-Id: Ibec9c77cd516b8b97fef68a579998598d0acf8c6 Reviewed-on: https://dart-review.googlesource.com/45141 Commit-Queue: Jenny Messerly <jmesserly@google.com> Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Vijay Menon <vsm@google.com>
104 lines
2 KiB
Dart
104 lines
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 "dart:async";
|
|
import "package:expect/expect.dart";
|
|
|
|
class B {}
|
|
|
|
class C implements Function {
|
|
B call(B b) => b;
|
|
}
|
|
|
|
typedef B BToB(B x);
|
|
|
|
typedef Object NullToObject(Null x);
|
|
|
|
C c = new C();
|
|
|
|
void check1(BToB f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
B b = new B();
|
|
Expect.identical(f(b), b);
|
|
}
|
|
|
|
void check2(FutureOr<BToB> f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
BToB f2 = f;
|
|
B b = new B();
|
|
Expect.identical(f2(b), b);
|
|
}
|
|
|
|
void check3(NullToObject f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
Expect.isNull(f(null));
|
|
}
|
|
|
|
void check4(FutureOr<NullToObject> f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
NullToObject f2 = f;
|
|
Expect.isNull(f2(null));
|
|
}
|
|
|
|
void check5(Function f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
B b = new B();
|
|
Expect.identical(f(b), b);
|
|
}
|
|
|
|
void check6(FutureOr<Function> f) {
|
|
Expect.isFalse(identical(c, f));
|
|
Expect.equals(c.call, f);
|
|
B b = new B();
|
|
Function f2 = f;
|
|
Expect.identical(f2(b), b);
|
|
}
|
|
|
|
void check7(C x) {
|
|
Expect.identical(c, x);
|
|
}
|
|
|
|
void check8(FutureOr<C> x) {
|
|
Expect.identical(c, x);
|
|
}
|
|
|
|
void check9(Object o) {
|
|
Expect.identical(c, o);
|
|
}
|
|
|
|
void check10(FutureOr<Object> o) {
|
|
Expect.identical(c, o);
|
|
}
|
|
|
|
void check11(dynamic d) {
|
|
Expect.identical(c, d);
|
|
}
|
|
|
|
void check12(FutureOr<dynamic> d) {
|
|
Expect.identical(c, d);
|
|
}
|
|
|
|
main() {
|
|
// Implicitly tears off c.call
|
|
check1(c); //# 01: ok
|
|
check2(c); //# 02: ok
|
|
check3(c); //# 03: ok
|
|
check4(c); //# 04: ok
|
|
check5(c); //# 05: ok
|
|
check6(c); //# 06: ok
|
|
// Does not tear off c.call
|
|
check7(c); //# 07: ok
|
|
check8(c); //# 08: ok
|
|
check9(c); //# 09: ok
|
|
check10(c); //# 10: ok
|
|
check11(c); //# 11: ok
|
|
check12(c); //# 12: ok
|
|
}
|