Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: pkg/kernel/testcases/reify/generic_methods_generic_class_tearoff_test.dart

Issue 2756693002: Add generic-methods 'golden' tests for 'reify' transformation (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test that a torn off method of a generic class is not a generic method,
6 // and that it is correctly specialized.
7
8 library generic_methods_generic_class_tearoff_test;
9
10 import "test_base.dart";
11
12 class A<T> {
13 T fun(T t) => t;
14 }
15
16 typedef Int2Int = int Function(int);
17 typedef String2String = String Function(String);
18 typedef Object2Object = Object Function(Object);
19 typedef GenericMethod = T Function<T>(T);
20
21 main() {
22 A<int> x = new A<int>();
23 var f = x.fun; // The type of f should be 'int Function(Object)'.
24 A<String> y = new A<String>();
25 var g = y.fun; // The type of g should be 'String Function(Object)'.
26 A z = new A();
27 var h = z.fun; // The type of h should be 'dynamic Function(Object)'.
28
29 expectTrue(f is Int2Int);
30 expectTrue(f is! String2String);
31 expectTrue(f is Object2Object);
32 expectTrue(f is! GenericMethod);
33
34 expectTrue(g is! Int2Int);
35 expectTrue(g is String2String);
36 expectTrue(g is Object2Object);
37 expectTrue(g is! GenericMethod);
38
39 expectTrue(h is! Int2Int);
40 expectTrue(h is! String2String);
41 expectTrue(h is Object2Object);
42 expectTrue(h is! GenericMethod);
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698