mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Add tests for method/local function signatures
Change-Id: I608303b91e0a4ed0d83130841719f0f5116102de Reviewed-on: https://dart-review.googlesource.com/52105 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
534268d017
commit
74a69a03c4
10 changed files with 622 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
method1() {
|
||||
/*needsSignature*/
|
||||
T local<T>(T t) => t;
|
||||
return local;
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is S Function<S>(S);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(method1()));
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
method1() {
|
||||
/*ast.*/
|
||||
/*kernel.*/
|
||||
/*strong.needsSignature*/
|
||||
num local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method2() {
|
||||
/*ast.*/
|
||||
/*kernel.*/
|
||||
/*strong.needsSignature*/
|
||||
num local(int n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method3() {
|
||||
/*ast.*/
|
||||
/*kernel.*/
|
||||
/*strong.needsSignature*/
|
||||
Object local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
/*class: Class2:needsArgs*/
|
||||
class Class2<T> {
|
||||
method4() {
|
||||
/*needsSignature*/
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
/*class: Class3:needsArgs*/
|
||||
class Class3<T> {
|
||||
method5() {
|
||||
/*needsSignature*/
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
/*ast.class: Class4:*/
|
||||
/*kernel.class: Class4:*/
|
||||
/*strong.class: Class4:needsArgs*/
|
||||
class Class4<T> {
|
||||
method6() {
|
||||
/*ast.*/
|
||||
/*kernel.*/
|
||||
/*strong.needsSignature*/
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(new Class1().method1()));
|
||||
Expect.isFalse(test(new Class1().method2()));
|
||||
Expect.isFalse(test(new Class1().method3()));
|
||||
Expect.isTrue(test(new Class2<num>().method4()));
|
||||
Expect.isTrue(test(new Class3<num>().method5()));
|
||||
Expect.isFalse(test(new Class4<num>().method6()));
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
method1() {
|
||||
/*needsSignature*/
|
||||
num local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method2() {
|
||||
/*needsSignature*/
|
||||
num local<T>(int n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method3() {
|
||||
/*needsSignature*/
|
||||
int local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
/*element: Class2.method4:needsArgs,selectors=[Selector(call, method4, arity=0, types=1)]*/
|
||||
method4<T>() {
|
||||
/*needsSignature*/
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
/*element: Class3.method5:needsArgs,selectors=[Selector(call, method5, arity=0, types=1)]*/
|
||||
method5<T>() {
|
||||
/*needsSignature*/
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
/*element: Class4.method6:needsArgs,selectors=[Selector(call, method6, arity=0, types=1)]*/
|
||||
method6<T>() {
|
||||
/*needsSignature*/
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
/*element: method7:needsArgs*/
|
||||
method7<T>() {
|
||||
/*needsSignature*/
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
/*element: method8:needsArgs*/
|
||||
method8<T>() {
|
||||
/*needsSignature*/
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
/*element: method9:needsArgs*/
|
||||
method9<T>() {
|
||||
/*needsSignature*/
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method10() {
|
||||
/*needsSignature*/
|
||||
num local<T>(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method11() {
|
||||
/*needsSignature*/
|
||||
T local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method12() {
|
||||
/*needsSignature*/
|
||||
num local<T>(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method13() {
|
||||
/*needsSignature*/
|
||||
num local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method14() {
|
||||
/*needsSignature*/
|
||||
num local<T>(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method15() {
|
||||
/*needsSignature*/
|
||||
T local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isFalse(test(new Class1().method1()));
|
||||
Expect.isFalse(test(new Class1().method2()));
|
||||
Expect.isFalse(test(new Class1().method3()));
|
||||
Expect.isTrue(test(new Class2().method4<num>()));
|
||||
Expect.isTrue(test(new Class3().method5<num>()));
|
||||
Expect.isFalse(test(new Class4().method6<num>()));
|
||||
Expect.isTrue(test(method7<num>()));
|
||||
Expect.isTrue(test(method8<num>()));
|
||||
Expect.isFalse(test(method9()));
|
||||
Expect.isFalse(test(method10()));
|
||||
Expect.isFalse(test(method11()));
|
||||
Expect.isFalse(test(method12()));
|
||||
Expect.isTrue(test(method13()));
|
||||
Expect.isTrue(test(method14()));
|
||||
Expect.isTrue(test(method15()));
|
||||
}
|
58
tests/compiler/dart2js/rti/data/method_signatures.dart
Normal file
58
tests/compiler/dart2js/rti/data/method_signatures.dart
Normal file
|
@ -0,0 +1,58 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
/*element: Class1.method1:*/
|
||||
num method1(num n) => null;
|
||||
|
||||
/*element: Class1.method2:*/
|
||||
num method2(int n) => null;
|
||||
|
||||
/*element: Class1.method3:*/
|
||||
Object method3(num n) => null;
|
||||
}
|
||||
|
||||
/*class: Class2:needsArgs*/
|
||||
class Class2<T> {
|
||||
/*element: Class2.method4:needsSignature*/
|
||||
num method4(T n) => null;
|
||||
}
|
||||
|
||||
/*class: Class3:needsArgs*/
|
||||
class Class3<T> {
|
||||
/*element: Class3.method5:needsSignature*/
|
||||
T method5(num n) => null;
|
||||
}
|
||||
|
||||
/*class: Class4:*/
|
||||
class Class4<T> {
|
||||
/*element: Class4.method6:*/
|
||||
num method6(num n, T t) => null;
|
||||
}
|
||||
|
||||
/*element: method7:*/
|
||||
num method7(num n) => null;
|
||||
|
||||
/*element: method8:*/
|
||||
num method8(int n) => null;
|
||||
|
||||
/*element: method9:*/
|
||||
Object method9(num n) => null;
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(new Class1().method1));
|
||||
Expect.isFalse(test(new Class1().method2));
|
||||
Expect.isFalse(test(new Class1().method3));
|
||||
Expect.isTrue(test(new Class2<num>().method4));
|
||||
Expect.isTrue(test(new Class3<num>().method5));
|
||||
Expect.isFalse(test(new Class4<num>().method6));
|
||||
Expect.isTrue(test(method7));
|
||||
Expect.isFalse(test(method8));
|
||||
Expect.isFalse(test(method9));
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
/*element: Class1.method1:*/
|
||||
num method1<T>(num n) => null;
|
||||
|
||||
/*element: Class1.method2:*/
|
||||
num method2<T>(int n) => null;
|
||||
|
||||
/*element: Class1.method3:*/
|
||||
int method3<T>(num n) => null;
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
/*element: Class2.method4:*/
|
||||
num method4<T>(T n) => null;
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
/*element: Class3.method5:*/
|
||||
T method5<T>(num n) => null;
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
/*element: Class4.method6:*/
|
||||
num method6<T>(num n, T t) => null;
|
||||
}
|
||||
|
||||
/*element: method7:*/
|
||||
num method7<T>(T n) => null;
|
||||
|
||||
/*element: method8:*/
|
||||
T method8<T>(num n) => null;
|
||||
|
||||
/*element: method9:*/
|
||||
num method9<T>(num n, T t) => null;
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
forceInstantiation(num Function(num) f) => f;
|
||||
|
||||
main() {
|
||||
Expect.isFalse(test(new Class1().method1));
|
||||
Expect.isFalse(test(new Class1().method2));
|
||||
Expect.isFalse(test(new Class1().method3));
|
||||
Expect.isTrue(test(forceInstantiation(new Class2().method4)));
|
||||
Expect.isTrue(test(forceInstantiation(new Class3().method5)));
|
||||
Expect.isFalse(test(new Class4().method6));
|
||||
Expect.isTrue(test(forceInstantiation(method7)));
|
||||
Expect.isTrue(test(forceInstantiation(method8)));
|
||||
Expect.isFalse(test(method9));
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// 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.
|
||||
|
||||
// dart2jsOptions=--strong
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
method1() {
|
||||
T local<T>(T t) => t;
|
||||
return local;
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is S Function<S>(S);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(method1()));
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
// 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.
|
||||
|
||||
// dart2jsOptions=--strong
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
method1() {
|
||||
num local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method2() {
|
||||
num local<T>(int n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method3() {
|
||||
int local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
method4<T>() {
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
method5<T>() {
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
method6<T>() {
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
method7<T>() {
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method8<T>() {
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method9<T>() {
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method10() {
|
||||
num local<T>(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method11() {
|
||||
T local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method12() {
|
||||
num local<T>(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method13() {
|
||||
num local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method14() {
|
||||
num local<T>(T n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
num Function(num) method15() {
|
||||
T local<T>(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isFalse(test(new Class1().method1()));
|
||||
Expect.isFalse(test(new Class1().method2()));
|
||||
Expect.isFalse(test(new Class1().method3()));
|
||||
Expect.isTrue(test(new Class2().method4<num>()));
|
||||
Expect.isTrue(test(new Class3().method5<num>()));
|
||||
Expect.isFalse(test(new Class4().method6<num>()));
|
||||
Expect.isTrue(test(method7<num>()));
|
||||
Expect.isTrue(test(method8<num>()));
|
||||
Expect.isFalse(test(method9()));
|
||||
Expect.isFalse(test(method10()));
|
||||
Expect.isFalse(test(method11()));
|
||||
Expect.isFalse(test(method12()));
|
||||
Expect.isTrue(test(method13()));
|
||||
Expect.isTrue(test(method14()));
|
||||
Expect.isTrue(test(method15()));
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
// 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.
|
||||
|
||||
// dart2jsOptions=--strong
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
method1() {
|
||||
num local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method2() {
|
||||
num local(int n) => null;
|
||||
return local;
|
||||
}
|
||||
|
||||
method3() {
|
||||
Object local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class2<T> {
|
||||
method4() {
|
||||
num local(T n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class3<T> {
|
||||
method5() {
|
||||
T local(num n) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
class Class4<T> {
|
||||
method6() {
|
||||
num local(num n, T t) => null;
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(new Class1().method1()));
|
||||
Expect.isFalse(test(new Class1().method2()));
|
||||
Expect.isFalse(test(new Class1().method3()));
|
||||
Expect.isTrue(test(new Class2<num>().method4()));
|
||||
Expect.isTrue(test(new Class3<num>().method5()));
|
||||
Expect.isFalse(test(new Class4<num>().method6()));
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
// 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.
|
||||
|
||||
// dart2jsOptions=--strong
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
num method1<T>(num n) => null;
|
||||
|
||||
num method2<T>(int n) => null;
|
||||
|
||||
int method3<T>(num n) => null;
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
num method4<T>(T n) => null;
|
||||
}
|
||||
|
||||
class Class3 {
|
||||
T method5<T>(num n) => null;
|
||||
}
|
||||
|
||||
class Class4 {
|
||||
num method6<T>(num n, T t) => null;
|
||||
}
|
||||
|
||||
num method7<T>(T n) => null;
|
||||
|
||||
T method8<T>(num n) => null;
|
||||
|
||||
num method9<T>(num n, T t) => null;
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
forceInstantiation(num Function(num) f) => f;
|
||||
|
||||
main() {
|
||||
Expect.isFalse(test(new Class1().method1));
|
||||
Expect.isFalse(test(new Class1().method2));
|
||||
Expect.isFalse(test(new Class1().method3));
|
||||
Expect.isTrue(test(forceInstantiation(new Class2().method4)));
|
||||
Expect.isTrue(test(forceInstantiation(new Class3().method5)));
|
||||
Expect.isFalse(test(new Class4().method6));
|
||||
Expect.isTrue(test(forceInstantiation(method7)));
|
||||
Expect.isTrue(test(forceInstantiation(method8)));
|
||||
Expect.isFalse(test(method9));
|
||||
}
|
48
tests/compiler/dart2js_extra/method_signatures_test.dart
Normal file
48
tests/compiler/dart2js_extra/method_signatures_test.dart
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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.
|
||||
|
||||
// dart2jsOptions=--strong
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class Class1 {
|
||||
num method1(num n) => null;
|
||||
|
||||
num method2(int n) => null;
|
||||
|
||||
Object method3(num n) => null;
|
||||
}
|
||||
|
||||
class Class2<T> {
|
||||
num method4(T n) => null;
|
||||
}
|
||||
|
||||
class Class3<T> {
|
||||
T method5(num n) => null;
|
||||
}
|
||||
|
||||
class Class4<T> {
|
||||
num method6(num n, T t) => null;
|
||||
}
|
||||
|
||||
num method7(num n) => null;
|
||||
|
||||
num method8(int n) => null;
|
||||
|
||||
Object method9(num n) => null;
|
||||
|
||||
@NoInline()
|
||||
test(o) => o is num Function(num);
|
||||
|
||||
main() {
|
||||
Expect.isTrue(test(new Class1().method1));
|
||||
Expect.isFalse(test(new Class1().method2));
|
||||
Expect.isFalse(test(new Class1().method3));
|
||||
Expect.isTrue(test(new Class2<num>().method4));
|
||||
Expect.isTrue(test(new Class3<num>().method5));
|
||||
Expect.isFalse(test(new Class4<num>().method6));
|
||||
Expect.isTrue(test(method7));
|
||||
Expect.isFalse(test(method8));
|
||||
Expect.isFalse(test(method9));
|
||||
}
|
Loading…
Reference in a new issue