mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
05ca544f15
Change-Id: Iaa0ca2b4f2d1b15f79ddca37834d3ed2497bc068 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149242 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
55 lines
1.5 KiB
Dart
55 lines
1.5 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 = 2.7
|
|
|
|
// dart2jsOptions=--strong
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
// This needs one-arg instantiation.
|
|
@pragma('dart2js:noInline')
|
|
T f1a<T>(T t) => t;
|
|
|
|
// This needs no instantiation because it is not closurized.
|
|
@pragma('dart2js:noInline')
|
|
T f1b<T>(T t1, T t2) => t1;
|
|
|
|
class Class {
|
|
// This needs two-arg instantiation.
|
|
@pragma('dart2js:noInline')
|
|
bool f2a<T, S>(T t, S s) => t == s;
|
|
|
|
// This needs no instantiation because it is not closurized.
|
|
@pragma('dart2js:noInline')
|
|
bool f2b<T, S>(T t, S s1, S s2) => t == s1;
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
int method1(int i, int Function(int) f) => f(i);
|
|
|
|
@pragma('dart2js:noInline')
|
|
bool method2(int a, int b, bool Function(int, int) f) => f(a, b);
|
|
|
|
@pragma('dart2js:noInline')
|
|
int method3(int a, int b, int c, int Function(int, int, int) f) => f(a, b, c);
|
|
|
|
main() {
|
|
// This needs three-arg instantiation.
|
|
T local1<T, S, U>(T t, S s, U u) => t;
|
|
|
|
// This needs no instantiation because but a local function is always
|
|
// closurized so we assume it does.
|
|
T local2<T, S, U>(T t, S s, U u1, U u2) => t;
|
|
|
|
Expect.equals(42, method1(42, f1a));
|
|
Expect.equals(f1b(42, 87), 42);
|
|
|
|
Class c = new Class();
|
|
Expect.isFalse(method2(0, 1, c.f2a));
|
|
Expect.isFalse(c.f2b(42, 87, 123));
|
|
|
|
Expect.equals(0, method3(0, 1, 2, local1));
|
|
Expect.equals(42, local2(42, 87, 123, 256));
|
|
}
|