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

Side by Side Diff: tests/language/factory_redirection_test.dart

Issue 10964058: Support redirecting factory constructors in the VM (issue 3969). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 class A<T> {
6 A() : x = null;
7
8 const A.constant(T x) : this.x = x;
siva 2012/09/24 20:51:35 const A.constant(this.x); ?
regis 2012/09/24 21:41:28 Done.
9
10 factory A.factory() {
11 return new B<Set>();
12 }
13
14 final T x;
15 }
16
17 class B<T> extends A<T> {
18 B();
19
20 factory B.A() = A<T>;
21
22 const factory B.A_constant(T x) = A<T>.constant;
23
24 factory B.A_factory() = A<T>.factory;
25 }
26
27 class C<K, V> extends B<V> {
28 C();
29
30 factory C.A() = A<V>;
31
32 factory C.A_factory() = A<V>.factory;
siva 2012/09/24 20:51:35 Would it be legal here to redirect to A<K>.factory
regis 2012/09/24 21:41:28 Yes, it would. But you would need to call new C<bo
33
34 const factory C.B_constant(V x) = B<V>.A_constant;
35 }
36
37 main() {
38 Expect.isTrue(new A<List>() is A<List>);
39 Expect.isTrue(new A<bool>.constant(true).x);
40 Expect.isTrue(new A<List>.factory() is B<Set>);
41 Expect.isTrue(new B<List>.A() is A<List>);
42 Expect.isTrue(new B<bool>.A_constant(true).x);
43 Expect.isTrue(new B<List>.A_factory() is B<Set>);
44 Expect.isTrue(new C<String, num>.A() is A<num>);
45 Expect.isTrue(new C<String, num>.A_factory() is B<Set>);
46 Expect.isTrue(new C<String, bool>.B_constant(true).x);
47 }
OLDNEW
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698