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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 23503035: Emit a compile-time error on const constructors with a body. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of dart2js; 5 part of dart2js;
6 6
7 const DONT_KNOW_HOW_TO_FIX = ""; 7 const DONT_KNOW_HOW_TO_FIX = "";
8 8
9 /** 9 /**
10 * The messages in this file should meet the following guide lines: 10 * The messages in this file should meet the following guide lines:
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 static const MessageKind INVALID_INITIALIZER = const MessageKind( 234 static const MessageKind INVALID_INITIALIZER = const MessageKind(
235 'Error: Invalid initializer.'); 235 'Error: Invalid initializer.');
236 236
237 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind( 237 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind(
238 'Error: Only constructors can have initializers.'); 238 'Error: Only constructors can have initializers.');
239 239
240 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( 240 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind(
241 'Error: Cyclic constructor redirection.'); 241 'Error: Cyclic constructor redirection.');
242 242
243 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( 243 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind(
244 'Error: Redirecting constructor cannot have a body.'); 244 "Error: Redirecting constructor can't have a body.");
245
246 static const MessageKind CONST_CONSTRUCTOR_HAS_BODY = const MessageKind(
247 "Error: Const constructor or factory can't have a body.",
248 howToFix: "Remove the 'const' keyword or the body",
249 examples: const ["""
250 class C {
251 const C() {}
252 }
253
254 main() => new C();"""]);
245 255
246 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = 256 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER =
247 const MessageKind( 257 const MessageKind(
248 'Error: Redirecting constructor cannot have other initializers.'); 258 'Error: Redirecting constructor cannot have other initializers.');
249 259
250 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind( 260 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind(
251 'Error: "Object" cannot have a super initializer.'); 261 'Error: "Object" cannot have a super initializer.');
252 262
253 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind( 263 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind(
254 'Error: Cannot have more than one super initializer.'); 264 'Error: Cannot have more than one super initializer.');
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( 504 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind(
495 'Error: Operator "#{operatorName}" cannot have optional parameters.'); 505 'Error: Operator "#{operatorName}" cannot have optional parameters.');
496 506
497 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind( 507 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind(
498 'Error: Operator "#{operatorName}" cannot have named parameters.'); 508 'Error: Operator "#{operatorName}" cannot have named parameters.');
499 509
500 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( 510 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind(
501 'Error: Cannot have return type for constructor.'); 511 'Error: Cannot have return type for constructor.');
502 512
503 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind( 513 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind(
504 "Error: Cannot return a value from a constructor.", 514 "Error: Constructors can't return values.",
505 howToFix: "Remove the return statement or use a factory constructor.", 515 howToFix: "Remove the return statement or use a factory constructor.",
506 examples: const [""" 516 examples: const ["""
507 class C { 517 class C {
508 C() { 518 C() {
509 return 1; 519 return 1;
510 } 520 }
511 } 521 }
512 522
513 main() => new C();"""]); 523 main() => new C();"""]);
514 524
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1047
1038 class CompileTimeConstantError extends Diagnostic { 1048 class CompileTimeConstantError extends Diagnostic {
1039 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1049 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1040 : super(kind, arguments, terse); 1050 : super(kind, arguments, terse);
1041 } 1051 }
1042 1052
1043 class CompilationError extends Diagnostic { 1053 class CompilationError extends Diagnostic {
1044 CompilationError(MessageKind kind, Map arguments, bool terse) 1054 CompilationError(MessageKind kind, Map arguments, bool terse)
1045 : super(kind, arguments, terse); 1055 : super(kind, arguments, terse);
1046 } 1056 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698