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

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

Issue 10905109: Add named constructor name checking (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/parser.cc ('k') | tests/language/function_literals2_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) 2012, the Dart project authors. Please see the AUTHORS file 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 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 // VMOptions=--constructor_name_check
5 5
6 class A { 6 class A {
7 // Constructor may not be static. 7 // Constructor may not be static.
8 static A(); /// 00: compile-time error 8 static A(); /// 00: compile-time error
9 9
10 // Factory may not be static. 10 // Factory may not be static.
11 static factory A() { return null; } /// 01: compile-time error 11 static factory A() { return null; } /// 01: compile-time error
12 12
13 // Constructor may not be abstract. 13 // Constructor may not be abstract.
14 abstract A(); /// 02: compile-time error 14 abstract A(); /// 02: compile-time error
15 15
16 // Factory may not be abstract 16 // Factory may not be abstract
17 abstract factory A() { return null; } /// 03: compile-time error 17 abstract factory A() { return null; } /// 03: compile-time error
18
19 // Named constructor may not conflict with names of methods and fields.
20 var m;
21 A.m() { m = 0; } /// 04: compile-time error
22
23 set q(var value) { m = q; }
24 A.q(); /// 05: compile-time error
25
26 A.foo() : m = 0; /// 06: compile-time error
27 int foo(int a, int b) => a + b * m;
18 } 28 }
19 29
20 main() { 30 main() {
21 new A(); 31 new A();
22 } 32 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/function_literals2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698