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

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

Issue 146733003: Handle type checking of generic compile time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for language/const_constructor3_test Created 6 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 // Regression test for issue 14348.
6
7 class A<T> {
8 const A();
9 }
10
11 class B<S> extends A<S> {
12 const B();
13 }
14
15 class C<U> {
16 final A<U> a;
17
18 const C(A<U> this.a);
19 const C.optional([A<U> this.a]);
20 const C.named({A<U> this.a});
21 const C.untyped(this.a);
22 const C.subtyped(B<U> this.a);
23 const factory C.redirecting(B<U> a) = D;
24 }
25
26 class D extends C {
27 const D(B b) : super(b);
28 }
29
30 class E {
31 const factory E.redirecting1(var a) = F<int>;
32 const factory E.redirecting2(var a) = F<int>.redirecting;
33 const factory E.redirecting3(var a) = F<double>.redirecting;
34 }
35
36 class F<V> implements E {
37 final V field;
38
39 const F(this.field);
40 const factory F.redirecting(V field) = G<int>;
41 }
42
43 class G<W> implements F {
44 final field;
45 const G(W this.field);
46 }
47
48 main() {
49 const A<int> a = const B<int>();
50
51 const C c1 = const C(a); /// 01: ok
52 const C c2 = const C.optional(a); /// 02: ok
53 const C c3 = const C.named(a: a); /// 03: ok
54 const C c4 = const C.untyped(a); /// 04: ok
55 const C c5 = const C.subtyped(a); /// 05: ok
56 const C c5m = const C.redirecting(a); /// 06: ok
57
58 const C c6 = const C<int>(a); /// 07: ok
59 const C c7 = const C<int>.optional(a); /// 08: ok
60 const C c8 = const C<int>.named(a: a); /// 09: ok
61 const C c9 = const C<int>.untyped(a); /// 10: ok
62 const C c10 = const C<int>.subtyped(a); /// 11: ok
63 const C c10m = const C<int>.redirecting(a); /// 12: ok
64
65 const C c11 = const C<double>(a); /// 13: static type warning, checked mode co mpile-time error
66 const C c12 = const C<double>.optional(a); /// 14: static type warning, checke d mode compile-time error
67 const C c13 = const C<double>.named(a: a); /// 15: static type warning, checke d mode compile-time error
68 const C c14 = const C<double>.untyped(a); /// 16: static type warning, checked mode compile-time error
69 const C c15 = const C<double>.subtyped(a); /// 17: static type warning, checke d mode compile-time error
70 const C c15m = const C<double>.redirecting(a); /// 18: static type warning
71
72 const E e1 = const E.redirecting1(0); /// 19: ok
73 const E e2 = const E.redirecting1(''); /// 20: checked mode compile-time error
74 const E e3 = const E.redirecting2(0); /// 21: ok
75 const E e4 = const E.redirecting2(''); /// 22: checked mode compile-time error
76 const E e5 = const E.redirecting3(0); /// 23: ok
77 const E e6 = const E.redirecting3(''); /// 24: checked mode compile-time error
78 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compile_time_constants.dart ('k') | tests/language/language_analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698