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

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

Issue 2953843003: Reintroducing parser changes to cause compile-time errors when trying to reinitialize a final field… (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | tests/language/final_attempt_reinitialization_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class C { 7 class C {
8 // Since this field is final and already initialized, the specification says 8 // Since this field is final and already initialized, the specification says
9 // that a runtime error occurs when attempting to initialize it in the 9 // that a runtime error occurs when attempting to initialize it in the
10 // constructor. When used as a compile-time constant, this causes a 10 // constructor. When used as a compile-time constant, this causes a
11 // compile-time error. 11 // compile-time error.
12 final x = 1; 12 final x = 1;
13 13
14 const C( 14 const C(
15 this. //# 01: compile-time error 15 this. //# 01: compile-time error
16 this. //# 02: static type warning 16 this. //# 02: compile-time error
17 x 17 x
18 ) 18 )
19 : x = 2 //# 03: compile-time error 19 : x = 2 //# 03: compile-time error
20 : x = 2 //# 04: static type warning 20 : x = 2 //# 04: compile-time error
21 ; 21 ;
22 } 22 }
23 23
24 instantiateC() { 24 instantiateC() {
25 const C(0); //# 01: continued 25 const C(0); //# 01: continued
26 const C(0); //# 03: continued 26 const C(0); //# 03: continued
27 new C(0); 27 new C(0);
28 } 28 }
29 29
30 main() { 30 main() {
31 bool shouldThrow = false; 31 bool shouldThrow = false;
32 shouldThrow = true; //# 02: continued 32 shouldThrow = true; //# 02: continued
33 shouldThrow = true; //# 04: continued 33 shouldThrow = true; //# 04: continued
34 if (shouldThrow) { 34 if (shouldThrow) {
35 Expect.throws(instantiateC); 35 Expect.throws(instantiateC());
36 } else { 36 } else {
37 instantiateC(); 37 instantiateC();
38 } 38 }
39 } 39 }
OLDNEW
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | tests/language/final_attempt_reinitialization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698