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

Side by Side Diff: pkg/kernel/testcases/reify/generic_methods_local_variable_declaration_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 type variable can be used to declare local variables, and that
6 // these local variables are of correct type.
7
8 library generic_methods_local_variable_declaration_test;
9
10 import "test_base.dart";
11
12 class X {}
13
14 abstract class Generator<T> {
15 T generate();
16 }
17
18 class A implements Generator<A> {
19 generate() {
20 return new A();
21 }
22
23 String toString() => "instance of A";
24 }
25
26 class B implements Generator<B> {
27 generate() {
28 return new B();
29 }
30
31 String toString() => "instance of B";
32 }
33
34 String fun<T extends Generator<T>>(T t) {
35 T another = t.generate();
36 String anotherName = "$another";
37
38 expectTrue(another is T);
39 expectTrue(another is Generator<T>);
40
41 return anotherName;
42 }
43
44 main() {
45 A a = new A();
46 B b = new B();
47
48 expectTrue(fun<A>(a) == "instance of A");
49 expectTrue(fun<B>(b) == "instance of B");
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698