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

Side by Side Diff: mojo/public/dart/third_party/analyzer/lib/src/generated/error.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
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 library engine.error;
6
7 import 'dart:collection';
8
9 import 'ast.dart' show AstNode;
10 import 'element.dart';
11 import 'java_core.dart';
12 import 'scanner.dart' show Token;
13 import 'source.dart';
14
15 /**
16 * An error discovered during the analysis of some Dart code.
17 *
18 * See [AnalysisErrorListener].
19 */
20 class AnalysisError {
21 /**
22 * An empty array of errors used when no errors are expected.
23 */
24 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[];
25
26 /**
27 * A [Comparator] that sorts by the name of the file that the [AnalysisError]
28 * was found.
29 */
30 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1,
31 AnalysisError o2) => o1.source.shortName.compareTo(o2.source.shortName);
32
33 /**
34 * A [Comparator] that sorts error codes first by their severity (errors
35 * first, warnings second), and then by the the error code type.
36 */
37 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = (AnalysisError o1,
38 AnalysisError o2) {
39 ErrorCode errorCode1 = o1.errorCode;
40 ErrorCode errorCode2 = o2.errorCode;
41 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity;
42 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity;
43 if (errorSeverity1 == errorSeverity2) {
44 ErrorType errorType1 = errorCode1.type;
45 ErrorType errorType2 = errorCode2.type;
46 return errorType1.compareTo(errorType2);
47 } else {
48 return errorSeverity2.compareTo(errorSeverity1);
49 }
50 };
51
52 /**
53 * The error code associated with the error.
54 */
55 final ErrorCode errorCode;
56
57 /**
58 * The localized error message.
59 */
60 String _message;
61
62 /**
63 * The correction to be displayed for this error, or `null` if there is no
64 * correction information for this error.
65 */
66 String _correction;
67
68 /**
69 * The source in which the error occurred, or `null` if unknown.
70 */
71 Source source;
72
73 /**
74 * The character offset from the beginning of the source (zero based) where
75 * the error occurred.
76 */
77 int offset = 0;
78
79 /**
80 * The number of characters from the offset to the end of the source which
81 * encompasses the compilation error.
82 */
83 int length = 0;
84
85 /**
86 * A flag indicating whether this error can be shown to be a non-issue because
87 * of the result of type propagation.
88 */
89 bool isStaticOnly = false;
90
91 /**
92 * Initialize a newly created analysis error. The error is associated with the
93 * given [source] and is located at the given [offset] with the given
94 * [length]. The error will have the given [errorCode] and the list of
95 * [arguments] will be used to complete the message.
96 */
97 AnalysisError(this.source, this.offset, this.length, this.errorCode,
98 [List<Object> arguments]) {
99 this._message = formatList(errorCode.message, arguments);
100 String correctionTemplate = errorCode.correction;
101 if (correctionTemplate != null) {
102 this._correction = formatList(correctionTemplate, arguments);
103 }
104 }
105
106 /**
107 * Initialize a newly created analysis error for the specified [source]. The
108 * error will have the given [errorCode] and the list of [arguments] will be
109 * used to complete the message. The error has no location information.
110 */
111 @deprecated // Use new AnalysisError(source, 0, 0, errorCode, arguments)
112 AnalysisError.con1(Source source, ErrorCode errorCode,
113 [List<Object> arguments])
114 : this(source, 0, 0, errorCode, arguments);
115
116 /**
117 * Initialize a newly created analysis error for the specified [source] at the
118 * given [offset] with the given [length]. The error will have the given
119 * [errorCode] and the list of [arguments] will be used to complete the
120 * message.
121 */
122 @deprecated // Use new AnalysisError(source, offset, length, errorCode, argume nts)
123 AnalysisError.con2(Source source, int offset, int length, ErrorCode errorCode,
124 [List<Object> arguments])
125 : this(source, offset, length, errorCode, arguments);
126
127 /**
128 * Return the template used to create the correction to be displayed for this
129 * error, or `null` if there is no correction information for this error. The
130 * correction should indicate how the user can fix the error.
131 */
132 String get correction => _correction;
133
134 @override
135 int get hashCode {
136 int hashCode = offset;
137 hashCode ^= (_message != null) ? _message.hashCode : 0;
138 hashCode ^= (source != null) ? source.hashCode : 0;
139 return hashCode;
140 }
141
142 /**
143 * Return the message to be displayed for this error. The message should
144 * indicate what is wrong and why it is wrong.
145 */
146 String get message => _message;
147
148 @override
149 bool operator ==(Object obj) {
150 if (identical(obj, this)) {
151 return true;
152 }
153 // prepare other AnalysisError
154 if (obj is! AnalysisError) {
155 return false;
156 }
157 AnalysisError other = obj as AnalysisError;
158 // Quick checks.
159 if (!identical(errorCode, other.errorCode)) {
160 return false;
161 }
162 if (offset != other.offset || length != other.length) {
163 return false;
164 }
165 if (isStaticOnly != other.isStaticOnly) {
166 return false;
167 }
168 // Deep checks.
169 if (_message != other._message) {
170 return false;
171 }
172 if (source != other.source) {
173 return false;
174 }
175 // OK
176 return true;
177 }
178
179 /**
180 * Return the value of the given [property], or `null` if the given property
181 * is not defined for this error.
182 */
183 Object getProperty(ErrorProperty property) => null;
184
185 @override
186 String toString() {
187 StringBuffer buffer = new StringBuffer();
188 buffer.write((source != null) ? source.fullName : "<unknown source>");
189 buffer.write("(");
190 buffer.write(offset);
191 buffer.write("..");
192 buffer.write(offset + length - 1);
193 buffer.write("): ");
194 //buffer.write("(" + lineNumber + ":" + columnNumber + "): ");
195 buffer.write(_message);
196 return buffer.toString();
197 }
198
199 /**
200 * Merge all of the errors in the lists in the given list of [errorLists] into
201 * a single list of errors.
202 */
203 static List<AnalysisError> mergeLists(List<List<AnalysisError>> errorLists) {
204 Set<AnalysisError> errors = new HashSet<AnalysisError>();
205 for (List<AnalysisError> errorList in errorLists) {
206 errors.addAll(errorList);
207 }
208 return errors.toList();
209 }
210 }
211
212 /**
213 * An object that listen for [AnalysisError]s being produced by the analysis
214 * engine.
215 */
216 abstract class AnalysisErrorListener {
217 /**
218 * An error listener that ignores errors that are reported to it.
219 */
220 static final AnalysisErrorListener NULL_LISTENER =
221 new AnalysisErrorListener_NULL_LISTENER();
222
223 /**
224 * This method is invoked when an [error] has been found by the analysis
225 * engine.
226 */
227 void onError(AnalysisError error);
228 }
229
230 /**
231 * An [AnalysisErrorListener] that ignores error.
232 */
233 class AnalysisErrorListener_NULL_LISTENER implements AnalysisErrorListener {
234 @override
235 void onError(AnalysisError event) {
236 // Ignore errors
237 }
238 }
239
240 /**
241 * An [AnalysisError] that can have arbitrary properties associated with it.
242 */
243 class AnalysisErrorWithProperties extends AnalysisError {
244 /**
245 * The properties associated with this error.
246 */
247 HashMap<ErrorProperty, Object> _propertyMap =
248 new HashMap<ErrorProperty, Object>();
249
250 /**
251 * Initialize a newly created analysis error. The error is associated with the
252 * given [source] and is located at the given [offset] with the given
253 * [length]. The error will have the given [errorCode] and the list of
254 * [arguments] will be used to complete the message.
255 */
256 AnalysisErrorWithProperties(
257 Source source, int offset, int length, ErrorCode errorCode,
258 [List<Object> arguments])
259 : super(source, offset, length, errorCode, arguments);
260
261 /**
262 * Initialize a newly created analysis error for the specified [source]. The
263 * error will have the given [errorCode] and the list of [arguments] will be
264 * used to complete the message. The error has no location information.
265 */
266 @deprecated // Use new AnalysisErrorWithProperties(source, 0, 0, errorCode, ar guments)
267 AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode,
268 [List<Object> arguments])
269 : this(source, 0, 0, errorCode, arguments);
270
271 /**
272 * Initialize a newly created analysis error for the specified [source] at the
273 * given [offset] with the given [length]. The error will have the given
274 * [errorCode] and the list of [arguments] will be used to complete the
275 * message.
276 */
277 @deprecated // Use new AnalysisErrorWithProperties(source, offset, length, err orCode, arguments)
278 AnalysisErrorWithProperties.con2(
279 Source source, int offset, int length, ErrorCode errorCode,
280 [List<Object> arguments])
281 : this(source, offset, length, errorCode, arguments);
282
283 @override
284 Object getProperty(ErrorProperty property) => _propertyMap[property];
285
286 /**
287 * Set the value of the given [property] to the given [value]. Using a value
288 * of `null` will effectively remove the property from this error.
289 */
290 void setProperty(ErrorProperty property, Object value) {
291 _propertyMap[property] = value;
292 }
293 }
294
295 /**
296 * An [AnalysisErrorListener] that keeps track of whether any error has been
297 * reported to it.
298 */
299 class BooleanErrorListener implements AnalysisErrorListener {
300 /**
301 * A flag indicating whether an error has been reported to this listener.
302 */
303 bool _errorReported = false;
304
305 /**
306 * Return `true` if an error has been reported to this listener.
307 */
308 bool get errorReported => _errorReported;
309
310 @override
311 void onError(AnalysisError error) {
312 _errorReported = true;
313 }
314 }
315
316 /**
317 * The error codes used for compile time errors caused by constant evaluation
318 * that would throw an exception when run in checked mode. The client of the
319 * analysis engine is responsible for determining how these errors should be
320 * presented to the user (for example, a command-line compiler might elect to
321 * treat these errors differently depending whether it is compiling it "checked"
322 * mode).
323 */
324 class CheckedModeCompileTimeErrorCode extends ErrorCode {
325 // TODO(paulberry): improve the text of these error messages so that it's
326 // clear to the user that the error is coming from constant evaluation (and
327 // hence the constant needs to be a subtype of the annotated type) as opposed
328 // to static type analysis (which only requires that the two types be
329 // assignable). Also consider populating the "correction" field for these
330 // errors.
331
332 /**
333 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
334 * object results in an uncaught exception being thrown.
335 */
336 static const CheckedModeCompileTimeErrorCode CONST_CONSTRUCTOR_FIELD_TYPE_MISM ATCH =
337 const CheckedModeCompileTimeErrorCode(
338 'CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH',
339 "The object type '{0}' cannot be assigned to the field '{1}', which ha s type '{2}'");
340
341 /**
342 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
343 * object results in an uncaught exception being thrown.
344 */
345 static const CheckedModeCompileTimeErrorCode CONST_CONSTRUCTOR_PARAM_TYPE_MISM ATCH =
346 const CheckedModeCompileTimeErrorCode(
347 'CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH',
348 "The object type '{0}' cannot be assigned to a parameter of type '{1}' ");
349
350 /**
351 * 7.6.1 Generative Constructors: In checked mode, it is a dynamic type error
352 * if o is not <b>null</b> and the interface of the class of <i>o</i> is not a
353 * subtype of the static type of the field <i>v</i>.
354 *
355 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
356 * object results in an uncaught exception being thrown.
357 *
358 * Parameters:
359 * 0: the name of the type of the initializer expression
360 * 1: the name of the type of the field
361 */
362 static const CheckedModeCompileTimeErrorCode CONST_FIELD_INITIALIZER_NOT_ASSIG NABLE =
363 const CheckedModeCompileTimeErrorCode(
364 'CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE',
365 "The initializer type '{0}' cannot be assigned to the field type '{1}' ");
366
367 /**
368 * 12.6 Lists: A run-time list literal &lt;<i>E</i>&gt; [<i>e<sub>1</sub></i>
369 * ... <i>e<sub>n</sub></i>] is evaluated as follows:
370 * * The operator []= is invoked on <i>a</i> with first argument <i>i</i> and
371 * second argument <i>o<sub>i+1</sub></i><i>, 1 &lt;= i &lt;= n</i>
372 *
373 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
374 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
375 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
376 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
377 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>,
378 * 1 &lt;= j &lt;= m</i>.
379 */
380 static const CheckedModeCompileTimeErrorCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
381 const CheckedModeCompileTimeErrorCode('LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
382 "The element type '{0}' cannot be assigned to the list type '{1}'");
383
384 /**
385 * 12.7 Map: A run-time map literal &lt;<i>K</i>, <i>V</i>&gt;
386 * [<i>k<sub>1</sub></i> : <i>e<sub>1</sub></i> ... <i>k<sub>n</sub></i> :
387 * <i>e<sub>n</sub></i>] is evaluated as follows:
388 * * The operator []= is invoked on <i>m</i> with first argument
389 * <i>k<sub>i</sub></i> and second argument <i>e<sub>i</sub></i><i>, 1 &lt;=
390 * i &lt;= n</i>
391 *
392 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
393 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
394 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
395 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
396 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
397 * &lt;= j &lt;= m</i>.
398 */
399 static const CheckedModeCompileTimeErrorCode MAP_KEY_TYPE_NOT_ASSIGNABLE =
400 const CheckedModeCompileTimeErrorCode('MAP_KEY_TYPE_NOT_ASSIGNABLE',
401 "The element type '{0}' cannot be assigned to the map key type '{1}'") ;
402
403 /**
404 * 12.7 Map: A run-time map literal &lt;<i>K</i>, <i>V</i>&gt;
405 * [<i>k<sub>1</sub></i> : <i>e<sub>1</sub></i> ... <i>k<sub>n</sub></i> :
406 * <i>e<sub>n</sub></i>] is evaluated as follows:
407 * * The operator []= is invoked on <i>m</i> with first argument
408 * <i>k<sub>i</sub></i> and second argument <i>e<sub>i</sub></i><i>, 1 &lt;=
409 * i &lt;= n</i>
410 *
411 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
412 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
413 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
414 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
415 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
416 * &lt;= j &lt;= m</i>.
417 */
418 static const CheckedModeCompileTimeErrorCode MAP_VALUE_TYPE_NOT_ASSIGNABLE =
419 const CheckedModeCompileTimeErrorCode('MAP_VALUE_TYPE_NOT_ASSIGNABLE',
420 "The element type '{0}' cannot be assigned to the map value type '{1}' ");
421
422 /**
423 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
424 * object results in an uncaught exception being thrown.
425 */
426 static const CheckedModeCompileTimeErrorCode VARIABLE_TYPE_MISMATCH =
427 const CheckedModeCompileTimeErrorCode('VARIABLE_TYPE_MISMATCH',
428 "The object type '{0}' cannot be assigned to a variable of type '{1}'" );
429
430 /**
431 * Initialize a newly created error code to have the given [name]. The message
432 * associated with the error will be created from the given [message]
433 * template. The correction associated with the error will be created from the
434 * given [correction] template.
435 */
436 const CheckedModeCompileTimeErrorCode(String name, String message,
437 [String correction])
438 : super(name, message, correction);
439
440 @override
441 ErrorSeverity get errorSeverity =>
442 ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR.severity;
443
444 @override
445 ErrorType get type => ErrorType.CHECKED_MODE_COMPILE_TIME_ERROR;
446 }
447
448 /**
449 * The error codes used for compile time errors. The convention for this class
450 * is for the name of the error code to indicate the problem that caused the
451 * error to be generated and for the error message to explain what is wrong and,
452 * when appropriate, how the problem can be corrected.
453 */
454 class CompileTimeErrorCode extends ErrorCode {
455 /**
456 * Enum proposal: It is also a compile-time error to explicitly instantiate an
457 * enum via 'new' or 'const' or to access its private fields.
458 */
459 static const CompileTimeErrorCode ACCESS_PRIVATE_ENUM_FIELD =
460 const CompileTimeErrorCode('ACCESS_PRIVATE_ENUM_FIELD',
461 "The private fields of an enum cannot be accessed, even within the sam e library");
462
463 /**
464 * 14.2 Exports: It is a compile-time error if a name <i>N</i> is re-exported
465 * by a library <i>L</i> and <i>N</i> is introduced into the export namespace
466 * of <i>L</i> by more than one export, unless each all exports refer to same
467 * declaration for the name N.
468 *
469 * Parameters:
470 * 0: the name of the ambiguous element
471 * 1: the name of the first library that the type is found
472 * 2: the name of the second library that the type is found
473 */
474 static const CompileTimeErrorCode AMBIGUOUS_EXPORT =
475 const CompileTimeErrorCode('AMBIGUOUS_EXPORT',
476 "The name '{0}' is defined in the libraries '{1}' and '{2}'");
477
478 /**
479 * 12.33 Argument Definition Test: It is a compile time error if <i>v</i> does
480 * not denote a formal parameter.
481 *
482 * Parameters:
483 * 0: the name of the identifier in the argument definition test that is not a
484 * parameter
485 */
486 static const CompileTimeErrorCode ARGUMENT_DEFINITION_TEST_NON_PARAMETER =
487 const CompileTimeErrorCode(
488 'ARGUMENT_DEFINITION_TEST_NON_PARAMETER', "'{0}' is not a parameter");
489
490 /**
491 * ?? Asynchronous For-in: It is a compile-time error if an asynchronous
492 * for-in statement appears inside a synchronous function.
493 */
494 static const CompileTimeErrorCode ASYNC_FOR_IN_WRONG_CONTEXT =
495 const CompileTimeErrorCode('ASYNC_FOR_IN_WRONG_CONTEXT',
496 "The asynchronous for-in can only be used in a function marked with as ync or async*");
497
498 /**
499 * ??: It is a compile-time error if the function immediately enclosing a is
500 * not declared asynchronous.
501 */
502 static const CompileTimeErrorCode AWAIT_IN_WRONG_CONTEXT =
503 const CompileTimeErrorCode('AWAIT_IN_WRONG_CONTEXT',
504 "The await expression can only be used in a function marked as async o r async*");
505
506 /**
507 * 12.30 Identifier Reference: It is a compile-time error to use a built-in
508 * identifier other than dynamic as a type annotation.
509 */
510 static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE =
511 const CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPE',
512 "The built-in identifier '{0}' cannot be used as a type");
513
514 /**
515 * 12.30 Identifier Reference: It is a compile-time error if a built-in
516 * identifier is used as the declared name of a class, type parameter or type
517 * alias.
518 */
519 static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_NAME =
520 const CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPE_NAME',
521 "The built-in identifier '{0}' cannot be used as a type name");
522
523 /**
524 * 12.30 Identifier Reference: It is a compile-time error if a built-in
525 * identifier is used as the declared name of a class, type parameter or type
526 * alias.
527 */
528 static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME =
529 const CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME',
530 "The built-in identifier '{0}' cannot be used as a type alias name");
531
532 /**
533 * 12.30 Identifier Reference: It is a compile-time error if a built-in
534 * identifier is used as the declared name of a class, type parameter or type
535 * alias.
536 */
537 static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME =
538 const CompileTimeErrorCode('BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME',
539 "The built-in identifier '{0}' cannot be used as a type parameter name ");
540
541 /**
542 * 13.9 Switch: It is a compile-time error if the class <i>C</i> implements
543 * the operator <i>==</i>.
544 */
545 static const CompileTimeErrorCode CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS =
546 const CompileTimeErrorCode('CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS',
547 "The switch case expression type '{0}' cannot override the == operator ");
548
549 /**
550 * 12.1 Constants: It is a compile-time error if evaluation of a compile-time
551 * constant would raise
552 * an exception.
553 */
554 static const CompileTimeErrorCode COMPILE_TIME_CONSTANT_RAISES_EXCEPTION =
555 const CompileTimeErrorCode('COMPILE_TIME_CONSTANT_RAISES_EXCEPTION', "");
556
557 /**
558 * 7.2 Getters: It is a compile-time error if a class has both a getter and a
559 * method with the same name. This restriction holds regardless of whether the
560 * getter is defined explicitly or implicitly, or whether the getter or the
561 * method are inherited or not.
562 */
563 static const CompileTimeErrorCode CONFLICTING_GETTER_AND_METHOD =
564 const CompileTimeErrorCode('CONFLICTING_GETTER_AND_METHOD',
565 "Class '{0}' cannot have both getter '{1}.{2}' and method with the sam e name");
566
567 /**
568 * 7.2 Getters: It is a compile-time error if a class has both a getter and a
569 * method with the same name. This restriction holds regardless of whether the
570 * getter is defined explicitly or implicitly, or whether the getter or the
571 * method are inherited or not.
572 */
573 static const CompileTimeErrorCode CONFLICTING_METHOD_AND_GETTER =
574 const CompileTimeErrorCode('CONFLICTING_METHOD_AND_GETTER',
575 "Class '{0}' cannot have both method '{1}.{2}' and getter with the sam e name");
576
577 /**
578 * 7.6 Constructors: A constructor name always begins with the name of its
579 * immediately enclosing class, and may optionally be followed by a dot and an
580 * identifier <i>id</i>. It is a compile-time error if <i>id</i> is the name
581 * of a member declared in the immediately enclosing class.
582 */
583 static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD =
584 const CompileTimeErrorCode('CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD',
585 "'{0}' cannot be used to name a constructor and a field in this class" );
586
587 /**
588 * 7.6 Constructors: A constructor name always begins with the name of its
589 * immediately enclosing class, and may optionally be followed by a dot and an
590 * identifier <i>id</i>. It is a compile-time error if <i>id</i> is the name
591 * of a member declared in the immediately enclosing class.
592 */
593 static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD =
594 const CompileTimeErrorCode('CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD',
595 "'{0}' cannot be used to name a constructor and a method in this class ");
596
597 /**
598 * 7. Classes: It is a compile time error if a generic class declares a type
599 * variable with the same name as the class or any of its members or
600 * constructors.
601 */
602 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_CLASS =
603 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_CLASS',
604 "'{0}' cannot be used to name a type varaible in a class with the same name");
605
606 /**
607 * 7. Classes: It is a compile time error if a generic class declares a type
608 * variable with the same name as the class or any of its members or
609 * constructors.
610 */
611 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER =
612 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
613 "'{0}' cannot be used to name a type varaible and member in this class ");
614
615 /**
616 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
617 * object results in an uncaught exception being thrown.
618 */
619 static const CompileTimeErrorCode CONST_CONSTRUCTOR_THROWS_EXCEPTION =
620 const CompileTimeErrorCode('CONST_CONSTRUCTOR_THROWS_EXCEPTION',
621 "'const' constructors cannot throw exceptions");
622
623 /**
624 * 10.6.3 Constant Constructors: It is a compile-time error if a constant
625 * constructor is declared by a class C if any instance variable declared in C
626 * is initialized with an expression that is not a constant expression.
627 */
628 static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_ NON_CONST =
629 const CompileTimeErrorCode(
630 'CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST',
631 "Can't define the 'const' constructor because the field '{0}' is initi alized with a non-constant value");
632
633 /**
634 * 7.6.3 Constant Constructors: The superinitializer that appears, explicitly
635 * or implicitly, in the initializer list of a constant constructor must
636 * specify a constant constructor of the superclass of the immediately
637 * enclosing class or a compile-time error occurs.
638 *
639 * 9 Mixins: For each generative constructor named ... an implicitly declared
640 * constructor named ... is declared.
641 */
642 static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_MIXIN =
643 const CompileTimeErrorCode('CONST_CONSTRUCTOR_WITH_MIXIN',
644 "Constant constructor cannot be declared for a class with a mixin");
645
646 /**
647 * 7.6.3 Constant Constructors: The superinitializer that appears, explicitly
648 * or implicitly, in the initializer list of a constant constructor must
649 * specify a constant constructor of the superclass of the immediately
650 * enclosing class or a compile-time error occurs.
651 */
652 static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER =
653 const CompileTimeErrorCode('CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER',
654 "Constant constructor cannot call non-constant super constructor of '{ 0}'");
655
656 /**
657 * 7.6.3 Constant Constructors: It is a compile-time error if a constant
658 * constructor is declared by a class that has a non-final instance variable.
659 *
660 * The above refers to both locally declared and inherited instance variables.
661 */
662 static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD =
663 const CompileTimeErrorCode('CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD',
664 "Cannot define the 'const' constructor for a class with non-final fiel ds");
665
666 /**
667 * 12.12.2 Const: It is a compile-time error if <i>T</i> is a deferred type.
668 */
669 static const CompileTimeErrorCode CONST_DEFERRED_CLASS =
670 const CompileTimeErrorCode('CONST_DEFERRED_CLASS',
671 "Deferred classes cannot be created with 'const'");
672
673 /**
674 * 6.2 Formal Parameters: It is a compile-time error if a formal parameter is
675 * declared as a constant variable.
676 */
677 static const CompileTimeErrorCode CONST_FORMAL_PARAMETER =
678 const CompileTimeErrorCode(
679 'CONST_FORMAL_PARAMETER', "Parameters cannot be 'const'");
680
681 /**
682 * 5 Variables: A constant variable must be initialized to a compile-time
683 * constant or a compile-time error occurs.
684 */
685 static const CompileTimeErrorCode CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE =
686 const CompileTimeErrorCode('CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE',
687 "'const' variables must be constant value");
688
689 /**
690 * 5 Variables: A constant variable must be initialized to a compile-time
691 * constant or a compile-time error occurs.
692 *
693 * 12.1 Constants: A qualified reference to a static constant variable that is
694 * not qualified by a deferred prefix.
695 */
696 static const CompileTimeErrorCode CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FR OM_DEFERRED_LIBRARY =
697 const CompileTimeErrorCode(
698 'CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY',
699 "Constant values from a deferred library cannot be used to initialized a 'const' variable");
700
701 /**
702 * 7.5 Instance Variables: It is a compile-time error if an instance variable
703 * is declared to be constant.
704 */
705 static const CompileTimeErrorCode CONST_INSTANCE_FIELD =
706 const CompileTimeErrorCode('CONST_INSTANCE_FIELD',
707 "Only static fields can be declared as 'const'");
708
709 /**
710 * 12.8 Maps: It is a compile-time error if the key of an entry in a constant
711 * map literal is an instance of a class that implements the operator
712 * <i>==</i> unless the key is a string or integer.
713 */
714 static const CompileTimeErrorCode CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQU ALS =
715 const CompileTimeErrorCode(
716 'CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS',
717 "The constant map entry key expression type '{0}' cannot override the == operator");
718
719 /**
720 * 5 Variables: A constant variable must be initialized to a compile-time
721 * constant (12.1) or a compile-time error occurs.
722 *
723 * Parameters:
724 * 0: the name of the uninitialized final variable
725 */
726 static const CompileTimeErrorCode CONST_NOT_INITIALIZED =
727 const CompileTimeErrorCode('CONST_NOT_INITIALIZED',
728 "The const variable '{0}' must be initialized");
729
730 /**
731 * 12.11.2 Const: An expression of one of the forms !e, e1 && e2 or e1 || e2,
732 * where e, e1 and e2 are constant expressions that evaluate to a boolean
733 * value.
734 */
735 static const CompileTimeErrorCode CONST_EVAL_TYPE_BOOL =
736 const CompileTimeErrorCode('CONST_EVAL_TYPE_BOOL',
737 "In constant expressions, operand(s) of this operator must be of type 'bool'");
738
739 /**
740 * 12.11.2 Const: An expression of one of the forms e1 == e2 or e1 != e2 where
741 * e1 and e2 are constant expressions that evaluate to a numeric, string or
742 * boolean value or to null.
743 */
744 static const CompileTimeErrorCode CONST_EVAL_TYPE_BOOL_NUM_STRING =
745 const CompileTimeErrorCode('CONST_EVAL_TYPE_BOOL_NUM_STRING',
746 "In constant expressions, operands of this operator must be of type 'b ool', 'num', 'String' or 'null'");
747
748 /**
749 * 12.11.2 Const: An expression of one of the forms ~e, e1 ^ e2, e1 & e2,
750 * e1 | e2, e1 >> e2 or e1 << e2, where e, e1 and e2 are constant expressions
751 * that evaluate to an integer value or to null.
752 */
753 static const CompileTimeErrorCode CONST_EVAL_TYPE_INT =
754 const CompileTimeErrorCode('CONST_EVAL_TYPE_INT',
755 "In constant expressions, operand(s) of this operator must be of type 'int'");
756
757 /**
758 * 12.11.2 Const: An expression of one of the forms e, e1 + e2, e1 - e2, e1 *
759 * e2, e1 / e2, e1 ~/ e2, e1 > e2, e1 < e2, e1 >= e2, e1 <= e2 or e1 % e2,
760 * where e, e1 and e2 are constant expressions that evaluate to a numeric
761 * value or to null.
762 */
763 static const CompileTimeErrorCode CONST_EVAL_TYPE_NUM =
764 const CompileTimeErrorCode('CONST_EVAL_TYPE_NUM',
765 "In constant expressions, operand(s) of this operator must be of type 'num'");
766
767 /**
768 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
769 * object results in an uncaught exception being thrown.
770 */
771 static const CompileTimeErrorCode CONST_EVAL_THROWS_EXCEPTION =
772 const CompileTimeErrorCode('CONST_EVAL_THROWS_EXCEPTION',
773 "Evaluation of this constant expression causes exception");
774
775 /**
776 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
777 * object results in an uncaught exception being thrown.
778 */
779 static const CompileTimeErrorCode CONST_EVAL_THROWS_IDBZE =
780 const CompileTimeErrorCode('CONST_EVAL_THROWS_IDBZE',
781 "Evaluation of this constant expression throws IntegerDivisionByZeroEx ception");
782
783 /**
784 * 12.11.2 Const: If <i>T</i> is a parameterized type <i>S&lt;U<sub>1</sub>,
785 * &hellip;, U<sub>m</sub>&gt;</i>, let <i>R = S</i>; It is a compile time
786 * error if <i>S</i> is not a generic type with <i>m</i> type parameters.
787 *
788 * Parameters:
789 * 0: the name of the type being referenced (<i>S</i>)
790 * 1: the number of type parameters that were declared
791 * 2: the number of type arguments provided
792 *
793 * See [CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS], and
794 * [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS].
795 */
796 static const CompileTimeErrorCode CONST_WITH_INVALID_TYPE_PARAMETERS =
797 const CompileTimeErrorCode('CONST_WITH_INVALID_TYPE_PARAMETERS',
798 "The type '{0}' is declared with {1} type parameters, but {2} type arg uments were given");
799
800 /**
801 * 12.11.2 Const: If <i>e</i> is of the form <i>const T(a<sub>1</sub>,
802 * &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;,
803 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a compile-time error if the
804 * type <i>T</i> does not declare a constant constructor with the same name as
805 * the declaration of <i>T</i>.
806 */
807 static const CompileTimeErrorCode CONST_WITH_NON_CONST =
808 const CompileTimeErrorCode('CONST_WITH_NON_CONST',
809 "The constructor being called is not a 'const' constructor");
810
811 /**
812 * 12.11.2 Const: In all of the above cases, it is a compile-time error if
813 * <i>a<sub>i</sub>, 1 &lt;= i &lt;= n + k</i>, is not a compile-time constant
814 * expression.
815 */
816 static const CompileTimeErrorCode CONST_WITH_NON_CONSTANT_ARGUMENT =
817 const CompileTimeErrorCode('CONST_WITH_NON_CONSTANT_ARGUMENT',
818 "Arguments of a constant creation must be constant expressions");
819
820 /**
821 * 12.11.2 Const: It is a compile-time error if <i>T</i> is not a class
822 * accessible in the current scope, optionally followed by type arguments.
823 *
824 * 12.11.2 Const: If <i>e</i> is of the form <i>const T.id(a<sub>1</sub>,
825 * &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;
826 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a compile-time error if
827 * <i>T</i> is not a class accessible in the current scope, optionally
828 * followed by type arguments.
829 *
830 * Parameters:
831 * 0: the name of the non-type element
832 */
833 static const CompileTimeErrorCode CONST_WITH_NON_TYPE =
834 const CompileTimeErrorCode(
835 'CONST_WITH_NON_TYPE', "The name '{0}' is not a class");
836
837 /**
838 * 12.11.2 Const: It is a compile-time error if <i>T</i> includes any type
839 * parameters.
840 */
841 static const CompileTimeErrorCode CONST_WITH_TYPE_PARAMETERS =
842 const CompileTimeErrorCode('CONST_WITH_TYPE_PARAMETERS',
843 "The constant creation cannot use a type parameter");
844
845 /**
846 * 12.11.2 Const: It is a compile-time error if <i>T.id</i> is not the name of
847 * a constant constructor declared by the type <i>T</i>.
848 *
849 * Parameters:
850 * 0: the name of the type
851 * 1: the name of the requested constant constructor
852 */
853 static const CompileTimeErrorCode CONST_WITH_UNDEFINED_CONSTRUCTOR =
854 const CompileTimeErrorCode('CONST_WITH_UNDEFINED_CONSTRUCTOR',
855 "The class '{0}' does not have a constant constructor '{1}'");
856
857 /**
858 * 12.11.2 Const: It is a compile-time error if <i>T.id</i> is not the name of
859 * a constant constructor declared by the type <i>T</i>.
860 *
861 * Parameters:
862 * 0: the name of the type
863 */
864 static const CompileTimeErrorCode CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
865 const CompileTimeErrorCode('CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
866 "The class '{0}' does not have a default constant constructor");
867
868 /**
869 * 15.3.1 Typedef: It is a compile-time error if any default values are
870 * specified in the signature of a function type alias.
871 */
872 static const CompileTimeErrorCode DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS =
873 const CompileTimeErrorCode('DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS',
874 "Default values aren't allowed in typedefs");
875
876 /**
877 * 6.2.1 Required Formals: By means of a function signature that names the
878 * parameter and describes its type as a function type. It is a compile-time
879 * error if any default values are specified in the signature of such a
880 * function type.
881 */
882 static const CompileTimeErrorCode DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER =
883 const CompileTimeErrorCode('DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER',
884 "Default values aren't allowed in function type parameters");
885
886 /**
887 * 7.6.2 Factories: It is a compile-time error if <i>k</i> explicitly
888 * specifies a default value for an optional parameter.
889 */
890 static const CompileTimeErrorCode DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRU CTOR =
891 const CompileTimeErrorCode(
892 'DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR',
893 "Default values aren't allowed in factory constructors that redirect t o another constructor");
894
895 /**
896 * 3.1 Scoping: It is a compile-time error if there is more than one entity
897 * with the same name declared in the same scope.
898 */
899 static const CompileTimeErrorCode DUPLICATE_CONSTRUCTOR_DEFAULT =
900 const CompileTimeErrorCode('DUPLICATE_CONSTRUCTOR_DEFAULT',
901 "The default constructor is already defined");
902
903 /**
904 * 3.1 Scoping: It is a compile-time error if there is more than one entity
905 * with the same name declared in the same scope.
906 *
907 * Parameters:
908 * 0: the name of the duplicate entity
909 */
910 static const CompileTimeErrorCode DUPLICATE_CONSTRUCTOR_NAME =
911 const CompileTimeErrorCode('DUPLICATE_CONSTRUCTOR_NAME',
912 "The constructor with name '{0}' is already defined");
913
914 /**
915 * 3.1 Scoping: It is a compile-time error if there is more than one entity
916 * with the same name declared in the same scope.
917 *
918 * 7 Classes: It is a compile-time error if a class declares two members of
919 * the same name.
920 *
921 * 7 Classes: It is a compile-time error if a class has an instance member and
922 * a static member with the same name.
923 *
924 * Parameters:
925 * 0: the name of the duplicate entity
926 */
927 static const CompileTimeErrorCode DUPLICATE_DEFINITION =
928 const CompileTimeErrorCode(
929 'DUPLICATE_DEFINITION', "The name '{0}' is already defined");
930
931 /**
932 * 7. Classes: It is a compile-time error if a class has an instance member
933 * and a static member with the same name.
934 *
935 * This covers the additional duplicate definition cases where inheritance has
936 * to be considered.
937 *
938 * Parameters:
939 * 0: the name of the class that has conflicting instance/static members
940 * 1: the name of the conflicting members
941 *
942 * See [DUPLICATE_DEFINITION].
943 */
944 static const CompileTimeErrorCode DUPLICATE_DEFINITION_INHERITANCE =
945 const CompileTimeErrorCode('DUPLICATE_DEFINITION_INHERITANCE',
946 "The name '{0}' is already defined in '{1}'");
947
948 /**
949 * 12.14.2 Binding Actuals to Formals: It is a compile-time error if
950 * <i>q<sub>i</sub> = q<sub>j</sub></i> for any <i>i != j</i> [where
951 * <i>q<sub>i</sub></i> is the label for a named argument].
952 */
953 static const CompileTimeErrorCode DUPLICATE_NAMED_ARGUMENT =
954 const CompileTimeErrorCode('DUPLICATE_NAMED_ARGUMENT',
955 "The argument for the named parameter '{0}' was already specified");
956
957 /**
958 * SDK implementation libraries can be exported only by other SDK libraries.
959 *
960 * Parameters:
961 * 0: the uri pointing to a library
962 */
963 static const CompileTimeErrorCode EXPORT_INTERNAL_LIBRARY =
964 const CompileTimeErrorCode('EXPORT_INTERNAL_LIBRARY',
965 "The library '{0}' is internal and cannot be exported");
966
967 /**
968 * 14.2 Exports: It is a compile-time error if the compilation unit found at
969 * the specified URI is not a library declaration.
970 *
971 * Parameters:
972 * 0: the uri pointing to a non-library declaration
973 */
974 static const CompileTimeErrorCode EXPORT_OF_NON_LIBRARY =
975 const CompileTimeErrorCode('EXPORT_OF_NON_LIBRARY',
976 "The exported library '{0}' must not have a part-of directive");
977
978 /**
979 * Enum proposal: It is a compile-time error to subclass, mix-in or implement
980 * an enum.
981 */
982 static const CompileTimeErrorCode EXTENDS_ENUM = const CompileTimeErrorCode(
983 'EXTENDS_ENUM', "Classes cannot extend an enum");
984
985 /**
986 * 7.9 Superclasses: It is a compile-time error if the extends clause of a
987 * class <i>C</i> includes a type expression that does not denote a class
988 * available in the lexical scope of <i>C</i>.
989 *
990 * Parameters:
991 * 0: the name of the superclass that was not found
992 */
993 static const CompileTimeErrorCode EXTENDS_NON_CLASS =
994 const CompileTimeErrorCode(
995 'EXTENDS_NON_CLASS', "Classes can only extend other classes");
996
997 /**
998 * 12.2 Null: It is a compile-time error for a class to attempt to extend or
999 * implement Null.
1000 *
1001 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1002 * or implement int.
1003 *
1004 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1005 * or implement double.
1006 *
1007 * 12.3 Numbers: It is a compile-time error for any type other than the types
1008 * int and double to
1009 * attempt to extend or implement num.
1010 *
1011 * 12.4 Booleans: It is a compile-time error for a class to attempt to extend
1012 * or implement bool.
1013 *
1014 * 12.5 Strings: It is a compile-time error for a class to attempt to extend
1015 * or implement String.
1016 *
1017 * Parameters:
1018 * 0: the name of the type that cannot be extended
1019 *
1020 * See [IMPLEMENTS_DISALLOWED_CLASS].
1021 */
1022 static const CompileTimeErrorCode EXTENDS_DISALLOWED_CLASS =
1023 const CompileTimeErrorCode(
1024 'EXTENDS_DISALLOWED_CLASS', "Classes cannot extend '{0}'");
1025
1026 /**
1027 * 7.9 Superclasses: It is a compile-time error if the extends clause of a
1028 * class <i>C</i> includes a deferred type expression.
1029 *
1030 * Parameters:
1031 * 0: the name of the type that cannot be extended
1032 *
1033 * See [IMPLEMENTS_DEFERRED_CLASS], and [MIXIN_DEFERRED_CLASS].
1034 */
1035 static const CompileTimeErrorCode EXTENDS_DEFERRED_CLASS =
1036 const CompileTimeErrorCode('EXTENDS_DEFERRED_CLASS',
1037 "This class cannot extend the deferred class '{0}'");
1038
1039 /**
1040 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m &lt;
1041 * h</i> or if <i>m &gt; n</i>.
1042 *
1043 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
1044 * object results in an uncaught exception being thrown.
1045 *
1046 * Parameters:
1047 * 0: the maximum number of positional arguments
1048 * 1: the actual number of positional arguments given
1049 */
1050 static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS =
1051 const CompileTimeErrorCode('EXTRA_POSITIONAL_ARGUMENTS',
1052 "{0} positional arguments expected, but {1} found");
1053
1054 /**
1055 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
1056 * is a compile time error if more than one initializer corresponding to a
1057 * given instance variable appears in <i>k</i>'s list.
1058 */
1059 static const CompileTimeErrorCode FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS =
1060 const CompileTimeErrorCode('FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS',
1061 "The field '{0}' cannot be initialized twice in the same constructor") ;
1062
1063 /**
1064 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
1065 * is a compile time error if <i>k</i>'s initializer list contains an
1066 * initializer for a variable that is initialized by means of an initializing
1067 * formal of <i>k</i>.
1068 */
1069 static const CompileTimeErrorCode FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZ ER =
1070 const CompileTimeErrorCode(
1071 'FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER',
1072 "Fields cannot be initialized in both the parameter list and the initi alizers");
1073
1074 /**
1075 * 5 Variables: It is a compile-time error if a final instance variable that
1076 * has is initialized by means of an initializing formal of a constructor is
1077 * also initialized elsewhere in the same constructor.
1078 *
1079 * Parameters:
1080 * 0: the name of the field in question
1081 */
1082 static const CompileTimeErrorCode FINAL_INITIALIZED_MULTIPLE_TIMES =
1083 const CompileTimeErrorCode('FINAL_INITIALIZED_MULTIPLE_TIMES',
1084 "'{0}' is a final field and so can only be set once");
1085
1086 /**
1087 * 7.6.1 Generative Constructors: It is a compile-time error if an
1088 * initializing formal is used by a function other than a non-redirecting
1089 * generative constructor.
1090 */
1091 static const CompileTimeErrorCode FIELD_INITIALIZER_FACTORY_CONSTRUCTOR =
1092 const CompileTimeErrorCode('FIELD_INITIALIZER_FACTORY_CONSTRUCTOR',
1093 "Initializing formal fields cannot be used in factory constructors");
1094
1095 /**
1096 * 7.6.1 Generative Constructors: It is a compile-time error if an
1097 * initializing formal is used by a function other than a non-redirecting
1098 * generative constructor.
1099 */
1100 static const CompileTimeErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
1101 const CompileTimeErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
1102 "Initializing formal fields can only be used in constructors");
1103
1104 /**
1105 * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
1106 * in which case its only action is to invoke another generative constructor.
1107 *
1108 * 7.6.1 Generative Constructors: It is a compile-time error if an
1109 * initializing formal is used by a function other than a non-redirecting
1110 * generative constructor.
1111 */
1112 static const CompileTimeErrorCode FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR =
1113 const CompileTimeErrorCode('FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR',
1114 "The redirecting constructor cannot have a field initializer");
1115
1116 /**
1117 * 7.2 Getters: It is a compile-time error if a class has both a getter and a
1118 * method with the same name.
1119 *
1120 * Parameters:
1121 * 0: the conflicting name of the getter and method
1122 */
1123 static const CompileTimeErrorCode GETTER_AND_METHOD_WITH_SAME_NAME =
1124 const CompileTimeErrorCode('GETTER_AND_METHOD_WITH_SAME_NAME',
1125 "'{0}' cannot be used to name a getter, there is already a method with the same name");
1126
1127 /**
1128 * 7.10 Superinterfaces: It is a compile-time error if the implements clause
1129 * of a class <i>C</i> specifies a malformed type or deferred type as a
1130 * superinterface.
1131 *
1132 * Parameters:
1133 * 0: the name of the type that cannot be extended
1134 *
1135 * See [EXTENDS_DEFERRED_CLASS], and [MIXIN_DEFERRED_CLASS].
1136 */
1137 static const CompileTimeErrorCode IMPLEMENTS_DEFERRED_CLASS =
1138 const CompileTimeErrorCode('IMPLEMENTS_DEFERRED_CLASS',
1139 "This class cannot implement the deferred class '{0}'");
1140
1141 /**
1142 * 12.2 Null: It is a compile-time error for a class to attempt to extend or
1143 * implement Null.
1144 *
1145 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1146 * or implement int.
1147 *
1148 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1149 * or implement double.
1150 *
1151 * 12.3 Numbers: It is a compile-time error for any type other than the types
1152 * int and double to
1153 * attempt to extend or implement num.
1154 *
1155 * 12.4 Booleans: It is a compile-time error for a class to attempt to extend
1156 * or implement bool.
1157 *
1158 * 12.5 Strings: It is a compile-time error for a class to attempt to extend
1159 * or implement String.
1160 *
1161 * Parameters:
1162 * 0: the name of the type that cannot be implemented
1163 *
1164 * See [EXTENDS_DISALLOWED_CLASS].
1165 */
1166 static const CompileTimeErrorCode IMPLEMENTS_DISALLOWED_CLASS =
1167 const CompileTimeErrorCode(
1168 'IMPLEMENTS_DISALLOWED_CLASS', "Classes cannot implement '{0}'");
1169
1170 /**
1171 * 7.10 Superinterfaces: It is a compile-time error if the implements clause
1172 * of a class includes type dynamic.
1173 */
1174 static const CompileTimeErrorCode IMPLEMENTS_DYNAMIC =
1175 const CompileTimeErrorCode(
1176 'IMPLEMENTS_DYNAMIC', "Classes cannot implement 'dynamic'");
1177
1178 /**
1179 * Enum proposal: It is a compile-time error to subclass, mix-in or implement
1180 * an enum.
1181 */
1182 static const CompileTimeErrorCode IMPLEMENTS_ENUM =
1183 const CompileTimeErrorCode(
1184 'IMPLEMENTS_ENUM', "Classes cannot implement an enum");
1185
1186 /**
1187 * 7.10 Superinterfaces: It is a compile-time error if the implements clause
1188 * of a class <i>C</i> includes a type expression that does not denote a class
1189 * available in the lexical scope of <i>C</i>.
1190 *
1191 * Parameters:
1192 * 0: the name of the interface that was not found
1193 */
1194 static const CompileTimeErrorCode IMPLEMENTS_NON_CLASS =
1195 const CompileTimeErrorCode(
1196 'IMPLEMENTS_NON_CLASS', "Classes can only implement other classes");
1197
1198 /**
1199 * 7.10 Superinterfaces: It is a compile-time error if a type <i>T</i> appears
1200 * more than once in the implements clause of a class.
1201 *
1202 * Parameters:
1203 * 0: the name of the class that is implemented more than once
1204 */
1205 static const CompileTimeErrorCode IMPLEMENTS_REPEATED =
1206 const CompileTimeErrorCode(
1207 'IMPLEMENTS_REPEATED', "'{0}' can only be implemented once");
1208
1209 /**
1210 * 7.10 Superinterfaces: It is a compile-time error if the superclass of a
1211 * class <i>C</i> appears in the implements clause of <i>C</i>.
1212 *
1213 * Parameters:
1214 * 0: the name of the class that appears in both "extends" and "implements"
1215 * clauses
1216 */
1217 static const CompileTimeErrorCode IMPLEMENTS_SUPER_CLASS =
1218 const CompileTimeErrorCode('IMPLEMENTS_SUPER_CLASS',
1219 "'{0}' cannot be used in both 'extends' and 'implements' clauses");
1220
1221 /**
1222 * 7.6.1 Generative Constructors: Note that <b>this</b> is not in scope on the
1223 * right hand side of an initializer.
1224 *
1225 * 12.10 This: It is a compile-time error if this appears in a top-level
1226 * function or variable initializer, in a factory constructor, or in a static
1227 * method or variable initializer, or in the initializer of an instance
1228 * variable.
1229 *
1230 * Parameters:
1231 * 0: the name of the type in question
1232 */
1233 static const CompileTimeErrorCode IMPLICIT_THIS_REFERENCE_IN_INITIALIZER =
1234 const CompileTimeErrorCode('IMPLICIT_THIS_REFERENCE_IN_INITIALIZER',
1235 "Only static members can be accessed in initializers");
1236
1237 /**
1238 * SDK implementation libraries can be imported only by other SDK libraries.
1239 *
1240 * Parameters:
1241 * 0: the uri pointing to a library
1242 */
1243 static const CompileTimeErrorCode IMPORT_INTERNAL_LIBRARY =
1244 const CompileTimeErrorCode('IMPORT_INTERNAL_LIBRARY',
1245 "The library '{0}' is internal and cannot be imported");
1246
1247 /**
1248 * 14.1 Imports: It is a compile-time error if the specified URI of an
1249 * immediate import does not refer to a library declaration.
1250 *
1251 * Parameters:
1252 * 0: the uri pointing to a non-library declaration
1253 *
1254 * See [StaticWarningCode.IMPORT_OF_NON_LIBRARY].
1255 */
1256 static const CompileTimeErrorCode IMPORT_OF_NON_LIBRARY =
1257 const CompileTimeErrorCode('IMPORT_OF_NON_LIBRARY',
1258 "The imported library '{0}' must not have a part-of directive");
1259
1260 /**
1261 * 13.9 Switch: It is a compile-time error if values of the expressions
1262 * <i>e<sub>k</sub></i> are not instances of the same class <i>C</i>, for all
1263 * <i>1 &lt;= k &lt;= n</i>.
1264 *
1265 * Parameters:
1266 * 0: the expression source code that is the unexpected type
1267 * 1: the name of the expected type
1268 */
1269 static const CompileTimeErrorCode INCONSISTENT_CASE_EXPRESSION_TYPES =
1270 const CompileTimeErrorCode('INCONSISTENT_CASE_EXPRESSION_TYPES',
1271 "Case expressions must have the same types, '{0}' is not a '{1}'");
1272
1273 /**
1274 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
1275 * is a compile-time error if <i>k</i>'s initializer list contains an
1276 * initializer for a variable that is not an instance variable declared in the
1277 * immediately surrounding class.
1278 *
1279 * Parameters:
1280 * 0: the name of the initializing formal that is not an instance variable in
1281 * the immediately enclosing class
1282 *
1283 * See [INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD].
1284 */
1285 static const CompileTimeErrorCode INITIALIZER_FOR_NON_EXISTENT_FIELD =
1286 const CompileTimeErrorCode('INITIALIZER_FOR_NON_EXISTENT_FIELD',
1287 "'{0}' is not a variable in the enclosing class");
1288
1289 /**
1290 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
1291 * is a compile-time error if <i>k</i>'s initializer list contains an
1292 * initializer for a variable that is not an instance variable declared in the
1293 * immediately surrounding class.
1294 *
1295 * Parameters:
1296 * 0: the name of the initializing formal that is a static variable in the
1297 * immediately enclosing class
1298 *
1299 * See [INITIALIZING_FORMAL_FOR_STATIC_FIELD].
1300 */
1301 static const CompileTimeErrorCode INITIALIZER_FOR_STATIC_FIELD =
1302 const CompileTimeErrorCode('INITIALIZER_FOR_STATIC_FIELD',
1303 "'{0}' is a static variable in the enclosing class, variables initiali zed in a constructor cannot be static");
1304
1305 /**
1306 * 7.6.1 Generative Constructors: An initializing formal has the form
1307 * <i>this.id</i>. It is a compile-time error if <i>id</i> is not the name of
1308 * an instance variable of the immediately enclosing class.
1309 *
1310 * Parameters:
1311 * 0: the name of the initializing formal that is not an instance variable in
1312 * the immediately enclosing class
1313 *
1314 * See [INITIALIZING_FORMAL_FOR_STATIC_FIELD], and
1315 * [INITIALIZER_FOR_NON_EXISTENT_FIELD].
1316 */
1317 static const CompileTimeErrorCode INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD =
1318 const CompileTimeErrorCode('INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD',
1319 "'{0}' is not a variable in the enclosing class");
1320
1321 /**
1322 * 7.6.1 Generative Constructors: An initializing formal has the form
1323 * <i>this.id</i>. It is a compile-time error if <i>id</i> is not the name of
1324 * an instance variable of the immediately enclosing class.
1325 *
1326 * Parameters:
1327 * 0: the name of the initializing formal that is a static variable in the
1328 * immediately enclosing class
1329 *
1330 * See [INITIALIZER_FOR_STATIC_FIELD].
1331 */
1332 static const CompileTimeErrorCode INITIALIZING_FORMAL_FOR_STATIC_FIELD =
1333 const CompileTimeErrorCode('INITIALIZING_FORMAL_FOR_STATIC_FIELD',
1334 "'{0}' is a static field in the enclosing class, fields initialized in a constructor cannot be static");
1335
1336 /**
1337 * 12.30 Identifier Reference: Otherwise, e is equivalent to the property
1338 * extraction <b>this</b>.<i>id</i>.
1339 */
1340 static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_FACTORY =
1341 const CompileTimeErrorCode('INSTANCE_MEMBER_ACCESS_FROM_FACTORY',
1342 "Instance members cannot be accessed from a factory constructor");
1343
1344 /**
1345 * 12.30 Identifier Reference: Otherwise, e is equivalent to the property
1346 * extraction <b>this</b>.<i>id</i>.
1347 */
1348 static const CompileTimeErrorCode INSTANCE_MEMBER_ACCESS_FROM_STATIC =
1349 const CompileTimeErrorCode('INSTANCE_MEMBER_ACCESS_FROM_STATIC',
1350 "Instance members cannot be accessed from a static method");
1351
1352 /**
1353 * Enum proposal: It is also a compile-time error to explicitly instantiate an
1354 * enum via 'new' or 'const' or to access its private fields.
1355 */
1356 static const CompileTimeErrorCode INSTANTIATE_ENUM =
1357 const CompileTimeErrorCode(
1358 'INSTANTIATE_ENUM', "Enums cannot be instantiated");
1359
1360 /**
1361 * 11 Metadata: Metadata consists of a series of annotations, each of which
1362 * begin with the character @, followed by a constant expression that must be
1363 * either a reference to a compile-time constant variable, or a call to a
1364 * constant constructor.
1365 */
1366 static const CompileTimeErrorCode INVALID_ANNOTATION = const CompileTimeErrorC ode(
1367 'INVALID_ANNOTATION',
1368 "Annotation can be only constant variable or constant constructor invocati on");
1369
1370 /**
1371 * 11 Metadata: Metadata consists of a series of annotations, each of which
1372 * begin with the character @, followed by a constant expression that must be
1373 * either a reference to a compile-time constant variable, or a call to a
1374 * constant constructor.
1375 *
1376 * 12.1 Constants: A qualified reference to a static constant variable that is
1377 * not qualified by a deferred prefix.
1378 */
1379 static const CompileTimeErrorCode INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY =
1380 const CompileTimeErrorCode('INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY',
1381 "Constant values from a deferred library cannot be used as annotations ");
1382
1383 /**
1384 * 15.31 Identifier Reference: It is a compile-time error if any of the
1385 * identifiers async, await or yield is used as an identifier in a function
1386 * body marked with either async, async* or sync*.
1387 */
1388 static const CompileTimeErrorCode INVALID_IDENTIFIER_IN_ASYNC =
1389 const CompileTimeErrorCode('INVALID_IDENTIFIER_IN_ASYNC',
1390 "The identifier '{0}' cannot be used in a function marked with async, async* or sync*");
1391
1392 /**
1393 * 9. Functions: It is a compile-time error if an async, async* or sync*
1394 * modifier is attached to the body of a setter or constructor.
1395 */
1396 static const CompileTimeErrorCode INVALID_MODIFIER_ON_CONSTRUCTOR =
1397 const CompileTimeErrorCode('INVALID_MODIFIER_ON_CONSTRUCTOR',
1398 "The modifier '{0}' cannot be applied to the body of a constructor");
1399
1400 /**
1401 * 9. Functions: It is a compile-time error if an async, async* or sync*
1402 * modifier is attached to the body of a setter or constructor.
1403 */
1404 static const CompileTimeErrorCode INVALID_MODIFIER_ON_SETTER =
1405 const CompileTimeErrorCode('INVALID_MODIFIER_ON_SETTER',
1406 "The modifier '{0}' cannot be applied to the body of a setter");
1407
1408 /**
1409 * TODO(brianwilkerson) Remove this when we have decided on how to report
1410 * errors in compile-time constants. Until then, this acts as a placeholder
1411 * for more informative errors.
1412 *
1413 * See TODOs in ConstantVisitor
1414 */
1415 static const CompileTimeErrorCode INVALID_CONSTANT =
1416 const CompileTimeErrorCode('INVALID_CONSTANT', "Invalid constant value");
1417
1418 /**
1419 * 7.6 Constructors: It is a compile-time error if the name of a constructor
1420 * is not a constructor name.
1421 */
1422 static const CompileTimeErrorCode INVALID_CONSTRUCTOR_NAME =
1423 const CompileTimeErrorCode(
1424 'INVALID_CONSTRUCTOR_NAME', "Invalid constructor name");
1425
1426 /**
1427 * 7.6.2 Factories: It is a compile-time error if <i>M</i> is not the name of
1428 * the immediately enclosing class.
1429 */
1430 static const CompileTimeErrorCode INVALID_FACTORY_NAME_NOT_A_CLASS =
1431 const CompileTimeErrorCode('INVALID_FACTORY_NAME_NOT_A_CLASS',
1432 "The name of the immediately enclosing class expected");
1433
1434 /**
1435 * 12.10 This: It is a compile-time error if this appears in a top-level
1436 * function or variable initializer, in a factory constructor, or in a static
1437 * method or variable initializer, or in the initializer of an instance
1438 * variable.
1439 */
1440 static const CompileTimeErrorCode INVALID_REFERENCE_TO_THIS =
1441 const CompileTimeErrorCode('INVALID_REFERENCE_TO_THIS',
1442 "Invalid reference to 'this' expression");
1443
1444 /**
1445 * 12.6 Lists: It is a compile time error if the type argument of a constant
1446 * list literal includes a type parameter.
1447 *
1448 * Parameters:
1449 * 0: the name of the type parameter
1450 */
1451 static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_LIST =
1452 const CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_LIST',
1453 "Constant list literals cannot include a type parameter as a type argu ment, such as '{0}'");
1454
1455 /**
1456 * 12.7 Maps: It is a compile time error if the type arguments of a constant
1457 * map literal include a type parameter.
1458 *
1459 * Parameters:
1460 * 0: the name of the type parameter
1461 */
1462 static const CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_MAP =
1463 const CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_MAP',
1464 "Constant map literals cannot include a type parameter as a type argum ent, such as '{0}'");
1465
1466 /**
1467 * 14.2 Exports: It is a compile-time error if the compilation unit found at
1468 * the specified URI is not a library declaration.
1469 *
1470 * 14.1 Imports: It is a compile-time error if the compilation unit found at
1471 * the specified URI is not a library declaration.
1472 *
1473 * 14.3 Parts: It is a compile time error if the contents of the URI are not a
1474 * valid part declaration.
1475 *
1476 * Parameters:
1477 * 0: the URI that is invalid
1478 *
1479 * See [URI_DOES_NOT_EXIST].
1480 */
1481 static const CompileTimeErrorCode INVALID_URI =
1482 const CompileTimeErrorCode('INVALID_URI', "Invalid URI syntax: '{0}'");
1483
1484 /**
1485 * 13.13 Break: It is a compile-time error if no such statement
1486 * <i>s<sub>E</sub></i> exists within the innermost function in which
1487 * <i>s<sub>b</sub></i> occurs.
1488 *
1489 * 13.14 Continue: It is a compile-time error if no such statement or case
1490 * clause <i>s<sub>E</sub></i> exists within the innermost function in which
1491 * <i>s<sub>c</sub></i> occurs.
1492 *
1493 * Parameters:
1494 * 0: the name of the unresolvable label
1495 */
1496 static const CompileTimeErrorCode LABEL_IN_OUTER_SCOPE =
1497 const CompileTimeErrorCode('LABEL_IN_OUTER_SCOPE',
1498 "Cannot reference label '{0}' declared in an outer method");
1499
1500 /**
1501 * 13.13 Break: It is a compile-time error if no such statement
1502 * <i>s<sub>E</sub></i> exists within the innermost function in which
1503 * <i>s<sub>b</sub></i> occurs.
1504 *
1505 * 13.14 Continue: It is a compile-time error if no such statement or case
1506 * clause <i>s<sub>E</sub></i> exists within the innermost function in which
1507 * <i>s<sub>c</sub></i> occurs.
1508 *
1509 * Parameters:
1510 * 0: the name of the unresolvable label
1511 */
1512 static const CompileTimeErrorCode LABEL_UNDEFINED =
1513 const CompileTimeErrorCode(
1514 'LABEL_UNDEFINED', "Cannot reference undefined label '{0}'");
1515
1516 /**
1517 * 7 Classes: It is a compile time error if a class <i>C</i> declares a member
1518 * with the same name as <i>C</i>.
1519 */
1520 static const CompileTimeErrorCode MEMBER_WITH_CLASS_NAME =
1521 const CompileTimeErrorCode('MEMBER_WITH_CLASS_NAME',
1522 "Class members cannot have the same name as the enclosing class");
1523
1524 /**
1525 * 7.2 Getters: It is a compile-time error if a class has both a getter and a
1526 * method with the same name.
1527 *
1528 * Parameters:
1529 * 0: the conflicting name of the getter and method
1530 */
1531 static const CompileTimeErrorCode METHOD_AND_GETTER_WITH_SAME_NAME =
1532 const CompileTimeErrorCode('METHOD_AND_GETTER_WITH_SAME_NAME',
1533 "'{0}' cannot be used to name a method, there is already a getter with the same name");
1534
1535 /**
1536 * 12.1 Constants: A constant expression is ... a constant list literal.
1537 */
1538 static const CompileTimeErrorCode MISSING_CONST_IN_LIST_LITERAL =
1539 const CompileTimeErrorCode('MISSING_CONST_IN_LIST_LITERAL',
1540 "List literals must be prefixed with 'const' when used as a constant e xpression");
1541
1542 /**
1543 * 12.1 Constants: A constant expression is ... a constant map literal.
1544 */
1545 static const CompileTimeErrorCode MISSING_CONST_IN_MAP_LITERAL =
1546 const CompileTimeErrorCode('MISSING_CONST_IN_MAP_LITERAL',
1547 "Map literals must be prefixed with 'const' when used as a constant ex pression");
1548
1549 /**
1550 * Enum proposal: It is a static warning if all of the following conditions
1551 * hold:
1552 * * The switch statement does not have a 'default' clause.
1553 * * The static type of <i>e</i> is an enumerated typed with elements
1554 * <i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>.
1555 * * The sets {<i>e<sub>1</sub></i>, &hellip;, <i>e<sub>k</sub></i>} and
1556 * {<i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>} are not the
1557 * same.
1558 *
1559 * Parameters:
1560 * 0: the name of the constant that is missing
1561 */
1562 static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH =
1563 const CompileTimeErrorCode('MISSING_ENUM_CONSTANT_IN_SWITCH',
1564 "Missing case clause for '{0}'",
1565 "Add a case clause for the missing constant or add a default clause.") ;
1566
1567 /**
1568 * 9 Mixins: It is a compile-time error if a declared or derived mixin
1569 * explicitly declares a constructor.
1570 *
1571 * Parameters:
1572 * 0: the name of the mixin that is invalid
1573 */
1574 static const CompileTimeErrorCode MIXIN_DECLARES_CONSTRUCTOR =
1575 const CompileTimeErrorCode('MIXIN_DECLARES_CONSTRUCTOR',
1576 "The class '{0}' cannot be used as a mixin because it declares a const ructor");
1577
1578 /**
1579 * 9.1 Mixin Application: It is a compile-time error if the with clause of a
1580 * mixin application <i>C</i> includes a deferred type expression.
1581 *
1582 * Parameters:
1583 * 0: the name of the type that cannot be extended
1584 *
1585 * See [EXTENDS_DEFERRED_CLASS], and [IMPLEMENTS_DEFERRED_CLASS].
1586 */
1587 static const CompileTimeErrorCode MIXIN_DEFERRED_CLASS =
1588 const CompileTimeErrorCode('MIXIN_DEFERRED_CLASS',
1589 "This class cannot mixin the deferred class '{0}'");
1590
1591 /**
1592 * Not yet in the spec, but consistent with VM behavior. It is a
1593 * compile-time error if all of the constructors of a mixin's base class have
1594 * at least one optional parameter (since only constructors that lack
1595 * optional parameters can be forwarded to the mixin). See
1596 * https://code.google.com/p/dart/issues/detail?id=15101#c4
1597 */
1598 static const CompileTimeErrorCode MIXIN_HAS_NO_CONSTRUCTORS =
1599 const CompileTimeErrorCode('MIXIN_HAS_NO_CONSTRUCTORS',
1600 "This mixin application is invalid because all of the constructors "
1601 "in the base class '{0}' have optional parameters.");
1602
1603 /**
1604 * 9 Mixins: It is a compile-time error if a mixin is derived from a class
1605 * whose superclass is not Object.
1606 *
1607 * Parameters:
1608 * 0: the name of the mixin that is invalid
1609 */
1610 static const CompileTimeErrorCode MIXIN_INHERITS_FROM_NOT_OBJECT =
1611 const CompileTimeErrorCode('MIXIN_INHERITS_FROM_NOT_OBJECT',
1612 "The class '{0}' cannot be used as a mixin because it extends a class other than Object");
1613
1614 /**
1615 * 12.2 Null: It is a compile-time error for a class to attempt to extend or
1616 * implement Null.
1617 *
1618 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1619 * or implement int.
1620 *
1621 * 12.3 Numbers: It is a compile-time error for a class to attempt to extend
1622 * or implement double.
1623 *
1624 * 12.3 Numbers: It is a compile-time error for any type other than the types
1625 * int and double to attempt to extend or implement num.
1626 *
1627 * 12.4 Booleans: It is a compile-time error for a class to attempt to extend
1628 * or implement bool.
1629 *
1630 * 12.5 Strings: It is a compile-time error for a class to attempt to extend
1631 * or implement String.
1632 *
1633 * Parameters:
1634 * 0: the name of the type that cannot be extended
1635 *
1636 * See [IMPLEMENTS_DISALLOWED_CLASS].
1637 */
1638 static const CompileTimeErrorCode MIXIN_OF_DISALLOWED_CLASS =
1639 const CompileTimeErrorCode(
1640 'MIXIN_OF_DISALLOWED_CLASS', "Classes cannot mixin '{0}'");
1641
1642 /**
1643 * Enum proposal: It is a compile-time error to subclass, mix-in or implement
1644 * an enum.
1645 */
1646 static const CompileTimeErrorCode MIXIN_OF_ENUM = const CompileTimeErrorCode(
1647 'MIXIN_OF_ENUM', "Classes cannot mixin an enum");
1648
1649 /**
1650 * 9.1 Mixin Application: It is a compile-time error if <i>M</i> does not
1651 * denote a class or mixin available in the immediately enclosing scope.
1652 */
1653 static const CompileTimeErrorCode MIXIN_OF_NON_CLASS =
1654 const CompileTimeErrorCode(
1655 'MIXIN_OF_NON_CLASS', "Classes can only mixin other classes");
1656
1657 /**
1658 * 9 Mixins: It is a compile-time error if a declared or derived mixin refers
1659 * to super.
1660 */
1661 static const CompileTimeErrorCode MIXIN_REFERENCES_SUPER =
1662 const CompileTimeErrorCode('MIXIN_REFERENCES_SUPER',
1663 "The class '{0}' cannot be used as a mixin because it references 'supe r'");
1664
1665 /**
1666 * 9.1 Mixin Application: It is a compile-time error if <i>S</i> does not
1667 * denote a class available in the immediately enclosing scope.
1668 */
1669 static const CompileTimeErrorCode MIXIN_WITH_NON_CLASS_SUPERCLASS =
1670 const CompileTimeErrorCode('MIXIN_WITH_NON_CLASS_SUPERCLASS',
1671 "Mixin can only be applied to class");
1672
1673 /**
1674 * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
1675 * in which case its only action is to invoke another generative constructor.
1676 */
1677 static const CompileTimeErrorCode MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS =
1678 const CompileTimeErrorCode('MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS',
1679 "Constructor may have at most one 'this' redirection");
1680
1681 /**
1682 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor.
1683 * Then <i>k</i> may include at most one superinitializer in its initializer
1684 * list or a compile time error occurs.
1685 */
1686 static const CompileTimeErrorCode MULTIPLE_SUPER_INITIALIZERS =
1687 const CompileTimeErrorCode('MULTIPLE_SUPER_INITIALIZERS',
1688 "Constructor may have at most one 'super' initializer");
1689
1690 /**
1691 * 11 Metadata: Metadata consists of a series of annotations, each of which
1692 * begin with the character @, followed by a constant expression that must be
1693 * either a reference to a compile-time constant variable, or a call to a
1694 * constant constructor.
1695 */
1696 static const CompileTimeErrorCode NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS =
1697 const CompileTimeErrorCode('NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS',
1698 "Annotation creation must have arguments");
1699
1700 /**
1701 * 7.6.1 Generative Constructors: If no superinitializer is provided, an
1702 * implicit superinitializer of the form <b>super</b>() is added at the end of
1703 * <i>k</i>'s initializer list, unless the enclosing class is class
1704 * <i>Object</i>.
1705 *
1706 * 7.6.1 Generative constructors. It is a compile-time error if class <i>S</i>
1707 * does not declare a generative constructor named <i>S</i> (respectively
1708 * <i>S.id</i>)
1709 */
1710 static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT =
1711 const CompileTimeErrorCode('NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
1712 "The class '{0}' does not have a default constructor");
1713
1714 /**
1715 * 7.6 Constructors: Iff no constructor is specified for a class <i>C</i>, it
1716 * implicitly has a default constructor C() : <b>super<b>() {}, unless
1717 * <i>C</i> is class <i>Object</i>.
1718 *
1719 * 7.6.1 Generative constructors. It is a compile-time error if class <i>S</i>
1720 * does not declare a generative constructor named <i>S</i> (respectively
1721 * <i>S.id</i>)
1722 */
1723 static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT =
1724 const CompileTimeErrorCode('NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
1725 "The class '{0}' does not have a default constructor");
1726
1727 /**
1728 * 13.2 Expression Statements: It is a compile-time error if a non-constant
1729 * map literal that has no explicit type arguments appears in a place where a
1730 * statement is expected.
1731 */
1732 static const CompileTimeErrorCode NON_CONST_MAP_AS_EXPRESSION_STATEMENT =
1733 const CompileTimeErrorCode('NON_CONST_MAP_AS_EXPRESSION_STATEMENT',
1734 "A non-constant map literal without type arguments cannot be used as a n expression statement");
1735
1736 /**
1737 * 13.9 Switch: Given a switch statement of the form <i>switch (e) {
1738 * label<sub>11</sub> &hellip; label<sub>1j1</sub> case e<sub>1</sub>:
1739 * s<sub>1</sub> &hellip; label<sub>n1</sub> &hellip; label<sub>njn</sub> case
1740 * e<sub>n</sub>: s<sub>n</sub> default: s<sub>n+1</sub>}</i> or the form
1741 * <i>switch (e) { label<sub>11</sub> &hellip; label<sub>1j1</sub> case
1742 * e<sub>1</sub>: s<sub>1</sub> &hellip; label<sub>n1</sub> &hellip;
1743 * label<sub>njn</sub> case e<sub>n</sub>: s<sub>n</sub>}</i>, it is a
1744 * compile-time error if the expressions <i>e<sub>k</sub></i> are not
1745 * compile-time constants, for all <i>1 &lt;= k &lt;= n</i>.
1746 */
1747 static const CompileTimeErrorCode NON_CONSTANT_CASE_EXPRESSION =
1748 const CompileTimeErrorCode(
1749 'NON_CONSTANT_CASE_EXPRESSION', "Case expressions must be constant");
1750
1751 /**
1752 * 13.9 Switch: Given a switch statement of the form <i>switch (e) {
1753 * label<sub>11</sub> &hellip; label<sub>1j1</sub> case e<sub>1</sub>:
1754 * s<sub>1</sub> &hellip; label<sub>n1</sub> &hellip; label<sub>njn</sub> case
1755 * e<sub>n</sub>: s<sub>n</sub> default: s<sub>n+1</sub>}</i> or the form
1756 * <i>switch (e) { label<sub>11</sub> &hellip; label<sub>1j1</sub> case
1757 * e<sub>1</sub>: s<sub>1</sub> &hellip; label<sub>n1</sub> &hellip;
1758 * label<sub>njn</sub> case e<sub>n</sub>: s<sub>n</sub>}</i>, it is a
1759 * compile-time error if the expressions <i>e<sub>k</sub></i> are not
1760 * compile-time constants, for all <i>1 &lt;= k &lt;= n</i>.
1761 *
1762 * 12.1 Constants: A qualified reference to a static constant variable that is
1763 * not qualified by a deferred prefix.
1764 */
1765 static const CompileTimeErrorCode NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_L IBRARY =
1766 const CompileTimeErrorCode(
1767 'NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY',
1768 "Constant values from a deferred library cannot be used as a case expr ession");
1769
1770 /**
1771 * 6.2.2 Optional Formals: It is a compile-time error if the default value of
1772 * an optional parameter is not a compile-time constant.
1773 */
1774 static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE =
1775 const CompileTimeErrorCode('NON_CONSTANT_DEFAULT_VALUE',
1776 "Default values of an optional parameter must be constant");
1777
1778 /**
1779 * 6.2.2 Optional Formals: It is a compile-time error if the default value of
1780 * an optional parameter is not a compile-time constant.
1781 *
1782 * 12.1 Constants: A qualified reference to a static constant variable that is
1783 * not qualified by a deferred prefix.
1784 */
1785 static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIB RARY =
1786 const CompileTimeErrorCode(
1787 'NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY',
1788 "Constant values from a deferred library cannot be used as a default p arameter value");
1789
1790 /**
1791 * 12.6 Lists: It is a compile time error if an element of a constant list
1792 * literal is not a compile-time constant.
1793 */
1794 static const CompileTimeErrorCode NON_CONSTANT_LIST_ELEMENT =
1795 const CompileTimeErrorCode('NON_CONSTANT_LIST_ELEMENT',
1796 "'const' lists must have all constant values");
1797
1798 /**
1799 * 12.6 Lists: It is a compile time error if an element of a constant list
1800 * literal is not a compile-time constant.
1801 *
1802 * 12.1 Constants: A qualified reference to a static constant variable that is
1803 * not qualified by a deferred prefix.
1804 */
1805 static const CompileTimeErrorCode NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBR ARY =
1806 const CompileTimeErrorCode(
1807 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY',
1808 "Constant values from a deferred library cannot be used as values in a 'const' list");
1809
1810 /**
1811 * 12.7 Maps: It is a compile time error if either a key or a value of an
1812 * entry in a constant map literal is not a compile-time constant.
1813 */
1814 static const CompileTimeErrorCode NON_CONSTANT_MAP_KEY =
1815 const CompileTimeErrorCode(
1816 'NON_CONSTANT_MAP_KEY', "The keys in a map must be constant");
1817
1818 /**
1819 * 12.7 Maps: It is a compile time error if either a key or a value of an
1820 * entry in a constant map literal is not a compile-time constant.
1821 *
1822 * 12.1 Constants: A qualified reference to a static constant variable that is
1823 * not qualified by a deferred prefix.
1824 */
1825 static const CompileTimeErrorCode NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY =
1826 const CompileTimeErrorCode('NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY',
1827 "Constant values from a deferred library cannot be used as keys in a m ap");
1828
1829 /**
1830 * 12.7 Maps: It is a compile time error if either a key or a value of an
1831 * entry in a constant map literal is not a compile-time constant.
1832 */
1833 static const CompileTimeErrorCode NON_CONSTANT_MAP_VALUE =
1834 const CompileTimeErrorCode('NON_CONSTANT_MAP_VALUE',
1835 "The values in a 'const' map must be constant");
1836
1837 /**
1838 * 12.7 Maps: It is a compile time error if either a key or a value of an
1839 * entry in a constant map literal is not a compile-time constant.
1840 *
1841 * 12.1 Constants: A qualified reference to a static constant variable that is
1842 * not qualified by a deferred prefix.
1843 */
1844 static const CompileTimeErrorCode NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY =
1845 const CompileTimeErrorCode('NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY',
1846 "Constant values from a deferred library cannot be used as values in a 'const' map");
1847
1848 /**
1849 * 11 Metadata: Metadata consists of a series of annotations, each of which
1850 * begin with the character @, followed by a constant expression that must be
1851 * either a reference to a compile-time constant variable, or a call to a
1852 * constant constructor.
1853 *
1854 * "From deferred library" case is covered by
1855 * [CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY].
1856 */
1857 static const CompileTimeErrorCode NON_CONSTANT_ANNOTATION_CONSTRUCTOR =
1858 const CompileTimeErrorCode('NON_CONSTANT_ANNOTATION_CONSTRUCTOR',
1859 "Annotation creation can use only 'const' constructor");
1860
1861 /**
1862 * 7.6.3 Constant Constructors: Any expression that appears within the
1863 * initializer list of a constant constructor must be a potentially constant
1864 * expression, or a compile-time error occurs.
1865 */
1866 static const CompileTimeErrorCode NON_CONSTANT_VALUE_IN_INITIALIZER =
1867 const CompileTimeErrorCode('NON_CONSTANT_VALUE_IN_INITIALIZER',
1868 "Initializer expressions in constant constructors must be constants");
1869
1870 /**
1871 * 7.6.3 Constant Constructors: Any expression that appears within the
1872 * initializer list of a constant constructor must be a potentially constant
1873 * expression, or a compile-time error occurs.
1874 *
1875 * 12.1 Constants: A qualified reference to a static constant variable that is
1876 * not qualified by a deferred prefix.
1877 */
1878 static const CompileTimeErrorCode NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFER RED_LIBRARY =
1879 const CompileTimeErrorCode(
1880 'NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY',
1881 "Constant values from a deferred library cannot be used as constant in itializers");
1882
1883 /**
1884 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m < h</i>
1885 * or if <i>m > n</i>.
1886 *
1887 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
1888 * object results in an uncaught exception being thrown.
1889 *
1890 * Parameters:
1891 * 0: the expected number of required arguments
1892 * 1: the actual number of positional arguments given
1893 */
1894 static const CompileTimeErrorCode NOT_ENOUGH_REQUIRED_ARGUMENTS =
1895 const CompileTimeErrorCode('NOT_ENOUGH_REQUIRED_ARGUMENTS',
1896 "{0} required argument(s) expected, but {1} found");
1897
1898 /**
1899 * 7.6.1 Generative Constructors: Let <i>C</i> be the class in which the
1900 * superinitializer appears and let <i>S</i> be the superclass of <i>C</i>.
1901 * Let <i>k</i> be a generative constructor. It is a compile-time error if
1902 * class <i>S</i> does not declare a generative constructor named <i>S</i>
1903 * (respectively <i>S.id</i>)
1904 */
1905 static const CompileTimeErrorCode NON_GENERATIVE_CONSTRUCTOR =
1906 const CompileTimeErrorCode('NON_GENERATIVE_CONSTRUCTOR',
1907 "The generative constructor '{0}' expected, but factory found");
1908
1909 /**
1910 * 7.9 Superclasses: It is a compile-time error to specify an extends clause
1911 * for class Object.
1912 */
1913 static const CompileTimeErrorCode OBJECT_CANNOT_EXTEND_ANOTHER_CLASS =
1914 const CompileTimeErrorCode('OBJECT_CANNOT_EXTEND_ANOTHER_CLASS', "");
1915
1916 /**
1917 * 7.1.1 Operators: It is a compile-time error to declare an optional
1918 * parameter in an operator.
1919 */
1920 static const CompileTimeErrorCode OPTIONAL_PARAMETER_IN_OPERATOR =
1921 const CompileTimeErrorCode('OPTIONAL_PARAMETER_IN_OPERATOR',
1922 "Optional parameters are not allowed when defining an operator");
1923
1924 /**
1925 * 14.3 Parts: It is a compile time error if the contents of the URI are not a
1926 * valid part declaration.
1927 *
1928 * Parameters:
1929 * 0: the uri pointing to a non-library declaration
1930 */
1931 static const CompileTimeErrorCode PART_OF_NON_PART =
1932 const CompileTimeErrorCode('PART_OF_NON_PART',
1933 "The included part '{0}' must have a part-of directive");
1934
1935 /**
1936 * 14.1 Imports: It is a compile-time error if the current library declares a
1937 * top-level member named <i>p</i>.
1938 */
1939 static const CompileTimeErrorCode PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER =
1940 const CompileTimeErrorCode('PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER',
1941 "The name '{0}' is already used as an import prefix and cannot be used to name a top-level element");
1942
1943 /**
1944 * 16.32 Identifier Reference: If d is a prefix p, a compile-time error
1945 * occurs unless the token immediately following d is '.'.
1946 */
1947 static const CompileTimeErrorCode PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT =
1948 const CompileTimeErrorCode('PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT',
1949 "The name '{0}' refers to an import prefix, so it must be followed by '.'");
1950
1951 /**
1952 * 6.2.2 Optional Formals: It is a compile-time error if the name of a named
1953 * optional parameter begins with an '_' character.
1954 */
1955 static const CompileTimeErrorCode PRIVATE_OPTIONAL_PARAMETER =
1956 const CompileTimeErrorCode('PRIVATE_OPTIONAL_PARAMETER',
1957 "Named optional parameters cannot start with an underscore");
1958
1959 /**
1960 * 12.1 Constants: It is a compile-time error if the value of a compile-time
1961 * constant expression depends on itself.
1962 */
1963 static const CompileTimeErrorCode RECURSIVE_COMPILE_TIME_CONSTANT =
1964 const CompileTimeErrorCode('RECURSIVE_COMPILE_TIME_CONSTANT',
1965 "Compile-time constant expression depends on itself");
1966
1967 /**
1968 * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
1969 * in which case its only action is to invoke another generative constructor.
1970 *
1971 * TODO(scheglov) review this later, there are no explicit "it is a
1972 * compile-time error" in specification. But it was added to the co19 and
1973 * there is same error for factories.
1974 *
1975 * https://code.google.com/p/dart/issues/detail?id=954
1976 */
1977 static const CompileTimeErrorCode RECURSIVE_CONSTRUCTOR_REDIRECT =
1978 const CompileTimeErrorCode('RECURSIVE_CONSTRUCTOR_REDIRECT',
1979 "Cycle in redirecting generative constructors");
1980
1981 /**
1982 * 7.6.2 Factories: It is a compile-time error if a redirecting factory
1983 * constructor redirects to itself, either directly or indirectly via a
1984 * sequence of redirections.
1985 */
1986 static const CompileTimeErrorCode RECURSIVE_FACTORY_REDIRECT =
1987 const CompileTimeErrorCode('RECURSIVE_FACTORY_REDIRECT',
1988 "Cycle in redirecting factory constructors");
1989
1990 /**
1991 * 7.10 Superinterfaces: It is a compile-time error if the interface of a
1992 * class <i>C</i> is a superinterface of itself.
1993 *
1994 * 8.1 Superinterfaces: It is a compile-time error if an interface is a
1995 * superinterface of itself.
1996 *
1997 * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
1998 * superclass of itself.
1999 *
2000 * Parameters:
2001 * 0: the name of the class that implements itself recursively
2002 * 1: a string representation of the implements loop
2003 */
2004 static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE =
2005 const CompileTimeErrorCode('RECURSIVE_INTERFACE_INHERITANCE',
2006 "'{0}' cannot be a superinterface of itself: {1}");
2007
2008 /**
2009 * 7.10 Superinterfaces: It is a compile-time error if the interface of a
2010 * class <i>C</i> is a superinterface of itself.
2011 *
2012 * 8.1 Superinterfaces: It is a compile-time error if an interface is a
2013 * superinterface of itself.
2014 *
2015 * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
2016 * superclass of itself.
2017 *
2018 * Parameters:
2019 * 0: the name of the class that implements itself recursively
2020 */
2021 static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EX TENDS =
2022 const CompileTimeErrorCode(
2023 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS',
2024 "'{0}' cannot extend itself");
2025
2026 /**
2027 * 7.10 Superinterfaces: It is a compile-time error if the interface of a
2028 * class <i>C</i> is a superinterface of itself.
2029 *
2030 * 8.1 Superinterfaces: It is a compile-time error if an interface is a
2031 * superinterface of itself.
2032 *
2033 * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
2034 * superclass of itself.
2035 *
2036 * Parameters:
2037 * 0: the name of the class that implements itself recursively
2038 */
2039 static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IM PLEMENTS =
2040 const CompileTimeErrorCode(
2041 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS',
2042 "'{0}' cannot implement itself");
2043
2044 /**
2045 * 7.10 Superinterfaces: It is a compile-time error if the interface of a
2046 * class <i>C</i> is a superinterface of itself.
2047 *
2048 * 8.1 Superinterfaces: It is a compile-time error if an interface is a
2049 * superinterface of itself.
2050 *
2051 * 7.9 Superclasses: It is a compile-time error if a class <i>C</i> is a
2052 * superclass of itself.
2053 *
2054 * Parameters:
2055 * 0: the name of the class that implements itself recursively
2056 */
2057 static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WI TH =
2058 const CompileTimeErrorCode(
2059 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH',
2060 "'{0}' cannot use itself as a mixin");
2061
2062 /**
2063 * 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
2064 * the const modifier but <i>k'</i> is not a constant constructor.
2065 */
2066 static const CompileTimeErrorCode REDIRECT_TO_MISSING_CONSTRUCTOR =
2067 const CompileTimeErrorCode('REDIRECT_TO_MISSING_CONSTRUCTOR',
2068 "The constructor '{0}' could not be found in '{1}'");
2069
2070 /**
2071 * 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
2072 * the const modifier but <i>k'</i> is not a constant constructor.
2073 */
2074 static const CompileTimeErrorCode REDIRECT_TO_NON_CLASS =
2075 const CompileTimeErrorCode('REDIRECT_TO_NON_CLASS',
2076 "The name '{0}' is not a type and cannot be used in a redirected const ructor");
2077
2078 /**
2079 * 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with
2080 * the const modifier but <i>k'</i> is not a constant constructor.
2081 */
2082 static const CompileTimeErrorCode REDIRECT_TO_NON_CONST_CONSTRUCTOR =
2083 const CompileTimeErrorCode('REDIRECT_TO_NON_CONST_CONSTRUCTOR',
2084 "Constant factory constructor cannot delegate to a non-constant constr uctor");
2085
2086 /**
2087 * 7.6.1 Generative constructors: A generative constructor may be
2088 * <i>redirecting</i>, in which case its only action is to invoke another
2089 * generative constructor.
2090 */
2091 static const CompileTimeErrorCode REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR =
2092 const CompileTimeErrorCode('REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR',
2093 "The constructor '{0}' could not be found in '{1}'");
2094
2095 /**
2096 * 7.6.1 Generative constructors: A generative constructor may be
2097 * <i>redirecting</i>, in which case its only action is to invoke another
2098 * generative constructor.
2099 */
2100 static const CompileTimeErrorCode REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTR UCTOR =
2101 const CompileTimeErrorCode(
2102 'REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR',
2103 "Generative constructor cannot redirect to a factory constructor");
2104
2105 /**
2106 * 5 Variables: A local variable may only be referenced at a source code
2107 * location that is after its initializer, if any, is complete, or a
2108 * compile-time error occurs.
2109 */
2110 static const CompileTimeErrorCode REFERENCED_BEFORE_DECLARATION =
2111 const CompileTimeErrorCode('REFERENCED_BEFORE_DECLARATION',
2112 "Local variables cannot be referenced before they are declared");
2113
2114 /**
2115 * 12.8.1 Rethrow: It is a compile-time error if an expression of the form
2116 * <i>rethrow;</i> is not enclosed within a on-catch clause.
2117 */
2118 static const CompileTimeErrorCode RETHROW_OUTSIDE_CATCH =
2119 const CompileTimeErrorCode(
2120 'RETHROW_OUTSIDE_CATCH', "rethrow must be inside of a catch clause");
2121
2122 /**
2123 * 13.12 Return: It is a compile-time error if a return statement of the form
2124 * <i>return e;</i> appears in a generative constructor.
2125 */
2126 static const CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR =
2127 const CompileTimeErrorCode('RETURN_IN_GENERATIVE_CONSTRUCTOR',
2128 "Constructors cannot return a value");
2129
2130 /**
2131 * 13.12 Return: It is a compile-time error if a return statement of the form
2132 * <i>return e;</i> appears in a generator function.
2133 */
2134 static const CompileTimeErrorCode RETURN_IN_GENERATOR =
2135 const CompileTimeErrorCode('RETURN_IN_GENERATOR',
2136 "Cannot return a value from a generator function (one marked with eith er 'async*' or 'sync*')");
2137
2138 /**
2139 * 14.1 Imports: It is a compile-time error if a prefix used in a deferred
2140 * import is used in another import clause.
2141 */
2142 static const CompileTimeErrorCode SHARED_DEFERRED_PREFIX =
2143 const CompileTimeErrorCode('SHARED_DEFERRED_PREFIX',
2144 "The prefix of a deferred import cannot be used in other import direct ives");
2145
2146 /**
2147 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
2148 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
2149 * a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a
2150 * compile-time error if a super method invocation occurs in a top-level
2151 * function or variable initializer, in an instance variable initializer or
2152 * initializer list, in class Object, in a factory constructor, or in a static
2153 * method or variable initializer.
2154 */
2155 static const CompileTimeErrorCode SUPER_IN_INVALID_CONTEXT =
2156 const CompileTimeErrorCode(
2157 'SUPER_IN_INVALID_CONTEXT', "Invalid context for 'super' invocation");
2158
2159 /**
2160 * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
2161 * in which case its only action is to invoke another generative constructor.
2162 */
2163 static const CompileTimeErrorCode SUPER_IN_REDIRECTING_CONSTRUCTOR =
2164 const CompileTimeErrorCode('SUPER_IN_REDIRECTING_CONSTRUCTOR',
2165 "The redirecting constructor cannot have a 'super' initializer");
2166
2167 /**
2168 * 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It
2169 * is a compile-time error if a generative constructor of class Object
2170 * includes a superinitializer.
2171 */
2172 static const CompileTimeErrorCode SUPER_INITIALIZER_IN_OBJECT =
2173 const CompileTimeErrorCode('SUPER_INITIALIZER_IN_OBJECT', "");
2174
2175 /**
2176 * 12.11 Instance Creation: It is a static type warning if any of the type
2177 * arguments to a constructor of a generic type <i>G</i> invoked by a new
2178 * expression or a constant object expression are not subtypes of the bounds
2179 * of the corresponding formal type parameters of <i>G</i>.
2180 *
2181 * 12.11.1 New: If T is malformed a dynamic error occurs. In checked mode, if
2182 * T is mal-bounded a dynamic error occurs.
2183 *
2184 * 12.1 Constants: It is a compile-time error if evaluation of a compile-time
2185 * constant would raise an exception.
2186 *
2187 * Parameters:
2188 * 0: the name of the type used in the instance creation that should be
2189 * limited by the bound as specified in the class declaration
2190 * 1: the name of the bounding type
2191 *
2192 * See [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
2193 */
2194 static const CompileTimeErrorCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
2195 const CompileTimeErrorCode(
2196 'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', "'{0}' does not extend '{1}'");
2197
2198 /**
2199 * 15.3.1 Typedef: Any self reference, either directly, or recursively via
2200 * another typedef, is a compile time error.
2201 */
2202 static const CompileTimeErrorCode TYPE_ALIAS_CANNOT_REFERENCE_ITSELF =
2203 const CompileTimeErrorCode('TYPE_ALIAS_CANNOT_REFERENCE_ITSELF',
2204 "Type alias cannot reference itself directly or recursively via anothe r typedef");
2205
2206 /**
2207 * 12.11.2 Const: It is a compile-time error if <i>T</i> is not a class
2208 * accessible in the current scope, optionally followed by type arguments.
2209 */
2210 static const CompileTimeErrorCode UNDEFINED_CLASS =
2211 const CompileTimeErrorCode('UNDEFINED_CLASS', "Undefined class '{0}'");
2212
2213 /**
2214 * 7.6.1 Generative Constructors: Let <i>C</i> be the class in which the
2215 * superinitializer appears and let <i>S</i> be the superclass of <i>C</i>.
2216 * Let <i>k</i> be a generative constructor. It is a compile-time error if
2217 * class <i>S</i> does not declare a generative constructor named <i>S</i>
2218 * (respectively <i>S.id</i>)
2219 */
2220 static const CompileTimeErrorCode UNDEFINED_CONSTRUCTOR_IN_INITIALIZER =
2221 const CompileTimeErrorCode('UNDEFINED_CONSTRUCTOR_IN_INITIALIZER',
2222 "The class '{0}' does not have a generative constructor '{1}'");
2223
2224 /**
2225 * 7.6.1 Generative Constructors: Let <i>C</i> be the class in which the
2226 * superinitializer appears and let <i>S</i> be the superclass of <i>C</i>.
2227 * Let <i>k</i> be a generative constructor. It is a compile-time error if
2228 * class <i>S</i> does not declare a generative constructor named <i>S</i>
2229 * (respectively <i>S.id</i>)
2230 */
2231 static const CompileTimeErrorCode UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT =
2232 const CompileTimeErrorCode('UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT',
2233 "The class '{0}' does not have a default generative constructor");
2234
2235 /**
2236 * 12.14.2 Binding Actuals to Formals: Furthermore, each <i>q<sub>i</sub></i>,
2237 * <i>1<=i<=l</i>, must have a corresponding named parameter in the set
2238 * {<i>p<sub>n+1</sub></i> ... <i>p<sub>n+k</sub></i>} or a static warning
2239 * occurs.
2240 *
2241 * 12.11.2 Const: It is a compile-time error if evaluation of a constant
2242 * object results in an uncaught exception being thrown.
2243 *
2244 * Parameters:
2245 * 0: the name of the requested named parameter
2246 */
2247 static const CompileTimeErrorCode UNDEFINED_NAMED_PARAMETER =
2248 const CompileTimeErrorCode('UNDEFINED_NAMED_PARAMETER',
2249 "The named parameter '{0}' is not defined");
2250
2251 /**
2252 * 14.2 Exports: It is a compile-time error if the compilation unit found at
2253 * the specified URI is not a library declaration.
2254 *
2255 * 14.1 Imports: It is a compile-time error if the compilation unit found at
2256 * the specified URI is not a library declaration.
2257 *
2258 * 14.3 Parts: It is a compile time error if the contents of the URI are not a
2259 * valid part declaration.
2260 *
2261 * Parameters:
2262 * 0: the URI pointing to a non-existent file
2263 *
2264 * See [INVALID_URI].
2265 */
2266 static const CompileTimeErrorCode URI_DOES_NOT_EXIST =
2267 const CompileTimeErrorCode(
2268 'URI_DOES_NOT_EXIST', "Target of URI does not exist: '{0}'");
2269
2270 /**
2271 * 14.1 Imports: It is a compile-time error if <i>x</i> is not a compile-time
2272 * constant, or if <i>x</i> involves string interpolation.
2273 *
2274 * 14.3 Parts: It is a compile-time error if <i>s</i> is not a compile-time
2275 * constant, or if <i>s</i> involves string interpolation.
2276 *
2277 * 14.5 URIs: It is a compile-time error if the string literal <i>x</i> that
2278 * describes a URI is not a compile-time constant, or if <i>x</i> involves
2279 * string interpolation.
2280 */
2281 static const CompileTimeErrorCode URI_WITH_INTERPOLATION =
2282 const CompileTimeErrorCode(
2283 'URI_WITH_INTERPOLATION', "URIs cannot use string interpolation");
2284
2285 /**
2286 * 7.1.1 Operators: It is a compile-time error if the arity of the
2287 * user-declared operator []= is not 2. It is a compile time error if the
2288 * arity of a user-declared operator with one of the names: &lt;, &gt;, &lt;=,
2289 * &gt;=, ==, +, /, ~/, *, %, |, ^, &, &lt;&lt;, &gt;&gt;, [] is not 1. It is
2290 * a compile time error if the arity of the user-declared operator - is not 0
2291 * or 1. It is a compile time error if the arity of the user-declared operator
2292 * ~ is not 0.
2293 *
2294 * Parameters:
2295 * 0: the name of the declared operator
2296 * 1: the number of parameters expected
2297 * 2: the number of parameters found in the operator declaration
2298 */
2299 static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR =
2300 const CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
2301 "Operator '{0}' should declare exactly {1} parameter(s), but {2} found ");
2302
2303 /**
2304 * 7.1.1 Operators: It is a compile time error if the arity of the
2305 * user-declared operator - is not 0 or 1.
2306 *
2307 * Parameters:
2308 * 0: the number of parameters found in the operator declaration
2309 */
2310 static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINU S =
2311 const CompileTimeErrorCode(
2312 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS',
2313 "Operator '-' should declare 0 or 1 parameter, but {0} found");
2314
2315 /**
2316 * 7.3 Setters: It is a compile-time error if a setter's formal parameter list
2317 * does not include exactly one required formal parameter <i>p</i>.
2318 */
2319 static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER =
2320 const CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER',
2321 "Setters should declare exactly one required parameter");
2322
2323 /**
2324 * ?? Yield: It is a compile-time error if a yield statement appears in a
2325 * function that is not a generator function.
2326 */
2327 static const CompileTimeErrorCode YIELD_EACH_IN_NON_GENERATOR =
2328 const CompileTimeErrorCode('YIELD_EACH_IN_NON_GENERATOR',
2329 "Yield-each statements must be in a generator function (one marked wit h either 'async*' or 'sync*')");
2330
2331 /**
2332 * ?? Yield: It is a compile-time error if a yield statement appears in a
2333 * function that is not a generator function.
2334 */
2335 static const CompileTimeErrorCode YIELD_IN_NON_GENERATOR =
2336 const CompileTimeErrorCode('YIELD_IN_NON_GENERATOR',
2337 "Yield statements must be in a generator function (one marked with eit her 'async*' or 'sync*')");
2338
2339 /**
2340 * Initialize a newly created error code to have the given [name]. The message
2341 * associated with the error will be created from the given [message]
2342 * template. The correction associated with the error will be created from the
2343 * given [correction] template.
2344 */
2345 const CompileTimeErrorCode(String name, String message, [String correction])
2346 : super(name, message, correction);
2347
2348 @override
2349 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
2350
2351 @override
2352 ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
2353 }
2354
2355 /**
2356 * An error code associated with an [AnalysisError].
2357 *
2358 * Generally, we want to provide messages that consist of three sentences. From
2359 * the user's perspective these sentences should explain:
2360 * 1. what is wrong,
2361 * 2. why is it wrong, and
2362 * 3. how do I fix it.
2363 * However, we combine the first two in the [message] and the last in the
2364 * [correction].
2365 */
2366 abstract class ErrorCode {
2367 /**
2368 * An empty list of error codes.
2369 */
2370 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[];
2371
2372 /**
2373 * The name of the error code.
2374 */
2375 final String name;
2376
2377 /**
2378 * The template used to create the message to be displayed for this error. The
2379 * message should indicate what is wrong and why it is wrong.
2380 */
2381 final String message;
2382
2383 /**
2384 * The template used to create the correction to be displayed for this error,
2385 * or `null` if there is no correction information for this error. The
2386 * correction should indicate how the user can fix the error.
2387 */
2388 final String correction;
2389
2390 /**
2391 * Initialize a newly created error code to have the given [name]. The message
2392 * associated with the error will be created from the given [message]
2393 * template. The correction associated with the error will be created from the
2394 * given [correction] template.
2395 */
2396 const ErrorCode(this.name, this.message, [this.correction]);
2397
2398 /**
2399 * The severity of the error.
2400 */
2401 ErrorSeverity get errorSeverity;
2402
2403 /**
2404 * The type of the error.
2405 */
2406 ErrorType get type;
2407
2408 /**
2409 * The unique name of this error code.
2410 */
2411 String get uniqueName => "$runtimeType.$name";
2412 }
2413
2414 /**
2415 * The properties that can be associated with an [AnalysisError].
2416 */
2417 class ErrorProperty extends Enum<ErrorProperty> {
2418 /**
2419 * A property whose value is a list of [FieldElement]s that are final, but
2420 * not initialized by a constructor.
2421 */
2422 static const ErrorProperty NOT_INITIALIZED_FIELDS =
2423 const ErrorProperty('NOT_INITIALIZED_FIELDS', 0);
2424
2425 /**
2426 * A property whose value is the name of the library that is used by all
2427 * of the "part of" directives, so should be used in the "library" directive.
2428 * Is `null` if there is no a single name used by all of the parts.
2429 */
2430 static const ErrorProperty PARTS_LIBRARY_NAME =
2431 const ErrorProperty('PARTS_LIBRARY_NAME', 1);
2432
2433 /**
2434 * A property whose value is a list of [ExecutableElement] that should
2435 * be but are not implemented by a concrete class.
2436 */
2437 static const ErrorProperty UNIMPLEMENTED_METHODS =
2438 const ErrorProperty('UNIMPLEMENTED_METHODS', 2);
2439
2440 static const List<ErrorProperty> values = const [
2441 NOT_INITIALIZED_FIELDS,
2442 PARTS_LIBRARY_NAME,
2443 UNIMPLEMENTED_METHODS
2444 ];
2445
2446 const ErrorProperty(String name, int ordinal) : super(name, ordinal);
2447 }
2448
2449 /**
2450 * An object used to create analysis errors and report then to an error
2451 * listener.
2452 */
2453 class ErrorReporter {
2454 /**
2455 * The error listener to which errors will be reported.
2456 */
2457 final AnalysisErrorListener _errorListener;
2458
2459 /**
2460 * The default source to be used when reporting errors.
2461 */
2462 final Source _defaultSource;
2463
2464 /**
2465 * The source to be used when reporting errors.
2466 */
2467 Source _source;
2468
2469 /**
2470 * Initialize a newly created error reporter that will report errors to the
2471 * given [_errorListener]. Errors will be reported against the
2472 * [_defaultSource] unless another source is provided later.
2473 */
2474 ErrorReporter(this._errorListener, this._defaultSource) {
2475 if (_errorListener == null) {
2476 throw new IllegalArgumentException("An error listener must be provided");
2477 } else if (_defaultSource == null) {
2478 throw new IllegalArgumentException("A default source must be provided");
2479 }
2480 this._source = _defaultSource;
2481 }
2482
2483 Source get source => _source;
2484
2485 /**
2486 * Set the source to be used when reporting errors to the given [source].
2487 * Setting the source to `null` will cause the default source to be used.
2488 */
2489 void set source(Source source) {
2490 this._source = source == null ? _defaultSource : source;
2491 }
2492
2493 /**
2494 * Creates an error with properties with the given [errorCode] and
2495 * [arguments]. The [node] is used to compute the location of the error.
2496 */
2497 AnalysisErrorWithProperties newErrorWithProperties(
2498 ErrorCode errorCode, AstNode node, List<Object> arguments) =>
2499 new AnalysisErrorWithProperties(
2500 _source, node.offset, node.length, errorCode, arguments);
2501
2502 /**
2503 * Report the given [error].
2504 */
2505 void reportError(AnalysisError error) {
2506 _errorListener.onError(error);
2507 }
2508
2509 /**
2510 * Report an error with the given [errorCode] and [arguments]. The [element]
2511 * is used to compute the location of the error.
2512 */
2513 void reportErrorForElement(
2514 ErrorCode errorCode, Element element, List<Object> arguments) {
2515 String displayName = element.displayName;
2516 int length = 0;
2517 if (displayName != null) {
2518 length = displayName.length;
2519 } else if (element is ImportElement) {
2520 length = 6; // 'import'.length
2521 } else if (element is ExportElement) {
2522 length = 6; // 'export'.length
2523 }
2524 reportErrorForOffset(errorCode, element.nameOffset, length, arguments);
2525 }
2526
2527 /**
2528 * Report an error with the given [errorCode] and [arguments].
2529 * The [node] is used to compute the location of the error.
2530 *
2531 * If the arguments contain the names of two or more types, the method
2532 * [reportTypeErrorForNode] should be used and the types
2533 * themselves (rather than their names) should be passed as arguments.
2534 */
2535 void reportErrorForNode(ErrorCode errorCode, AstNode node,
2536 [List<Object> arguments]) {
2537 reportErrorForOffset(errorCode, node.offset, node.length, arguments);
2538 }
2539
2540 /**
2541 * Report an error with the given [errorCode] and [arguments]. The location of
2542 * the error is specified by the given [offset] and [length].
2543 */
2544 void reportErrorForOffset(ErrorCode errorCode, int offset, int length,
2545 [List<Object> arguments]) {
2546 _errorListener.onError(
2547 new AnalysisError(_source, offset, length, errorCode, arguments));
2548 }
2549
2550 /**
2551 * Report an error with the given [errorCode] and [arguments]. The [token] is
2552 * used to compute the location of the error.
2553 */
2554 void reportErrorForToken(ErrorCode errorCode, Token token,
2555 [List<Object> arguments]) {
2556 reportErrorForOffset(errorCode, token.offset, token.length, arguments);
2557 }
2558
2559 /**
2560 * Report an error with the given [errorCode] and [arguments]. The [node] is
2561 * used to compute the location of the error. The arguments are expected to
2562 * contain two or more types. Convert the types into strings by using the
2563 * display names of the types, unless there are two or more types with the
2564 * same names, in which case the extended display names of the types will be
2565 * used in order to clarify the message.
2566 *
2567 * If there are not two or more types in the argument list, the method
2568 * [reportErrorForNode] should be used instead.
2569 */
2570 void reportTypeErrorForNode(
2571 ErrorCode errorCode, AstNode node, List<Object> arguments) {
2572 _convertTypeNames(arguments);
2573 reportErrorForOffset(errorCode, node.offset, node.length, arguments);
2574 }
2575
2576 /**
2577 * Given an array of [arguments] that is expected to contain two or more
2578 * types, convert the types into strings by using the display names of the
2579 * types, unless there are two or more types with the same names, in which
2580 * case the extended display names of the types will be used in order to
2581 * clarify the message.
2582 */
2583 void _convertTypeNames(List<Object> arguments) {
2584 if (_hasEqualTypeNames(arguments)) {
2585 int count = arguments.length;
2586 for (int i = 0; i < count; i++) {
2587 Object argument = arguments[i];
2588 if (argument is DartType) {
2589 DartType type = argument;
2590 Element element = type.element;
2591 if (element == null) {
2592 arguments[i] = type.displayName;
2593 } else {
2594 arguments[i] = element.getExtendedDisplayName(type.displayName);
2595 }
2596 }
2597 }
2598 } else {
2599 int count = arguments.length;
2600 for (int i = 0; i < count; i++) {
2601 Object argument = arguments[i];
2602 if (argument is DartType) {
2603 arguments[i] = argument.displayName;
2604 }
2605 }
2606 }
2607 }
2608
2609 /**
2610 * Return `true` if the given array of [arguments] contains two or more types
2611 * with the same display name.
2612 */
2613 bool _hasEqualTypeNames(List<Object> arguments) {
2614 int count = arguments.length;
2615 HashSet<String> typeNames = new HashSet<String>();
2616 for (int i = 0; i < count; i++) {
2617 if (arguments[i] is DartType &&
2618 !typeNames.add((arguments[i] as DartType).displayName)) {
2619 return true;
2620 }
2621 }
2622 return false;
2623 }
2624 }
2625
2626 /**
2627 * The severity of an [ErrorCode].
2628 */
2629 class ErrorSeverity extends Enum<ErrorSeverity> {
2630 /**
2631 * The severity representing a non-error. This is never used for any error
2632 * code, but is useful for clients.
2633 */
2634 static const ErrorSeverity NONE = const ErrorSeverity('NONE', 0, " ", "none");
2635
2636 /**
2637 * The severity representing an informational level analysis issue.
2638 */
2639 static const ErrorSeverity INFO = const ErrorSeverity('INFO', 1, "I", "info");
2640
2641 /**
2642 * The severity representing a warning. Warnings can become errors if the `-We rror` command
2643 * line flag is specified.
2644 */
2645 static const ErrorSeverity WARNING =
2646 const ErrorSeverity('WARNING', 2, "W", "warning");
2647
2648 /**
2649 * The severity representing an error.
2650 */
2651 static const ErrorSeverity ERROR =
2652 const ErrorSeverity('ERROR', 3, "E", "error");
2653
2654 static const List<ErrorSeverity> values = const [NONE, INFO, WARNING, ERROR];
2655
2656 /**
2657 * The name of the severity used when producing machine output.
2658 */
2659 final String machineCode;
2660
2661 /**
2662 * The name of the severity used when producing readable output.
2663 */
2664 final String displayName;
2665
2666 /**
2667 * Initialize a newly created severity with the given names.
2668 *
2669 * Parameters:
2670 * 0: the name of the severity used when producing machine output
2671 * 1: the name of the severity used when producing readable output
2672 */
2673 const ErrorSeverity(
2674 String name, int ordinal, this.machineCode, this.displayName)
2675 : super(name, ordinal);
2676
2677 /**
2678 * Return the severity constant that represents the greatest severity.
2679 */
2680 ErrorSeverity max(ErrorSeverity severity) =>
2681 this.ordinal >= severity.ordinal ? this : severity;
2682 }
2683
2684 /**
2685 * The type of an [ErrorCode].
2686 */
2687 class ErrorType extends Enum<ErrorType> {
2688 /**
2689 * Task (todo) comments in user code.
2690 */
2691 static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO);
2692
2693 /**
2694 * Extra analysis run over the code to follow best practices, which are not in
2695 * the Dart Language Specification.
2696 */
2697 static const ErrorType HINT = const ErrorType('HINT', 1, ErrorSeverity.INFO);
2698
2699 /**
2700 * Compile-time errors are errors that preclude execution. A compile time
2701 * error must be reported by a Dart compiler before the erroneous code is
2702 * executed.
2703 */
2704 static const ErrorType COMPILE_TIME_ERROR =
2705 const ErrorType('COMPILE_TIME_ERROR', 2, ErrorSeverity.ERROR);
2706
2707 /**
2708 * Checked mode compile-time errors are errors that preclude execution in
2709 * checked mode.
2710 */
2711 static const ErrorType CHECKED_MODE_COMPILE_TIME_ERROR = const ErrorType(
2712 'CHECKED_MODE_COMPILE_TIME_ERROR', 3, ErrorSeverity.ERROR);
2713
2714 /**
2715 * Static warnings are those warnings reported by the static checker. They
2716 * have no effect on execution. Static warnings must be provided by Dart
2717 * compilers used during development.
2718 */
2719 static const ErrorType STATIC_WARNING =
2720 const ErrorType('STATIC_WARNING', 4, ErrorSeverity.WARNING);
2721
2722 /**
2723 * Many, but not all, static warnings relate to types, in which case they are
2724 * known as static type warnings.
2725 */
2726 static const ErrorType STATIC_TYPE_WARNING =
2727 const ErrorType('STATIC_TYPE_WARNING', 5, ErrorSeverity.WARNING);
2728
2729 /**
2730 * Syntactic errors are errors produced as a result of input that does not
2731 * conform to the grammar.
2732 */
2733 static const ErrorType SYNTACTIC_ERROR =
2734 const ErrorType('SYNTACTIC_ERROR', 6, ErrorSeverity.ERROR);
2735
2736 /**
2737 * Lint warnings describe style and best practice recommendations that can be
2738 * used to formalize a project's style guidelines.
2739 */
2740 static const ErrorType LINT = const ErrorType('LINT', 7, ErrorSeverity.INFO);
2741
2742 static const List<ErrorType> values = const [
2743 TODO,
2744 HINT,
2745 COMPILE_TIME_ERROR,
2746 CHECKED_MODE_COMPILE_TIME_ERROR,
2747 STATIC_WARNING,
2748 STATIC_TYPE_WARNING,
2749 SYNTACTIC_ERROR,
2750 LINT
2751 ];
2752
2753 /**
2754 * The severity of this type of error.
2755 */
2756 final ErrorSeverity severity;
2757
2758 /**
2759 * Initialize a newly created error type to have the given [name] and
2760 * [severity].
2761 */
2762 const ErrorType(String name, int ordinal, this.severity)
2763 : super(name, ordinal);
2764
2765 String get displayName => name.toLowerCase().replaceAll('_', ' ');
2766 }
2767
2768 /**
2769 * The hints and coding recommendations for best practices which are not
2770 * mentioned in the Dart Language Specification.
2771 */
2772 class HintCode extends ErrorCode {
2773 /**
2774 * This hint is generated anywhere where the
2775 * [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated,
2776 * if we used propagated information for the warnings.
2777 *
2778 * Parameters:
2779 * 0: the name of the actual argument type
2780 * 1: the name of the expected type
2781 */
2782 static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE = const HintCode(
2783 'ARGUMENT_TYPE_NOT_ASSIGNABLE',
2784 "The argument type '{0}' cannot be assigned to the parameter type '{1}'");
2785
2786 /**
2787 * Dead code is code that is never reached, this can happen for instance if a
2788 * statement follows a return statement.
2789 */
2790 static const HintCode DEAD_CODE = const HintCode('DEAD_CODE', "Dead code");
2791
2792 /**
2793 * Dead code is code that is never reached. This case covers cases where the
2794 * user has catch clauses after `catch (e)` or `on Object catch (e)`.
2795 */
2796 static const HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = const HintCode(
2797 'DEAD_CODE_CATCH_FOLLOWING_CATCH',
2798 "Dead code, catch clauses after a 'catch (e)' or an 'on Object catch (e)' are never reached");
2799
2800 /**
2801 * Dead code is code that is never reached. This case covers cases where the
2802 * user has an on-catch clause such as `on A catch (e)`, where a supertype of
2803 * `A` was already caught.
2804 *
2805 * Parameters:
2806 * 0: name of the subtype
2807 * 1: name of the supertype
2808 */
2809 static const HintCode DEAD_CODE_ON_CATCH_SUBTYPE = const HintCode(
2810 'DEAD_CODE_ON_CATCH_SUBTYPE',
2811 "Dead code, this on-catch block will never be executed since '{0}' is a su btype of '{1}'");
2812
2813 /**
2814 * Deprecated members should not be invoked or used.
2815 *
2816 * Parameters:
2817 * 0: the name of the member
2818 */
2819 static const HintCode DEPRECATED_MEMBER_USE =
2820 const HintCode('DEPRECATED_MEMBER_USE', "'{0}' is deprecated");
2821
2822 /**
2823 * Duplicate imports.
2824 */
2825 static const HintCode DUPLICATE_IMPORT =
2826 const HintCode('DUPLICATE_IMPORT', "Duplicate import");
2827
2828 /**
2829 * Hint to use the ~/ operator.
2830 */
2831 static const HintCode DIVISION_OPTIMIZATION = const HintCode(
2832 'DIVISION_OPTIMIZATION',
2833 "The operator x ~/ y is more efficient than (x / y).toInt()");
2834
2835 /**
2836 * Hint for the `x is double` type checks.
2837 */
2838 static const HintCode IS_DOUBLE = const HintCode('IS_DOUBLE',
2839 "When compiled to JS, this test might return true when the left hand side is an int");
2840
2841 /**
2842 * Hint for the `x is int` type checks.
2843 */
2844 static const HintCode IS_INT = const HintCode('IS_INT',
2845 "When compiled to JS, this test might return true when the left hand side is a double");
2846
2847 /**
2848 * Hint for the `x is! double` type checks.
2849 */
2850 static const HintCode IS_NOT_DOUBLE = const HintCode('IS_NOT_DOUBLE',
2851 "When compiled to JS, this test might return false when the left hand side is an int");
2852
2853 /**
2854 * Hint for the `x is! int` type checks.
2855 */
2856 static const HintCode IS_NOT_INT = const HintCode('IS_NOT_INT',
2857 "When compiled to JS, this test might return false when the left hand side is a double");
2858
2859 /**
2860 * Deferred libraries shouldn't define a top level function 'loadLibrary'.
2861 */
2862 static const HintCode IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION = const HintC ode(
2863 'IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION',
2864 "The library '{0}' defines a top-level function named 'loadLibrary' which is hidden by deferring this library");
2865
2866 /**
2867 * This hint is generated anywhere where the
2868 * [StaticTypeWarningCode.INVALID_ASSIGNMENT] would have been generated, if we
2869 * used propagated information for the warnings.
2870 *
2871 * Parameters:
2872 * 0: the name of the right hand side type
2873 * 1: the name of the left hand side type
2874 */
2875 static const HintCode INVALID_ASSIGNMENT = const HintCode(
2876 'INVALID_ASSIGNMENT',
2877 "A value of type '{0}' cannot be assigned to a variable of type '{1}'");
2878
2879 /**
2880 * Generate a hint for methods or functions that have a return type, but do
2881 * not have a non-void return statement on all branches. At the end of methods
2882 * or functions with no return, Dart implicitly returns `null`, avoiding these
2883 * implicit returns is considered a best practice.
2884 *
2885 * Parameters:
2886 * 0: the name of the declared return type
2887 */
2888 static const HintCode MISSING_RETURN = const HintCode('MISSING_RETURN',
2889 "This function declares a return type of '{0}', but does not end with a re turn statement",
2890 "Either add a return statement or change the return type to 'void'");
2891
2892 /**
2893 * A getter with the override annotation does not override an existing getter.
2894 */
2895 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode(
2896 'OVERRIDE_ON_NON_OVERRIDING_GETTER',
2897 "Getter does not override an inherited getter");
2898
2899 /**
2900 * A method with the override annotation does not override an existing method.
2901 */
2902 static const HintCode OVERRIDE_ON_NON_OVERRIDING_METHOD = const HintCode(
2903 'OVERRIDE_ON_NON_OVERRIDING_METHOD',
2904 "Method does not override an inherited method");
2905
2906 /**
2907 * A setter with the override annotation does not override an existing setter.
2908 */
2909 static const HintCode OVERRIDE_ON_NON_OVERRIDING_SETTER = const HintCode(
2910 'OVERRIDE_ON_NON_OVERRIDING_SETTER',
2911 "Setter does not override an inherited setter");
2912
2913 /**
2914 * Hint for classes that override equals, but not hashCode.
2915 *
2916 * Parameters:
2917 * 0: the name of the current class
2918 */
2919 static const HintCode OVERRIDE_EQUALS_BUT_NOT_HASH_CODE = const HintCode(
2920 'OVERRIDE_EQUALS_BUT_NOT_HASH_CODE',
2921 "The class '{0}' overrides 'operator==', but not 'get hashCode'");
2922
2923 /**
2924 * Type checks of the type `x is! Null` should be done with `x != null`.
2925 */
2926 static const HintCode TYPE_CHECK_IS_NOT_NULL = const HintCode(
2927 'TYPE_CHECK_IS_NOT_NULL',
2928 "Tests for non-null should be done with '!= null'");
2929
2930 /**
2931 * Type checks of the type `x is Null` should be done with `x == null`.
2932 */
2933 static const HintCode TYPE_CHECK_IS_NULL = const HintCode(
2934 'TYPE_CHECK_IS_NULL', "Tests for null should be done with '== null'");
2935
2936 /**
2937 * This hint is generated anywhere where the
2938 * [StaticTypeWarningCode.UNDEFINED_GETTER] or
2939 * [StaticWarningCode.UNDEFINED_GETTER] would have been generated, if we used
2940 * propagated information for the warnings.
2941 *
2942 * Parameters:
2943 * 0: the name of the getter
2944 * 1: the name of the enclosing type where the getter is being looked for
2945 */
2946 static const HintCode UNDEFINED_GETTER = const HintCode('UNDEFINED_GETTER',
2947 "The getter '{0}' is not defined for the class '{1}'");
2948
2949 /**
2950 * This hint is generated anywhere where the
2951 * [StaticTypeWarningCode.UNDEFINED_METHOD] would have been generated, if we
2952 * used propagated information for the warnings.
2953 *
2954 * Parameters:
2955 * 0: the name of the method that is undefined
2956 * 1: the resolved type name that the method lookup is happening on
2957 */
2958 static const HintCode UNDEFINED_METHOD = const HintCode('UNDEFINED_METHOD',
2959 "The method '{0}' is not defined for the class '{1}'");
2960
2961 /**
2962 * This hint is generated anywhere where the
2963 * [StaticTypeWarningCode.UNDEFINED_OPERATOR] would have been generated, if we
2964 * used propagated information for the warnings.
2965 *
2966 * Parameters:
2967 * 0: the name of the operator
2968 * 1: the name of the enclosing type where the operator is being looked for
2969 */
2970 static const HintCode UNDEFINED_OPERATOR = const HintCode(
2971 'UNDEFINED_OPERATOR',
2972 "The operator '{0}' is not defined for the class '{1}'");
2973
2974 /**
2975 * This hint is generated anywhere where the
2976 * [StaticTypeWarningCode.UNDEFINED_SETTER] or
2977 * [StaticWarningCode.UNDEFINED_SETTER] would have been generated, if we used
2978 * propagated information for the warnings.
2979 *
2980 * Parameters:
2981 * 0: the name of the setter
2982 * 1: the name of the enclosing type where the setter is being looked for
2983 */
2984 static const HintCode UNDEFINED_SETTER = const HintCode('UNDEFINED_SETTER',
2985 "The setter '{0}' is not defined for the class '{1}'");
2986
2987 /**
2988 * Unnecessary cast.
2989 */
2990 static const HintCode UNNECESSARY_CAST =
2991 const HintCode('UNNECESSARY_CAST', "Unnecessary cast");
2992
2993 /**
2994 * Unnecessary type checks, the result is always true.
2995 */
2996 static const HintCode UNNECESSARY_TYPE_CHECK_FALSE = const HintCode(
2997 'UNNECESSARY_TYPE_CHECK_FALSE',
2998 "Unnecessary type check, the result is always false");
2999
3000 /**
3001 * Unnecessary type checks, the result is always false.
3002 */
3003 static const HintCode UNNECESSARY_TYPE_CHECK_TRUE = const HintCode(
3004 'UNNECESSARY_TYPE_CHECK_TRUE',
3005 "Unnecessary type check, the result is always true");
3006
3007 /**
3008 * See [Modifier.IS_USED_IN_LIBRARY].
3009 */
3010 static const HintCode UNUSED_ELEMENT =
3011 const HintCode('UNUSED_ELEMENT', "The {0} '{1}' is not used");
3012
3013 /**
3014 * Unused fields are fields which are never read.
3015 */
3016 static const HintCode UNUSED_FIELD = const HintCode(
3017 'UNUSED_FIELD', "The value of the field '{0}' is not used");
3018
3019 /**
3020 * Unused imports are imports which are never used.
3021 */
3022 static const HintCode UNUSED_IMPORT =
3023 const HintCode('UNUSED_IMPORT', "Unused import");
3024
3025 /**
3026 * Unused catch exception variables.
3027 */
3028 static const HintCode UNUSED_CATCH_CLAUSE = const HintCode(
3029 'UNUSED_CATCH_CLAUSE',
3030 "The exception variable '{0}' is not used, so the 'catch' clause can be re moved");
3031
3032 /**
3033 * Unused catch stack trace variables.
3034 */
3035 static const HintCode UNUSED_CATCH_STACK = const HintCode(
3036 'UNUSED_CATCH_STACK',
3037 "The stack trace variable '{0}' is not used and can be removed");
3038
3039 /**
3040 * Unused local variables are local varaibles which are never read.
3041 */
3042 static const HintCode UNUSED_LOCAL_VARIABLE = const HintCode(
3043 'UNUSED_LOCAL_VARIABLE',
3044 "The value of the local variable '{0}' is not used");
3045
3046 /**
3047 * Hint for cases where the source expects a method or function to return a
3048 * non-void result, but the method or function signature returns void.
3049 *
3050 * Parameters:
3051 * 0: the name of the method or function that returns void
3052 */
3053 static const HintCode USE_OF_VOID_RESULT = const HintCode(
3054 'USE_OF_VOID_RESULT',
3055 "The result of '{0}' is being used, even though it is declared to be 'void '");
3056
3057 /**
3058 * It is a bad practice for a source file in a package "lib" directory
3059 * hierarchy to traverse outside that directory hierarchy. For example, a
3060 * source file in the "lib" directory should not contain a directive such as
3061 * `import '../web/some.dart'` which references a file outside the lib
3062 * directory.
3063 */
3064 static const HintCode FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE =
3065 const HintCode('FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE',
3066 "A file in the 'lib' directory hierarchy should not reference a file o utside that hierarchy");
3067
3068 /**
3069 * It is a bad practice for a source file ouside a package "lib" directory
3070 * hierarchy to traverse into that directory hierarchy. For example, a source
3071 * file in the "web" directory should not contain a directive such as
3072 * `import '../lib/some.dart'` which references a file inside the lib
3073 * directory.
3074 */
3075 static const HintCode FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE =
3076 const HintCode('FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE',
3077 "A file outside the 'lib' directory hierarchy should not reference a f ile inside that hierarchy. Use a package: reference instead.");
3078
3079 /**
3080 * It is a bad practice for a package import to reference anything outside the
3081 * given package, or more generally, it is bad practice for a package import
3082 * to contain a "..". For example, a source file should not contain a
3083 * directive such as `import 'package:foo/../some.dart'`.
3084 */
3085 static const HintCode PACKAGE_IMPORT_CONTAINS_DOT_DOT = const HintCode(
3086 'PACKAGE_IMPORT_CONTAINS_DOT_DOT',
3087 "A package import should not contain '..'");
3088
3089 /**
3090 * Initialize a newly created error code to have the given [name]. The message
3091 * associated with the error will be created from the given [message]
3092 * template. The correction associated with the error will be created from the
3093 * given [correction] template.
3094 */
3095 const HintCode(String name, String message, [String correction])
3096 : super(name, message, correction);
3097
3098 @override
3099 ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
3100
3101 @override
3102 ErrorType get type => ErrorType.HINT;
3103 }
3104
3105 /**
3106 * The error codes used for errors in HTML files. The convention for this
3107 * class is for the name of the error code to indicate the problem that caused
3108 * the error to be generated and for the error message to explain what is wrong
3109 * and, when appropriate, how the problem can be corrected.
3110 */
3111 class HtmlErrorCode extends ErrorCode {
3112 /**
3113 * An error code indicating that there is a syntactic error in the file.
3114 *
3115 * Parameters:
3116 * 0: the error message from the parse error
3117 */
3118 static const HtmlErrorCode PARSE_ERROR =
3119 const HtmlErrorCode('PARSE_ERROR', '{0}');
3120
3121 /**
3122 * Initialize a newly created error code to have the given [name]. The message
3123 * associated with the error will be created from the given [message]
3124 * template. The correction associated with the error will be created from the
3125 * given [correction] template.
3126 */
3127 const HtmlErrorCode(String name, String message, [String correction])
3128 : super(name, message, correction);
3129
3130 @override
3131 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
3132
3133 @override
3134 ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
3135 }
3136
3137 /**
3138 * The error codes used for warnings in HTML files. The convention for this
3139 * class is for the name of the error code to indicate the problem that caused
3140 * the error to be generated and for the error message to explain what is wrong
3141 * and, when appropriate, how the problem can be corrected.
3142 */
3143 class HtmlWarningCode extends ErrorCode {
3144 /**
3145 * An error code indicating that the value of the 'src' attribute of a Dart
3146 * script tag is not a valid URI.
3147 *
3148 * Parameters:
3149 * 0: the URI that is invalid
3150 */
3151 static const HtmlWarningCode INVALID_URI =
3152 const HtmlWarningCode('INVALID_URI', "Invalid URI syntax: '{0}'");
3153
3154 /**
3155 * An error code indicating that the value of the 'src' attribute of a Dart
3156 * script tag references a file that does not exist.
3157 *
3158 * Parameters:
3159 * 0: the URI pointing to a non-existent file
3160 */
3161 static const HtmlWarningCode URI_DOES_NOT_EXIST = const HtmlWarningCode(
3162 'URI_DOES_NOT_EXIST', "Target of URI does not exist: '{0}'");
3163
3164 /**
3165 * Initialize a newly created error code to have the given [name]. The message
3166 * associated with the error will be created from the given [message]
3167 * template. The correction associated with the error will be created from the
3168 * given [correction] template.
3169 */
3170 const HtmlWarningCode(String name, String message, [String correction])
3171 : super(name, message, correction);
3172
3173 @override
3174 ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
3175
3176 @override
3177 ErrorType get type => ErrorType.STATIC_WARNING;
3178 }
3179
3180 /**
3181 * Defines style and best practice recommendations.
3182 *
3183 * Unlike [HintCode]s, which are akin to traditional static warnings from a
3184 * compiler, lint recommendations focus on matters of style and practices that
3185 * might aggregated to define a project's style guide.
3186 */
3187 class LintCode extends ErrorCode {
3188 const LintCode(String name, String message, [String correction])
3189 : super(name, message, correction);
3190
3191 @override
3192 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
3193
3194 @override
3195 ErrorType get type => ErrorType.LINT;
3196 }
3197
3198 /**
3199 * The error codes used for static type warnings. The convention for this class
3200 * is for the name of the error code to indicate the problem that caused the
3201 * error to be generated and for the error message to explain what is wrong and,
3202 * when appropriate, how the problem can be corrected.
3203 */
3204 class StaticTypeWarningCode extends ErrorCode {
3205 /**
3206 * 12.7 Lists: A fresh instance (7.6.1) <i>a</i>, of size <i>n</i>, whose
3207 * class implements the built-in class <i>List&lt;E></i> is allocated.
3208 *
3209 * Parameters:
3210 * 0: the number of provided type arguments
3211 */
3212 static const StaticTypeWarningCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS =
3213 const StaticTypeWarningCode('EXPECTED_ONE_LIST_TYPE_ARGUMENTS',
3214 "List literal requires exactly one type arguments or none, but {0} fou nd");
3215
3216 /**
3217 * 12.8 Maps: A fresh instance (7.6.1) <i>m</i>, of size <i>n</i>, whose class
3218 * implements the built-in class <i>Map&lt;K, V></i> is allocated.
3219 *
3220 * Parameters:
3221 * 0: the number of provided type arguments
3222 */
3223 static const StaticTypeWarningCode EXPECTED_TWO_MAP_TYPE_ARGUMENTS =
3224 const StaticTypeWarningCode('EXPECTED_TWO_MAP_TYPE_ARGUMENTS',
3225 "Map literal requires exactly two type arguments or none, but {0} foun d");
3226
3227 /**
3228 * 9 Functions: It is a static warning if the declared return type of a
3229 * function marked async* may not be assigned to Stream.
3230 */
3231 static const StaticTypeWarningCode ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE =
3232 const StaticTypeWarningCode('ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE',
3233 "Functions marked 'async*' must have a return type assignable to 'Stre am'");
3234
3235 /**
3236 * 9 Functions: It is a static warning if the declared return type of a
3237 * function marked async may not be assigned to Future.
3238 */
3239 static const StaticTypeWarningCode ILLEGAL_ASYNC_RETURN_TYPE =
3240 const StaticTypeWarningCode('ILLEGAL_ASYNC_RETURN_TYPE',
3241 "Functions marked 'async' must have a return type assignable to 'Futur e'");
3242
3243 /**
3244 * 9 Functions: It is a static warning if the declared return type of a
3245 * function marked sync* may not be assigned to Iterable.
3246 */
3247 static const StaticTypeWarningCode ILLEGAL_SYNC_GENERATOR_RETURN_TYPE =
3248 const StaticTypeWarningCode('ILLEGAL_SYNC_GENERATOR_RETURN_TYPE',
3249 "Functions marked 'sync*' must have a return type assignable to 'Itera ble'");
3250
3251 /**
3252 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
3253 * It is a static type warning if <i>T</i> does not have an accessible
3254 * instance setter named <i>v=</i>.
3255 *
3256 * See [UNDEFINED_SETTER].
3257 */
3258 static const StaticTypeWarningCode INACCESSIBLE_SETTER =
3259 const StaticTypeWarningCode('INACCESSIBLE_SETTER', "");
3260
3261 /**
3262 * 8.1.1 Inheritance and Overriding: However, if the above rules would cause
3263 * multiple members <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> with the
3264 * same name <i>n</i> that would be inherited (because identically named
3265 * members existed in several superinterfaces) then at most one member is
3266 * inherited.
3267 *
3268 * If the static types <i>T<sub>1</sub>, &hellip;, T<sub>k</sub></i> of the
3269 * members <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> are not identical,
3270 * then there must be a member <i>m<sub>x</sub></i> such that <i>T<sub>x</sub>
3271 * &lt;: T<sub>i</sub>, 1 &lt;= x &lt;= k</i> for all <i>i, 1 &lt;= i &lt;=
3272 * k</i>, or a static type warning occurs. The member that is inherited is
3273 * <i>m<sub>x</sub></i>, if it exists; otherwise:
3274 * * Let <i>numberOfPositionals</i>(<i>f</i>) denote the number of positional
3275 * parameters of a function <i>f</i>, and let
3276 * <i>numberOfRequiredParams</i>(<i>f</i>) denote the number of required
3277 * parameters of a function <i>f</i>. Furthermore, let <i>s</i> denote the
3278 * set of all named parameters of the <i>m<sub>1</sub>, &hellip;,
3279 * m<sub>k</sub></i>. Then let
3280 * * <i>h = max(numberOfPositionals(m<sub>i</sub>)),</i>
3281 * * <i>r = min(numberOfRequiredParams(m<sub>i</sub>)), for all <i>i</i>, 1 <=
3282 * i <= k.</i> If <i>r <= h</i> then <i>I</i> has a method named <i>n</i>,
3283 * with <i>r</i> required parameters of type <b>dynamic</b>, <i>h</i>
3284 * positional parameters of type <b>dynamic</b>, named parameters <i>s</i>
3285 * of type <b>dynamic</b> and return type <b>dynamic</b>.
3286 * * Otherwise none of the members <i>m<sub>1</sub>, &hellip;,
3287 * m<sub>k</sub></i> is inherited.
3288 */
3289 static const StaticTypeWarningCode INCONSISTENT_METHOD_INHERITANCE =
3290 const StaticTypeWarningCode('INCONSISTENT_METHOD_INHERITANCE',
3291 "'{0}' is inherited by at least two interfaces inconsistently, from {1 }");
3292
3293 /**
3294 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does
3295 * not have an accessible (3.2) instance member named <i>m</i>.
3296 *
3297 * Parameters:
3298 * 0: the name of the static member
3299 *
3300 * See [UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER].
3301 */
3302 static const StaticTypeWarningCode INSTANCE_ACCESS_TO_STATIC_MEMBER =
3303 const StaticTypeWarningCode('INSTANCE_ACCESS_TO_STATIC_MEMBER',
3304 "Static member '{0}' cannot be accessed using instance access");
3305
3306 /**
3307 * 12.18 Assignment: It is a static type warning if the static type of
3308 * <i>e</i> may not be assigned to the static type of <i>v</i>. The static
3309 * type of the expression <i>v = e</i> is the static type of <i>e</i>.
3310 *
3311 * 12.18 Assignment: It is a static type warning if the static type of
3312 * <i>e</i> may not be assigned to the static type of <i>C.v</i>. The static
3313 * type of the expression <i>C.v = e</i> is the static type of <i>e</i>.
3314 *
3315 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
3316 * It is a static type warning if the static type of <i>e<sub>2</sub></i> may
3317 * not be assigned to <i>T</i>.
3318 *
3319 * Parameters:
3320 * 0: the name of the right hand side type
3321 * 1: the name of the left hand side type
3322 */
3323 static const StaticTypeWarningCode INVALID_ASSIGNMENT =
3324 const StaticTypeWarningCode('INVALID_ASSIGNMENT',
3325 "A value of type '{0}' cannot be assigned to a variable of type '{1}'" );
3326
3327 /**
3328 * 12.15.1 Ordinary Invocation: An ordinary method invocation <i>i</i> has the
3329 * form <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
3330 * a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>.
3331 *
3332 * Let <i>T</i> be the static type of <i>o</i>. It is a static type warning if
3333 * <i>T</i> does not have an accessible instance member named <i>m</i>. If
3334 * <i>T.m</i> exists, it is a static warning if the type <i>F</i> of
3335 * <i>T.m</i> may not be assigned to a function type. If <i>T.m</i> does not
3336 * exist, or if <i>F</i> is not a function type, the static type of <i>i</i>
3337 * is dynamic.
3338 *
3339 * 12.15.3 Static Invocation: It is a static type warning if the type <i>F</i>
3340 * of <i>C.m</i> may not be assigned to a function type.
3341 *
3342 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
3343 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
3344 * a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. If
3345 * <i>S.m</i> exists, it is a static warning if the type <i>F</i> of
3346 * <i>S.m</i> may not be assigned to a function type.
3347 *
3348 * Parameters:
3349 * 0: the name of the identifier that is not a function type
3350 */
3351 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION =
3352 const StaticTypeWarningCode(
3353 'INVOCATION_OF_NON_FUNCTION', "'{0}' is not a method");
3354
3355 /**
3356 * 12.14.4 Function Expression Invocation: A function expression invocation
3357 * <i>i</i> has the form <i>e<sub>f</sub>(a<sub>1</sub>, &hellip;,
3358 * a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;, x<sub>n+k</sub>:
3359 * a<sub>n+k</sub>)</i>, where <i>e<sub>f</sub></i> is an expression.
3360 *
3361 * It is a static type warning if the static type <i>F</i> of
3362 * <i>e<sub>f</sub></i> may not be assigned to a function type.
3363 */
3364 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION_EXPRESSION =
3365 const StaticTypeWarningCode('INVOCATION_OF_NON_FUNCTION_EXPRESSION',
3366 "Cannot invoke a non-function");
3367
3368 /**
3369 * 12.20 Conditional: It is a static type warning if the type of
3370 * <i>e<sub>1</sub></i> may not be assigned to bool.
3371 *
3372 * 13.5 If: It is a static type warning if the type of the expression <i>b</i>
3373 * may not be assigned to bool.
3374 *
3375 * 13.7 While: It is a static type warning if the type of <i>e</i> may not be
3376 * assigned to bool.
3377 *
3378 * 13.8 Do: It is a static type warning if the type of <i>e</i> cannot be
3379 * assigned to bool.
3380 */
3381 static const StaticTypeWarningCode NON_BOOL_CONDITION =
3382 const StaticTypeWarningCode(
3383 'NON_BOOL_CONDITION', "Conditions must have a static type of 'bool'");
3384
3385 /**
3386 * 13.15 Assert: It is a static type warning if the type of <i>e</i> may not
3387 * be assigned to either bool or () &rarr; bool
3388 */
3389 static const StaticTypeWarningCode NON_BOOL_EXPRESSION =
3390 const StaticTypeWarningCode('NON_BOOL_EXPRESSION',
3391 "Assertions must be on either a 'bool' or '() -> bool'");
3392
3393 /**
3394 * 12.28 Unary Expressions: The expression !<i>e</i> is equivalent to the
3395 * expression <i>e</i>?<b>false<b> : <b>true</b>.
3396 *
3397 * 12.20 Conditional: It is a static type warning if the type of
3398 * <i>e<sub>1</sub></i> may not be assigned to bool.
3399 */
3400 static const StaticTypeWarningCode NON_BOOL_NEGATION_EXPRESSION =
3401 const StaticTypeWarningCode('NON_BOOL_NEGATION_EXPRESSION',
3402 "Negation argument must have a static type of 'bool'");
3403
3404 /**
3405 * 12.21 Logical Boolean Expressions: It is a static type warning if the
3406 * static types of both of <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> may
3407 * not be assigned to bool.
3408 *
3409 * Parameters:
3410 * 0: the lexeme of the logical operator
3411 */
3412 static const StaticTypeWarningCode NON_BOOL_OPERAND =
3413 const StaticTypeWarningCode('NON_BOOL_OPERAND',
3414 "The operands of the '{0}' operator must be assignable to 'bool'");
3415
3416 /**
3417 * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>,
3418 * 1 &lt;= i &lt;= n</i> does not denote a type in the enclosing lexical scope .
3419 */
3420 static const StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT =
3421 const StaticTypeWarningCode('NON_TYPE_AS_TYPE_ARGUMENT',
3422 "The name '{0}' is not a type and cannot be used as a parameterized ty pe");
3423
3424 /**
3425 * 13.11 Return: It is a static type warning if the type of <i>e</i> may not
3426 * be assigned to the declared return type of the immediately enclosing
3427 * function.
3428 *
3429 * Parameters:
3430 * 0: the return type as declared in the return statement
3431 * 1: the expected return type as defined by the method
3432 * 2: the name of the method
3433 */
3434 static const StaticTypeWarningCode RETURN_OF_INVALID_TYPE =
3435 const StaticTypeWarningCode('RETURN_OF_INVALID_TYPE',
3436 "The return type '{0}' is not a '{1}', as defined by the method '{2}'" );
3437
3438 /**
3439 * 12.11 Instance Creation: It is a static type warning if any of the type
3440 * arguments to a constructor of a generic type <i>G</i> invoked by a new
3441 * expression or a constant object expression are not subtypes of the bounds
3442 * of the corresponding formal type parameters of <i>G</i>.
3443 *
3444 * 15.8 Parameterized Types: If <i>S</i> is the static type of a member
3445 * <i>m</i> of <i>G</i>, then the static type of the member <i>m</i> of
3446 * <i>G&lt;A<sub>1</sub>, &hellip;, A<sub>n</sub>&gt;</i> is <i>[A<sub>1</sub> ,
3447 * &hellip;, A<sub>n</sub>/T<sub>1</sub>, &hellip;, T<sub>n</sub>]S</i> where
3448 * <i>T<sub>1</sub>, &hellip;, T<sub>n</sub></i> are the formal type
3449 * parameters of <i>G</i>. Let <i>B<sub>i</sub></i> be the bounds of
3450 * <i>T<sub>i</sub>, 1 &lt;= i &lt;= n</i>. It is a static type warning if
3451 * <i>A<sub>i</sub></i> is not a subtype of <i>[A<sub>1</sub>, &hellip;,
3452 * A<sub>n</sub>/T<sub>1</sub>, &hellip;, T<sub>n</sub>]B<sub>i</sub>, 1 &lt;=
3453 * i &lt;= n</i>.
3454 *
3455 * 7.6.2 Factories: It is a static type warning if any of the type arguments
3456 * to <i>k'</i> are not subtypes of the bounds of the corresponding formal
3457 * type parameters of type.
3458 *
3459 * Parameters:
3460 * 0: the name of the type used in the instance creation that should be
3461 * limited by the bound as specified in the class declaration
3462 * 1: the name of the bounding type
3463 *
3464 * See [TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND].
3465 */
3466 static const StaticTypeWarningCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS =
3467 const StaticTypeWarningCode(
3468 'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', "'{0}' does not extend '{1}'");
3469
3470 /**
3471 * 10 Generics: It is a static type warning if a type parameter is a supertype
3472 * of its upper bound.
3473 *
3474 * Parameters:
3475 * 0: the name of the type parameter
3476 *
3477 * See [TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
3478 */
3479 static const StaticTypeWarningCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND =
3480 const StaticTypeWarningCode('TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND',
3481 "'{0}' cannot be a supertype of its upper bound");
3482
3483 /**
3484 * 12.17 Getter Invocation: It is a static warning if there is no class
3485 * <i>C</i> in the enclosing lexical scope of <i>i</i>, or if <i>C</i> does
3486 * not declare, implicitly or explicitly, a getter named <i>m</i>.
3487 *
3488 * Parameters:
3489 * 0: the name of the enumeration constant that is not defined
3490 * 1: the name of the enumeration used to access the constant
3491 */
3492 static const StaticTypeWarningCode UNDEFINED_ENUM_CONSTANT =
3493 const StaticTypeWarningCode('UNDEFINED_ENUM_CONSTANT',
3494 "There is no constant named '{0}' in '{1}'");
3495
3496 /**
3497 * 12.15.3 Unqualified Invocation: If there exists a lexically visible
3498 * declaration named <i>id</i>, let <i>f<sub>id</sub></i> be the innermost
3499 * such declaration. Then: [skip]. Otherwise, <i>f<sub>id</sub></i> is
3500 * considered equivalent to the ordinary method invocation
3501 * <b>this</b>.<i>id</i>(<i>a<sub>1</sub></i>, ..., <i>a<sub>n</sub></i>,
3502 * <i>x<sub>n+1</sub></i> : <i>a<sub>n+1</sub></i>, ...,
3503 * <i>x<sub>n+k</sub></i> : <i>a<sub>n+k</sub></i>).
3504 *
3505 * Parameters:
3506 * 0: the name of the method that is undefined
3507 */
3508 static const StaticTypeWarningCode UNDEFINED_FUNCTION =
3509 const StaticTypeWarningCode(
3510 'UNDEFINED_FUNCTION', "The function '{0}' is not defined");
3511
3512 /**
3513 * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
3514 * a static type warning if <i>T</i> does not have a getter named <i>m</i>.
3515 *
3516 * Parameters:
3517 * 0: the name of the getter
3518 * 1: the name of the enclosing type where the getter is being looked for
3519 */
3520 static const StaticTypeWarningCode UNDEFINED_GETTER =
3521 const StaticTypeWarningCode('UNDEFINED_GETTER',
3522 "The getter '{0}' is not defined for the class '{1}'");
3523
3524 /**
3525 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
3526 * It is a static type warning if <i>T</i> does not have an accessible
3527 * instance member named <i>m</i>.
3528 *
3529 * Parameters:
3530 * 0: the name of the method that is undefined
3531 * 1: the resolved type name that the method lookup is happening on
3532 */
3533 static const StaticTypeWarningCode UNDEFINED_METHOD =
3534 const StaticTypeWarningCode('UNDEFINED_METHOD',
3535 "The method '{0}' is not defined for the class '{1}'");
3536
3537 /**
3538 * 12.18 Assignment: Evaluation of an assignment of the form
3539 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
3540 * equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
3541 * return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
3542 * <i>e<sub>2</sub></i>).
3543 *
3544 * 12.29 Assignable Expressions: An assignable expression of the form
3545 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
3546 * invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
3547 * <i>e<sub>2</sub></i>.
3548 *
3549 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
3550 * It is a static type warning if <i>T</i> does not have an accessible
3551 * instance member named <i>m</i>.
3552 *
3553 * Parameters:
3554 * 0: the name of the operator
3555 * 1: the name of the enclosing type where the operator is being looked for
3556 */
3557 static const StaticTypeWarningCode UNDEFINED_OPERATOR =
3558 const StaticTypeWarningCode('UNDEFINED_OPERATOR',
3559 "The operator '{0}' is not defined for the class '{1}'");
3560
3561 /**
3562 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
3563 * It is a static type warning if <i>T</i> does not have an accessible
3564 * instance setter named <i>v=</i>.
3565 *
3566 * Parameters:
3567 * 0: the name of the setter
3568 * 1: the name of the enclosing type where the setter is being looked for
3569 *
3570 * See [INACCESSIBLE_SETTER].
3571 */
3572 static const StaticTypeWarningCode UNDEFINED_SETTER =
3573 const StaticTypeWarningCode('UNDEFINED_SETTER',
3574 "The setter '{0}' is not defined for the class '{1}'");
3575
3576 /**
3577 * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
3578 * a static type warning if <i>T</i> does not have a getter named <i>m</i>.
3579 *
3580 * Parameters:
3581 * 0: the name of the getter
3582 * 1: the name of the enclosing type where the getter is being looked for
3583 */
3584 static const StaticTypeWarningCode UNDEFINED_SUPER_GETTER =
3585 const StaticTypeWarningCode('UNDEFINED_SUPER_GETTER',
3586 "The getter '{0}' is not defined in a superclass of '{1}'");
3587
3588 /**
3589 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
3590 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
3591 * a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a
3592 * static type warning if <i>S</i> does not have an accessible instance member
3593 * named <i>m</i>.
3594 *
3595 * Parameters:
3596 * 0: the name of the method that is undefined
3597 * 1: the resolved type name that the method lookup is happening on
3598 */
3599 static const StaticTypeWarningCode UNDEFINED_SUPER_METHOD =
3600 const StaticTypeWarningCode('UNDEFINED_SUPER_METHOD',
3601 "The method '{0}' is not defined in a superclass of '{1}'");
3602
3603 /**
3604 * 12.18 Assignment: Evaluation of an assignment of the form
3605 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
3606 * equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
3607 * return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
3608 * <i>e<sub>2</sub></i>).
3609 *
3610 * 12.29 Assignable Expressions: An assignable expression of the form
3611 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
3612 * invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
3613 * <i>e<sub>2</sub></i>.
3614 *
3615 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
3616 * It is a static type warning if <i>T</i> does not have an accessible
3617 * instance member named <i>m</i>.
3618 *
3619 * Parameters:
3620 * 0: the name of the operator
3621 * 1: the name of the enclosing type where the operator is being looked for
3622 */
3623 static const StaticTypeWarningCode UNDEFINED_SUPER_OPERATOR =
3624 const StaticTypeWarningCode('UNDEFINED_SUPER_OPERATOR',
3625 "The operator '{0}' is not defined in a superclass of '{1}'");
3626
3627 /**
3628 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
3629 * It is a static type warning if <i>T</i> does not have an accessible
3630 * instance setter named <i>v=</i>.
3631 *
3632 * Parameters:
3633 * 0: the name of the setter
3634 * 1: the name of the enclosing type where the setter is being looked for
3635 *
3636 * See [INACCESSIBLE_SETTER].
3637 */
3638 static const StaticTypeWarningCode UNDEFINED_SUPER_SETTER =
3639 const StaticTypeWarningCode('UNDEFINED_SUPER_SETTER',
3640 "The setter '{0}' is not defined in a superclass of '{1}'");
3641
3642 /**
3643 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does
3644 * not have an accessible (3.2) instance member named <i>m</i>.
3645 *
3646 * This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used
3647 * when we are able to find the name defined in a supertype. It exists to
3648 * provide a more informative error message.
3649 */
3650 static const StaticTypeWarningCode UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_M EMBER =
3651 const StaticTypeWarningCode(
3652 'UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER',
3653 "Static members from supertypes must be qualified by the name of the d efining type");
3654
3655 /**
3656 * 15.8 Parameterized Types: It is a static type warning if <i>G</i> is not a
3657 * generic type with exactly <i>n</i> type parameters.
3658 *
3659 * Parameters:
3660 * 0: the name of the type being referenced (<i>G</i>)
3661 * 1: the number of type parameters that were declared
3662 * 2: the number of type arguments provided
3663 *
3664 * See [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS], and
3665 * [CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS].
3666 */
3667 static const StaticTypeWarningCode WRONG_NUMBER_OF_TYPE_ARGUMENTS =
3668 const StaticTypeWarningCode('WRONG_NUMBER_OF_TYPE_ARGUMENTS',
3669 "The type '{0}' is declared with {1} type parameters, but {2} type arg uments were given");
3670
3671 /**
3672 * 17.16.1 Yield: Let T be the static type of e [the expression to the right
3673 * of "yield"] and let f be the immediately enclosing function. It is a
3674 * static type warning if either:
3675 *
3676 * - the body of f is marked async* and the type Stream<T> may not be
3677 * assigned to the declared return type of f.
3678 *
3679 * - the body of f is marked sync* and the type Iterable<T> may not be
3680 * assigned to the declared return type of f.
3681 *
3682 * 17.16.2 Yield-Each: Let T be the static type of e [the expression to the
3683 * right of "yield*"] and let f be the immediately enclosing function. It is
3684 * a static type warning if T may not be assigned to the declared return type
3685 * of f. If f is synchronous it is a static type warning if T may not be
3686 * assigned to Iterable. If f is asynchronous it is a static type warning if
3687 * T may not be assigned to Stream.
3688 */
3689 static const StaticTypeWarningCode YIELD_OF_INVALID_TYPE =
3690 const StaticTypeWarningCode('YIELD_OF_INVALID_TYPE',
3691 "The type '{0}' implied by the 'yield' expression must be assignable t o '{1}'");
3692
3693 /**
3694 * Initialize a newly created error code to have the given [name]. The message
3695 * associated with the error will be created from the given [message]
3696 * template. The correction associated with the error will be created from the
3697 * given [correction] template.
3698 */
3699 const StaticTypeWarningCode(String name, String message, [String correction])
3700 : super(name, message, correction);
3701
3702 @override
3703 ErrorSeverity get errorSeverity => ErrorType.STATIC_TYPE_WARNING.severity;
3704
3705 @override
3706 ErrorType get type => ErrorType.STATIC_TYPE_WARNING;
3707 }
3708
3709 /**
3710 * The error codes used for static warnings. The convention for this class is
3711 * for the name of the error code to indicate the problem that caused the error
3712 * to be generated and for the error message to explain what is wrong and, when
3713 * appropriate, how the problem can be corrected.
3714 */
3715 class StaticWarningCode extends ErrorCode {
3716 /**
3717 * 14.1 Imports: If a name <i>N</i> is referenced by a library <i>L</i> and
3718 * <i>N</i> is introduced into the top level scope <i>L</i> by more than one
3719 * import then:
3720 * 1. A static warning occurs.
3721 * 2. If <i>N</i> is referenced as a function, getter or setter, a
3722 * <i>NoSuchMethodError</i> is raised.
3723 * 3. If <i>N</i> is referenced as a type, it is treated as a malformed type.
3724 *
3725 * Parameters:
3726 * 0: the name of the ambiguous type
3727 * 1: the name of the first library that the type is found
3728 * 2: the name of the second library that the type is found
3729 */
3730 static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode(
3731 'AMBIGUOUS_IMPORT', "The name '{0}' is defined in the libraries {1}",
3732 "Consider using 'as prefix' for one of the import directives "
3733 "or hiding the name from all but one of the imports.");
3734
3735 /**
3736 * 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>,
3737 * 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type of the
3738 * corresponding formal parameter of the constructor <i>T.id</i> (respectively
3739 * <i>T</i>).
3740 *
3741 * 12.11.2 Const: It is a static warning if the static type of
3742 * <i>a<sub>i</sub>, 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type
3743 * of the corresponding formal parameter of the constructor <i>T.id</i>
3744 * (respectively <i>T</i>).
3745 *
3746 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
3747 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
3748 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
3749 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
3750 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
3751 * &lt;= j &lt;= m</i>.
3752 *
3753 * 12.14.2 Binding Actuals to Formals: Furthermore, each <i>q<sub>i</sub>, 1
3754 * &lt;= i &lt;= l</i>, must have a corresponding named parameter in the set
3755 * <i>{p<sub>n+1</sub>, &hellip; p<sub>n+k</sub>}</i> or a static warning
3756 * occurs. It is a static warning if <i>T<sub>m+j</sub></i> may not be
3757 * assigned to <i>S<sub>r</sub></i>, where <i>r = q<sub>j</sub>, 1 &lt;= j
3758 * &lt;= l</i>.
3759 *
3760 * Parameters:
3761 * 0: the name of the actual argument type
3762 * 1: the name of the expected type
3763 */
3764 static const StaticWarningCode ARGUMENT_TYPE_NOT_ASSIGNABLE =
3765 const StaticWarningCode('ARGUMENT_TYPE_NOT_ASSIGNABLE',
3766 "The argument type '{0}' cannot be assigned to the parameter type '{1} '");
3767
3768 /**
3769 * 5 Variables: Attempting to assign to a final variable elsewhere will cause
3770 * a NoSuchMethodError to be thrown, because no setter is defined for it. The
3771 * assignment will also give rise to a static warning for the same reason.
3772 *
3773 * A constant variable is always implicitly final.
3774 */
3775 static const StaticWarningCode ASSIGNMENT_TO_CONST = const StaticWarningCode(
3776 'ASSIGNMENT_TO_CONST', "Constant variables cannot be assigned a value");
3777
3778 /**
3779 * 5 Variables: Attempting to assign to a final variable elsewhere will cause
3780 * a NoSuchMethodError to be thrown, because no setter is defined for it. The
3781 * assignment will also give rise to a static warning for the same reason.
3782 */
3783 static const StaticWarningCode ASSIGNMENT_TO_FINAL = const StaticWarningCode(
3784 'ASSIGNMENT_TO_FINAL', "'{0}' cannot be used as a setter, it is final");
3785
3786 /**
3787 * 5 Variables: Attempting to assign to a final variable elsewhere will cause
3788 * a NoSuchMethodError to be thrown, because no setter is defined for it. The
3789 * assignment will also give rise to a static warning for the same reason.
3790 */
3791 static const StaticWarningCode ASSIGNMENT_TO_FINAL_NO_SETTER =
3792 const StaticWarningCode('ASSIGNMENT_TO_FINAL_NO_SETTER',
3793 "No setter named '{0}' in class '{1}'");
3794
3795 /**
3796 * 12.18 Assignment: It is as static warning if an assignment of the form
3797 * <i>v = e</i> occurs inside a top level or static function (be it function,
3798 * method, getter, or setter) or variable initializer and there is neither a
3799 * local variable declaration with name <i>v</i> nor setter declaration with
3800 * name <i>v=</i> in the lexical scope enclosing the assignment.
3801 */
3802 static const StaticWarningCode ASSIGNMENT_TO_FUNCTION =
3803 const StaticWarningCode(
3804 'ASSIGNMENT_TO_FUNCTION', "Functions cannot be assigned a value");
3805
3806 /**
3807 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>
3808 * It is a static type warning if <i>T</i> does not have an accessible
3809 * instance setter named <i>v=</i>.
3810 */
3811 static const StaticWarningCode ASSIGNMENT_TO_METHOD = const StaticWarningCode(
3812 'ASSIGNMENT_TO_METHOD', "Methods cannot be assigned a value");
3813
3814 /**
3815 * 12.18 Assignment: It is as static warning if an assignment of the form
3816 * <i>v = e</i> occurs inside a top level or static function (be it function,
3817 * method, getter, or setter) or variable initializer and there is neither a
3818 * local variable declaration with name <i>v</i> nor setter declaration with
3819 * name <i>v=</i> in the lexical scope enclosing the assignment.
3820 */
3821 static const StaticWarningCode ASSIGNMENT_TO_TYPE = const StaticWarningCode(
3822 'ASSIGNMENT_TO_TYPE', "Types cannot be assigned a value");
3823
3824 /**
3825 * 13.9 Switch: It is a static warning if the last statement of the statement
3826 * sequence <i>s<sub>k</sub></i> is not a break, continue, return or throw
3827 * statement.
3828 */
3829 static const StaticWarningCode CASE_BLOCK_NOT_TERMINATED =
3830 const StaticWarningCode('CASE_BLOCK_NOT_TERMINATED',
3831 "The last statement of the 'case' should be 'break', 'continue', 'retu rn' or 'throw'");
3832
3833 /**
3834 * 12.32 Type Cast: It is a static warning if <i>T</i> does not denote a type
3835 * available in the current lexical scope.
3836 */
3837 static const StaticWarningCode CAST_TO_NON_TYPE = const StaticWarningCode(
3838 'CAST_TO_NON_TYPE',
3839 "The name '{0}' is not a type and cannot be used in an 'as' expression");
3840
3841 /**
3842 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
3843 * is declared or inherited in a concrete class.
3844 */
3845 static const StaticWarningCode CONCRETE_CLASS_WITH_ABSTRACT_MEMBER =
3846 const StaticWarningCode('CONCRETE_CLASS_WITH_ABSTRACT_MEMBER',
3847 "'{0}' must have a method body because '{1}' is not abstract");
3848
3849 /**
3850 * 14.1 Imports: If a name <i>N</i> is referenced by a library <i>L</i> and
3851 * <i>N</i> would be introduced into the top level scope of <i>L</i> by an
3852 * import from a library whose URI begins with <i>dart:</i> and an import from
3853 * a library whose URI does not begin with <i>dart:</i>:
3854 * * The import from <i>dart:</i> is implicitly extended by a hide N clause.
3855 * * A static warning is issued.
3856 *
3857 * Parameters:
3858 * 0: the ambiguous name
3859 * 1: the name of the dart: library in which the element is found
3860 * 1: the name of the non-dart: library in which the element is found
3861 */
3862 static const StaticWarningCode CONFLICTING_DART_IMPORT =
3863 const StaticWarningCode('CONFLICTING_DART_IMPORT',
3864 "Element '{0}' from SDK library '{1}' is implicitly hidden by '{2}'");
3865
3866 /**
3867 * 7.2 Getters: It is a static warning if a class <i>C</i> declares an
3868 * instance getter named <i>v</i> and an accessible static member named
3869 * <i>v</i> or <i>v=</i> is declared in a superclass of <i>C</i>.
3870 *
3871 * Parameters:
3872 * 0: the name of the super class declaring a static member
3873 */
3874 static const StaticWarningCode CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMB ER =
3875 const StaticWarningCode(
3876 'CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER',
3877 "Superclass '{0}' declares static member with the same name");
3878
3879 /**
3880 * 7.1 Instance Methods: It is a static warning if a class <i>C</i> declares
3881 * an instance method named <i>n</i> and has a setter named <i>n=</i>.
3882 */
3883 static const StaticWarningCode CONFLICTING_INSTANCE_METHOD_SETTER =
3884 const StaticWarningCode('CONFLICTING_INSTANCE_METHOD_SETTER',
3885 "Class '{0}' declares instance method '{1}', but also has a setter wit h the same name from '{2}'");
3886
3887 /**
3888 * 7.1 Instance Methods: It is a static warning if a class <i>C</i> declares
3889 * an instance method named <i>n</i> and has a setter named <i>n=</i>.
3890 */
3891 static const StaticWarningCode CONFLICTING_INSTANCE_METHOD_SETTER2 =
3892 const StaticWarningCode('CONFLICTING_INSTANCE_METHOD_SETTER2',
3893 "Class '{0}' declares the setter '{1}', but also has an instance metho d in the same class");
3894
3895 /**
3896 * 7.3 Setters: It is a static warning if a class <i>C</i> declares an
3897 * instance setter named <i>v=</i> and an accessible static member named
3898 * <i>v=</i> or <i>v</i> is declared in a superclass of <i>C</i>.
3899 *
3900 * Parameters:
3901 * 0: the name of the super class declaring a static member
3902 */
3903 static const StaticWarningCode CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMB ER =
3904 const StaticWarningCode(
3905 'CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER',
3906 "Superclass '{0}' declares static member with the same name");
3907
3908 /**
3909 * 7.2 Getters: It is a static warning if a class declares a static getter
3910 * named <i>v</i> and also has a non-static setter named <i>v=</i>.
3911 */
3912 static const StaticWarningCode CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER =
3913 const StaticWarningCode('CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER',
3914 "Class '{0}' declares non-static setter with the same name");
3915
3916 /**
3917 * 7.3 Setters: It is a static warning if a class declares a static setter
3918 * named <i>v=</i> and also has a non-static member named <i>v</i>.
3919 */
3920 static const StaticWarningCode CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER =
3921 const StaticWarningCode('CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER',
3922 "Class '{0}' declares non-static member with the same name");
3923
3924 /**
3925 * 12.11.2 Const: Given an instance creation expression of the form <i>const
3926 * q(a<sub>1</sub>, &hellip; a<sub>n</sub>)</i> it is a static warning if
3927 * <i>q</i> is the constructor of an abstract class but <i>q</i> is not a
3928 * factory constructor.
3929 */
3930 static const StaticWarningCode CONST_WITH_ABSTRACT_CLASS =
3931 const StaticWarningCode('CONST_WITH_ABSTRACT_CLASS',
3932 "Abstract classes cannot be created with a 'const' expression");
3933
3934 /**
3935 * 12.7 Maps: It is a static warning if the values of any two keys in a map
3936 * literal are equal.
3937 */
3938 static const StaticWarningCode EQUAL_KEYS_IN_MAP = const StaticWarningCode(
3939 'EQUAL_KEYS_IN_MAP', "Keys in a map cannot be equal");
3940
3941 /**
3942 * 14.2 Exports: It is a static warning to export two different libraries with
3943 * the same name.
3944 *
3945 * Parameters:
3946 * 0: the uri pointing to a first library
3947 * 1: the uri pointing to a second library
3948 * 2:e the shared name of the exported libraries
3949 */
3950 static const StaticWarningCode EXPORT_DUPLICATED_LIBRARY_NAMED =
3951 const StaticWarningCode('EXPORT_DUPLICATED_LIBRARY_NAMED',
3952 "The exported libraries '{0}' and '{1}' cannot have the same name '{2} '");
3953
3954 /**
3955 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m &lt;
3956 * h</i> or if <i>m &gt; n</i>.
3957 *
3958 * Parameters:
3959 * 0: the maximum number of positional arguments
3960 * 1: the actual number of positional arguments given
3961 *
3962 * See [NOT_ENOUGH_REQUIRED_ARGUMENTS].
3963 */
3964 static const StaticWarningCode EXTRA_POSITIONAL_ARGUMENTS =
3965 const StaticWarningCode('EXTRA_POSITIONAL_ARGUMENTS',
3966 "{0} positional arguments expected, but {1} found");
3967
3968 /**
3969 * 5. Variables: It is a static warning if a final instance variable that has
3970 * been initialized at its point of declaration is also initialized in a
3971 * constructor.
3972 */
3973 static const StaticWarningCode FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATIO N =
3974 const StaticWarningCode(
3975 'FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION',
3976 "Values cannot be set in the constructor if they are final, and have a lready been set");
3977
3978 /**
3979 * 5. Variables: It is a static warning if a final instance variable that has
3980 * been initialized at its point of declaration is also initialized in a
3981 * constructor.
3982 *
3983 * Parameters:
3984 * 0: the name of the field in question
3985 */
3986 static const StaticWarningCode FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTO R =
3987 const StaticWarningCode(
3988 'FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR',
3989 "'{0}' is final and was given a value when it was declared, so it cann ot be set to a new value");
3990
3991 /**
3992 * 7.6.1 Generative Constructors: Execution of an initializer of the form
3993 * <b>this</b>.<i>v</i> = <i>e</i> proceeds as follows: First, the expression
3994 * <i>e</i> is evaluated to an object <i>o</i>. Then, the instance variable
3995 * <i>v</i> of the object denoted by this is bound to <i>o</i>.
3996 *
3997 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
3998 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
3999 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
4000 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
4001 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
4002 * &lt;= j &lt;= m</i>.
4003 *
4004 * Parameters:
4005 * 0: the name of the type of the initializer expression
4006 * 1: the name of the type of the field
4007 */
4008 static const StaticWarningCode FIELD_INITIALIZER_NOT_ASSIGNABLE =
4009 const StaticWarningCode('FIELD_INITIALIZER_NOT_ASSIGNABLE',
4010 "The initializer type '{0}' cannot be assigned to the field type '{1}' ");
4011
4012 /**
4013 * 7.6.1 Generative Constructors: An initializing formal has the form
4014 * <i>this.id</i>. It is a static warning if the static type of <i>id</i> is
4015 * not assignable to <i>T<sub>id</sub></i>.
4016 *
4017 * Parameters:
4018 * 0: the name of the type of the field formal parameter
4019 * 1: the name of the type of the field
4020 */
4021 static const StaticWarningCode FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE =
4022 const StaticWarningCode('FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE',
4023 "The parameter type '{0}' is incompatable with the field type '{1}'");
4024
4025 /**
4026 * 5 Variables: It is a static warning if a library, static or local variable
4027 * <i>v</i> is final and <i>v</i> is not initialized at its point of
4028 * declaration.
4029 *
4030 * Parameters:
4031 * 0: the name of the uninitialized final variable
4032 */
4033 static const StaticWarningCode FINAL_NOT_INITIALIZED =
4034 const StaticWarningCode('FINAL_NOT_INITIALIZED',
4035 "The final variable '{0}' must be initialized");
4036
4037 /**
4038 * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
4039 * declared in the immediately enclosing class must have an initializer in
4040 * <i>k</i>'s initializer list unless it has already been initialized by one
4041 * of the following means:
4042 * * Initialization at the declaration of <i>f</i>.
4043 * * Initialization by means of an initializing formal of <i>k</i>.
4044 * or a static warning occurs.
4045 *
4046 * Parameters:
4047 * 0: the name of the uninitialized final variable
4048 */
4049 static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_1 =
4050 const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_1',
4051 "The final variable '{0}' must be initialized");
4052
4053 /**
4054 * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
4055 * declared in the immediately enclosing class must have an initializer in
4056 * <i>k</i>'s initializer list unless it has already been initialized by one
4057 * of the following means:
4058 * * Initialization at the declaration of <i>f</i>.
4059 * * Initialization by means of an initializing formal of <i>k</i>.
4060 * or a static warning occurs.
4061 *
4062 * Parameters:
4063 * 0: the name of the uninitialized final variable
4064 * 1: the name of the uninitialized final variable
4065 */
4066 static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_2 =
4067 const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
4068 "The final variables '{0}' and '{1}' must be initialized");
4069
4070 /**
4071 * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
4072 * declared in the immediately enclosing class must have an initializer in
4073 * <i>k</i>'s initializer list unless it has already been initialized by one
4074 * of the following means:
4075 * * Initialization at the declaration of <i>f</i>.
4076 * * Initialization by means of an initializing formal of <i>k</i>.
4077 * or a static warning occurs.
4078 *
4079 * Parameters:
4080 * 0: the name of the uninitialized final variable
4081 * 1: the name of the uninitialized final variable
4082 * 2: the number of additional not initialized variables that aren't listed
4083 */
4084 static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS =
4085 const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_3',
4086 "The final variables '{0}', '{1}' and '{2}' more must be initialized") ;
4087
4088 /**
4089 * 15.5 Function Types: It is a static warning if a concrete class implements
4090 * Function and does not have a concrete method named call().
4091 */
4092 static const StaticWarningCode FUNCTION_WITHOUT_CALL = const StaticWarningCode (
4093 'FUNCTION_WITHOUT_CALL',
4094 "Concrete classes that implement Function must implement the method call() ");
4095
4096 /**
4097 * 14.1 Imports: It is a static warning to import two different libraries with
4098 * the same name.
4099 *
4100 * Parameters:
4101 * 0: the uri pointing to a first library
4102 * 1: the uri pointing to a second library
4103 * 2: the shared name of the imported libraries
4104 */
4105 static const StaticWarningCode IMPORT_DUPLICATED_LIBRARY_NAMED =
4106 const StaticWarningCode('IMPORT_DUPLICATED_LIBRARY_NAMED',
4107 "The imported libraries '{0}' and '{1}' cannot have the same name '{2} '");
4108
4109 /**
4110 * 14.1 Imports: It is a static warning if the specified URI of a deferred
4111 * import does not refer to a library declaration.
4112 *
4113 * Parameters:
4114 * 0: the uri pointing to a non-library declaration
4115 *
4116 * See [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY].
4117 */
4118 static const StaticWarningCode IMPORT_OF_NON_LIBRARY =
4119 const StaticWarningCode('IMPORT_OF_NON_LIBRARY',
4120 "The imported library '{0}' must not have a part-of directive");
4121
4122 /**
4123 * 8.1.1 Inheritance and Overriding: However, if the above rules would cause
4124 * multiple members <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> with the
4125 * same name <i>n</i> that would be inherited (because identically named
4126 * members existed in several superinterfaces) then at most one member is
4127 * inherited.
4128 *
4129 * If some but not all of the <i>m<sub>i</sub>, 1 &lt;= i &lt;= k</i> are
4130 * getters none of the <i>m<sub>i</sub></i> are inherited, and a static
4131 * warning is issued.
4132 */
4133 static const StaticWarningCode INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METH OD =
4134 const StaticWarningCode(
4135 'INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD',
4136 "'{0}' is inherited as a getter and also a method");
4137
4138 /**
4139 * 7.1 Instance Methods: It is a static warning if a class <i>C</i> declares
4140 * an instance method named <i>n</i> and an accessible static member named
4141 * <i>n</i> is declared in a superclass of <i>C</i>.
4142 *
4143 * Parameters:
4144 * 0: the name of the member with the name conflict
4145 * 1: the name of the enclosing class that has the static member
4146 */
4147 static const StaticWarningCode INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_S TATIC =
4148 const StaticWarningCode(
4149 'INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC',
4150 "'{0}' collides with a static member in the superclass '{1}'");
4151
4152 /**
4153 * 7.2 Getters: It is a static warning if a getter <i>m1</i> overrides a
4154 * getter <i>m2</i> and the type of <i>m1</i> is not a subtype of the type of
4155 * <i>m2</i>.
4156 *
4157 * Parameters:
4158 * 0: the name of the actual return type
4159 * 1: the name of the expected return type, not assignable to the actual
4160 * return type
4161 * 2: the name of the class where the overridden getter is declared
4162 *
4163 * See [INVALID_METHOD_OVERRIDE_RETURN_TYPE].
4164 */
4165 static const StaticWarningCode INVALID_GETTER_OVERRIDE_RETURN_TYPE =
4166 const StaticWarningCode('INVALID_GETTER_OVERRIDE_RETURN_TYPE',
4167 "The return type '{0}' is not assignable to '{1}' as required by the g etter it is overriding from '{2}'");
4168
4169 /**
4170 * 7.1 Instance Methods: It is a static warning if an instance method
4171 * <i>m1</i> overrides an instance method <i>m2</i> and the type of <i>m1</i>
4172 * is not a subtype of the type of <i>m2</i>.
4173 *
4174 * Parameters:
4175 * 0: the name of the actual parameter type
4176 * 1: the name of the expected parameter type, not assignable to the actual
4177 * parameter type
4178 * 2: the name of the class where the overridden method is declared
4179 */
4180 static const StaticWarningCode INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE =
4181 const StaticWarningCode('INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE',
4182 "The parameter type '{0}' is not assignable to '{1}' as required by th e method it is overriding from '{2}'");
4183
4184 /**
4185 * 7.1 Instance Methods: It is a static warning if an instance method
4186 * <i>m1</i> overrides an instance method <i>m2</i> and the type of <i>m1</i>
4187 * is not a subtype of the type of <i>m2</i>.
4188 *
4189 * Parameters:
4190 * 0: the name of the actual parameter type
4191 * 1: the name of the expected parameter type, not assignable to the actual
4192 * parameter type
4193 * 2: the name of the class where the overridden method is declared
4194 * See [INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE].
4195 */
4196 static const StaticWarningCode INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE =
4197 const StaticWarningCode('INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE',
4198 "The parameter type '{0}' is not assignable to '{1}' as required by th e method it is overriding from '{2}'");
4199
4200 /**
4201 * 7.1 Instance Methods: It is a static warning if an instance method
4202 * <i>m1</i> overrides an instance method <i>m2</i> and the type of <i>m1</i>
4203 * is not a subtype of the type of <i>m2</i>.
4204 *
4205 * Parameters:
4206 * 0: the name of the actual parameter type
4207 * 1: the name of the expected parameter type, not assignable to the actual
4208 * parameter type
4209 * 2: the name of the class where the overridden method is declared
4210 */
4211 static const StaticWarningCode INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE =
4212 const StaticWarningCode('INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE',
4213 "The parameter type '{0}' is not assignable to '{1}' as required by th e method it is overriding from '{2}'");
4214
4215 /**
4216 * 7.1 Instance Methods: It is a static warning if an instance method
4217 * <i>m1</i> overrides an instance method <i>m2</i> and the type of <i>m1</i>
4218 * is not a subtype of the type of <i>m2</i>.
4219 *
4220 * Parameters:
4221 * 0: the name of the actual return type
4222 * 1: the name of the expected return type, not assignable to the actual
4223 * return type
4224 * 2: the name of the class where the overridden method is declared
4225 *
4226 * See [INVALID_GETTER_OVERRIDE_RETURN_TYPE].
4227 */
4228 static const StaticWarningCode INVALID_METHOD_OVERRIDE_RETURN_TYPE =
4229 const StaticWarningCode('INVALID_METHOD_OVERRIDE_RETURN_TYPE',
4230 "The return type '{0}' is not assignable to '{1}' as required by the m ethod it is overriding from '{2}'");
4231
4232 /**
4233 * 7.1 Instance Methods: It is a static warning if an instance method
4234 * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
4235 * <i>m2</i> explicitly specifies a default value for a formal parameter
4236 * <i>p</i> and the signature of <i>m1</i> specifies a different default value
4237 * for <i>p</i>.
4238 */
4239 static const StaticWarningCode INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED =
4240 const StaticWarningCode('INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED',
4241 "Parameters cannot override default values, this method overrides '{0} .{1}' where '{2}' has a different value");
4242
4243 /**
4244 * 7.1 Instance Methods: It is a static warning if an instance method
4245 * <i>m1</i> overrides an instance member <i>m2</i>, the signature of
4246 * <i>m2</i> explicitly specifies a default value for a formal parameter
4247 * <i>p</i> and the signature of <i>m1</i> specifies a different default value
4248 * for <i>p</i>.
4249 */
4250 static const StaticWarningCode INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSIT IONAL =
4251 const StaticWarningCode(
4252 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL',
4253 "Parameters cannot override default values, this method overrides '{0} .{1}' where this positional parameter has a different value");
4254
4255 /**
4256 * 7.1 Instance Methods: It is a static warning if an instance method
4257 * <i>m1</i> overrides an instance member <i>m2</i> and <i>m1</i> does not
4258 * declare all the named parameters declared by <i>m2</i>.
4259 *
4260 * Parameters:
4261 * 0: the number of named parameters in the overridden member
4262 * 1: the name of the class from the overridden method
4263 */
4264 static const StaticWarningCode INVALID_OVERRIDE_NAMED = const StaticWarningCod e(
4265 'INVALID_OVERRIDE_NAMED',
4266 "Missing the named parameter '{0}' to match the overridden method from '{1 }'");
4267
4268 /**
4269 * 7.1 Instance Methods: It is a static warning if an instance method
4270 * <i>m1</i> overrides an instance member <i>m2</i> and <i>m1</i> has fewer
4271 * positional parameters than <i>m2</i>.
4272 *
4273 * Parameters:
4274 * 0: the number of positional parameters in the overridden member
4275 * 1: the name of the class from the overridden method
4276 */
4277 static const StaticWarningCode INVALID_OVERRIDE_POSITIONAL =
4278 const StaticWarningCode('INVALID_OVERRIDE_POSITIONAL',
4279 "Must have at least {0} parameters to match the overridden method from '{1}'");
4280
4281 /**
4282 * 7.1 Instance Methods: It is a static warning if an instance method
4283 * <i>m1</i> overrides an instance member <i>m2</i> and <i>m1</i> has a
4284 * greater number of required parameters than <i>m2</i>.
4285 *
4286 * Parameters:
4287 * 0: the number of required parameters in the overridden member
4288 * 1: the name of the class from the overridden method
4289 */
4290 static const StaticWarningCode INVALID_OVERRIDE_REQUIRED =
4291 const StaticWarningCode('INVALID_OVERRIDE_REQUIRED',
4292 "Must have {0} required parameters or less to match the overridden met hod from '{1}'");
4293
4294 /**
4295 * 7.3 Setters: It is a static warning if a setter <i>m1</i> overrides a
4296 * setter <i>m2</i> and the type of <i>m1</i> is not a subtype of the type of
4297 * <i>m2</i>.
4298 *
4299 * Parameters:
4300 * 0: the name of the actual parameter type
4301 * 1: the name of the expected parameter type, not assignable to the actual
4302 * parameter type
4303 * 2: the name of the class where the overridden setter is declared
4304 *
4305 * See [INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE].
4306 */
4307 static const StaticWarningCode INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE =
4308 const StaticWarningCode('INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE',
4309 "The parameter type '{0}' is not assignable to '{1}' as required by th e setter it is overriding from '{2}'");
4310
4311 /**
4312 * 12.6 Lists: A run-time list literal &lt;<i>E</i>&gt; [<i>e<sub>1</sub></i>
4313 * &hellip; <i>e<sub>n</sub></i>] is evaluated as follows:
4314 * * The operator []= is invoked on <i>a</i> with first argument <i>i</i> and
4315 * second argument <i>o<sub>i+1</sub></i><i>, 1 &lt;= i &lt;= n</i>
4316 *
4317 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
4318 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
4319 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
4320 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
4321 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
4322 * &lt;= j &lt;= m</i>.
4323 */
4324 static const StaticWarningCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
4325 const StaticWarningCode('LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
4326 "The element type '{0}' cannot be assigned to the list type '{1}'");
4327
4328 /**
4329 * 12.7 Map: A run-time map literal &lt;<i>K</i>, <i>V</i>&gt;
4330 * [<i>k<sub>1</sub></i> : <i>e<sub>1</sub></i> &hellip; <i>k<sub>n</sub></i>
4331 * : <i>e<sub>n</sub></i>] is evaluated as follows:
4332 * * The operator []= is invoked on <i>m</i> with first argument
4333 * <i>k<sub>i</sub></i> and second argument <i>e<sub>i</sub></i><i>, 1 &lt;=
4334 * i &lt;= n</i>
4335 *
4336 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
4337 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
4338 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
4339 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
4340 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
4341 * &lt;= j &lt;= m</i>.
4342 */
4343 static const StaticWarningCode MAP_KEY_TYPE_NOT_ASSIGNABLE =
4344 const StaticWarningCode('MAP_KEY_TYPE_NOT_ASSIGNABLE',
4345 "The element type '{0}' cannot be assigned to the map key type '{1}'") ;
4346
4347 /**
4348 * 12.7 Map: A run-time map literal &lt;<i>K</i>, <i>V</i>&gt;
4349 * [<i>k<sub>1</sub></i> : <i>e<sub>1</sub></i> &hellip; <i>k<sub>n</sub></i>
4350 * : <i>e<sub>n</sub></i>] is evaluated as follows:
4351 * * The operator []= is invoked on <i>m</i> with first argument
4352 * <i>k<sub>i</sub></i> and second argument <i>e<sub>i</sub></i><i>, 1 &lt;=
4353 * i &lt;= n</i>
4354 *
4355 * 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
4356 * type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
4357 * <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
4358 * the type of the named parameter <i>q</i> of <i>f</i>. It is a static
4359 * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
4360 * &lt;= j &lt;= m</i>.
4361 */
4362 static const StaticWarningCode MAP_VALUE_TYPE_NOT_ASSIGNABLE =
4363 const StaticWarningCode('MAP_VALUE_TYPE_NOT_ASSIGNABLE',
4364 "The element type '{0}' cannot be assigned to the map value type '{1}' ");
4365
4366 /**
4367 * 7.3 Setters: It is a static warning if a class has a setter named <i>v=</i>
4368 * with argument type <i>T</i> and a getter named <i>v</i> with return type
4369 * <i>S</i>, and <i>T</i> may not be assigned to <i>S</i>.
4370 */
4371 static const StaticWarningCode MISMATCHED_GETTER_AND_SETTER_TYPES =
4372 const StaticWarningCode('MISMATCHED_GETTER_AND_SETTER_TYPES',
4373 "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}')");
4374
4375 /**
4376 * 7.3 Setters: It is a static warning if a class has a setter named <i>v=</i>
4377 * with argument type <i>T</i> and a getter named <i>v</i> with return type
4378 * <i>S</i>, and <i>T</i> may not be assigned to <i>S</i>.
4379 */
4380 static const StaticWarningCode MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTY PE =
4381 const StaticWarningCode(
4382 'MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE',
4383 "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}'), from superclass '{3}'");
4384
4385 /**
4386 * 13.12 Return: It is a static warning if a function contains both one or
4387 * more return statements of the form <i>return;</i> and one or more return
4388 * statements of the form <i>return e;</i>.
4389 */
4390 static const StaticWarningCode MIXED_RETURN_TYPES = const StaticWarningCode(
4391 'MIXED_RETURN_TYPES',
4392 "Methods and functions cannot use return both with and without values");
4393
4394 /**
4395 * 12.11.1 New: It is a static warning if <i>q</i> is a constructor of an
4396 * abstract class and <i>q</i> is not a factory constructor.
4397 */
4398 static const StaticWarningCode NEW_WITH_ABSTRACT_CLASS =
4399 const StaticWarningCode('NEW_WITH_ABSTRACT_CLASS',
4400 "Abstract classes cannot be created with a 'new' expression");
4401
4402 /**
4403 * 15.8 Parameterized Types: Any use of a malbounded type gives rise to a
4404 * static warning.
4405 *
4406 * Parameters:
4407 * 0: the name of the type being referenced (<i>S</i>)
4408 * 1: the number of type parameters that were declared
4409 * 2: the number of type arguments provided
4410 *
4411 * See [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS], and
4412 * [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS].
4413 */
4414 static const StaticWarningCode NEW_WITH_INVALID_TYPE_PARAMETERS =
4415 const StaticWarningCode('NEW_WITH_INVALID_TYPE_PARAMETERS',
4416 "The type '{0}' is declared with {1} type parameters, but {2} type arg uments were given");
4417
4418 /**
4419 * 12.11.1 New: It is a static warning if <i>T</i> is not a class accessible
4420 * in the current scope, optionally followed by type arguments.
4421 *
4422 * Parameters:
4423 * 0: the name of the non-type element
4424 */
4425 static const StaticWarningCode NEW_WITH_NON_TYPE = const StaticWarningCode(
4426 'NEW_WITH_NON_TYPE', "The name '{0}' is not a class");
4427
4428 /**
4429 * 12.11.1 New: If <i>T</i> is a class or parameterized type accessible in the
4430 * current scope then:
4431 * 1. If <i>e</i> is of the form <i>new T.id(a<sub>1</sub>, &hellip;,
4432 * a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;,
4433 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a static warning if
4434 * <i>T.id</i> is not the name of a constructor declared by the type
4435 * <i>T</i>.
4436 * If <i>e</i> of the form <i>new T(a<sub>1</sub>, &hellip;, a<sub>n</sub>,
4437 * x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;, x<sub>n+k</sub>:
4438 * a<sub>n+kM/sub>)</i> it is a static warning if the type <i>T</i> does not
4439 * declare a constructor with the same name as the declaration of <i>T</i>.
4440 */
4441 static const StaticWarningCode NEW_WITH_UNDEFINED_CONSTRUCTOR =
4442 const StaticWarningCode('NEW_WITH_UNDEFINED_CONSTRUCTOR',
4443 "The class '{0}' does not have a constructor '{1}'");
4444
4445 /**
4446 * 12.11.1 New: If <i>T</i> is a class or parameterized type accessible in the
4447 * current scope then:
4448 * 1. If <i>e</i> is of the form <i>new T.id(a<sub>1</sub>, &hellip;,
4449 * a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, &hellip;, x<sub>n+k</sub>:
4450 * a<sub>n+k</sub>)</i> it is a static warning if <i>T.id</i> is not the name
4451 * of a constructor declared by the type <i>T</i>. If <i>e</i> of the form
4452 * <i>new T(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
4453 * a<sub>n+1</sub>, &hellip;, x<sub>n+k</sub>: a<sub>n+kM/sub>)</i> it is a
4454 * static warning if the type <i>T</i> does not declare a constructor with the
4455 * same name as the declaration of <i>T</i>.
4456 */
4457 static const StaticWarningCode NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
4458 const StaticWarningCode('NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
4459 "The class '{0}' does not have a default constructor");
4460
4461 /**
4462 * 7.9.1 Inheritance and Overriding: It is a static warning if a non-abstract
4463 * class inherits an abstract method.
4464 *
4465 * 7.10 Superinterfaces: Let <i>C</i> be a concrete class that does not
4466 * declare its own <i>noSuchMethod()</i> method. It is a static warning if the
4467 * implicit interface of <i>C</i> includes an instance member <i>m</i> of type
4468 * <i>F</i> and <i>C</i> does not declare or inherit a corresponding instance
4469 * member <i>m</i> of type <i>F'</i> such that <i>F' <: F</i>.
4470 *
4471 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
4472 * is declared or inherited in a concrete class unless that member overrides a
4473 * concrete one.
4474 *
4475 * Parameters:
4476 * 0: the name of the first member
4477 * 1: the name of the second member
4478 * 2: the name of the third member
4479 * 3: the name of the fourth member
4480 * 4: the number of additional missing members that aren't listed
4481 */
4482 static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIV E_PLUS =
4483 const StaticWarningCode(
4484 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS',
4485 "Missing concrete implementation of {0}, {1}, {2}, {3} and {4} more");
4486
4487 /**
4488 * 7.9.1 Inheritance and Overriding: It is a static warning if a non-abstract
4489 * class inherits an abstract method.
4490 *
4491 * 7.10 Superinterfaces: Let <i>C</i> be a concrete class that does not
4492 * declare its own <i>noSuchMethod()</i> method. It is a static warning if the
4493 * implicit interface of <i>C</i> includes an instance member <i>m</i> of type
4494 * <i>F</i> and <i>C</i> does not declare or inherit a corresponding instance
4495 * member <i>m</i> of type <i>F'</i> such that <i>F' <: F</i>.
4496 *
4497 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
4498 * is declared or inherited in a concrete class unless that member overrides a
4499 * concrete one.
4500 *
4501 * Parameters:
4502 * 0: the name of the first member
4503 * 1: the name of the second member
4504 * 2: the name of the third member
4505 * 3: the name of the fourth member
4506 */
4507 static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOU R =
4508 const StaticWarningCode(
4509 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR',
4510 "Missing concrete implementation of {0}, {1}, {2} and {3}");
4511
4512 /**
4513 * 7.9.1 Inheritance and Overriding: It is a static warning if a non-abstract
4514 * class inherits an abstract method.
4515 *
4516 * 7.10 Superinterfaces: Let <i>C</i> be a concrete class that does not
4517 * declare its own <i>noSuchMethod()</i> method. It is a static warning if the
4518 * implicit interface of <i>C</i> includes an instance member <i>m</i> of type
4519 * <i>F</i> and <i>C</i> does not declare or inherit a corresponding instance
4520 * member <i>m</i> of type <i>F'</i> such that <i>F' <: F</i>.
4521 *
4522 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
4523 * is declared or inherited in a concrete class unless that member overrides a
4524 * concrete one.
4525 *
4526 * Parameters:
4527 * 0: the name of the member
4528 */
4529 static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE =
4530 const StaticWarningCode('NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
4531 "Missing concrete implementation of {0}");
4532
4533 /**
4534 * 7.9.1 Inheritance and Overriding: It is a static warning if a non-abstract
4535 * class inherits an abstract method.
4536 *
4537 * 7.10 Superinterfaces: Let <i>C</i> be a concrete class that does not
4538 * declare its own <i>noSuchMethod()</i> method. It is a static warning if the
4539 * implicit interface of <i>C</i> includes an instance member <i>m</i> of type
4540 * <i>F</i> and <i>C</i> does not declare or inherit a corresponding instance
4541 * member <i>m</i> of type <i>F'</i> such that <i>F' <: F</i>.
4542 *
4543 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
4544 * is declared or inherited in a concrete class unless that member overrides a
4545 * concrete one.
4546 *
4547 * Parameters:
4548 * 0: the name of the first member
4549 * 1: the name of the second member
4550 * 2: the name of the third member
4551 */
4552 static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THR EE =
4553 const StaticWarningCode(
4554 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE',
4555 "Missing concrete implementation of {0}, {1} and {2}");
4556
4557 /**
4558 * 7.9.1 Inheritance and Overriding: It is a static warning if a non-abstract
4559 * class inherits an abstract method.
4560 *
4561 * 7.10 Superinterfaces: Let <i>C</i> be a concrete class that does not
4562 * declare its own <i>noSuchMethod()</i> method. It is a static warning if the
4563 * implicit interface of <i>C</i> includes an instance member <i>m</i> of type
4564 * <i>F</i> and <i>C</i> does not declare or inherit a corresponding instance
4565 * member <i>m</i> of type <i>F'</i> such that <i>F' <: F</i>.
4566 *
4567 * 7.4 Abstract Instance Members: It is a static warning if an abstract member
4568 * is declared or inherited in a concrete class unless that member overrides a
4569 * concrete one.
4570 *
4571 * Parameters:
4572 * 0: the name of the first member
4573 * 1: the name of the second member
4574 */
4575 static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO =
4576 const StaticWarningCode('NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
4577 "Missing concrete implementation of {0} and {1}");
4578
4579 /**
4580 * 13.11 Try: An on-catch clause of the form <i>on T catch (p<sub>1</sub>,
4581 * p<sub>2</sub>) s</i> or <i>on T s</i> matches an object <i>o</i> if the
4582 * type of <i>o</i> is a subtype of <i>T</i>. It is a static warning if
4583 * <i>T</i> does not denote a type available in the lexical scope of the
4584 * catch clause.
4585 *
4586 * Parameters:
4587 * 0: the name of the non-type element
4588 */
4589 static const StaticWarningCode NON_TYPE_IN_CATCH_CLAUSE =
4590 const StaticWarningCode('NON_TYPE_IN_CATCH_CLAUSE',
4591 "The name '{0}' is not a type and cannot be used in an on-catch clause ");
4592
4593 /**
4594 * 7.1.1 Operators: It is a static warning if the return type of the
4595 * user-declared operator []= is explicitly declared and not void.
4596 */
4597 static const StaticWarningCode NON_VOID_RETURN_FOR_OPERATOR =
4598 const StaticWarningCode('NON_VOID_RETURN_FOR_OPERATOR',
4599 "The return type of the operator []= must be 'void'");
4600
4601 /**
4602 * 7.3 Setters: It is a static warning if a setter declares a return type
4603 * other than void.
4604 */
4605 static const StaticWarningCode NON_VOID_RETURN_FOR_SETTER =
4606 const StaticWarningCode('NON_VOID_RETURN_FOR_SETTER',
4607 "The return type of the setter must be 'void'");
4608
4609 /**
4610 * 15.1 Static Types: A type <i>T</i> is malformed iff:
4611 * * <i>T</i> has the form <i>id</i> or the form <i>prefix.id</i>, and in the
4612 * enclosing lexical scope, the name <i>id</i> (respectively
4613 * <i>prefix.id</i>) does not denote a type.
4614 * * <i>T</i> denotes a type parameter in the enclosing lexical scope, but
4615 * occurs in the signature or body of a static member.
4616 * * <i>T</i> is a parameterized type of the form <i>G&lt;S<sub>1</sub>, ..,
4617 * S<sub>n</sub>&gt;</i>,
4618 *
4619 * Any use of a malformed type gives rise to a static warning.
4620 *
4621 * Parameters:
4622 * 0: the name that is not a type
4623 */
4624 static const StaticWarningCode NOT_A_TYPE =
4625 const StaticWarningCode('NOT_A_TYPE', "{0} is not a type");
4626
4627 /**
4628 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m &lt;
4629 * h</i> or if <i>m &gt; n</i>.
4630 *
4631 * Parameters:
4632 * 0: the expected number of required arguments
4633 * 1: the actual number of positional arguments given
4634 *
4635 * See [EXTRA_POSITIONAL_ARGUMENTS].
4636 */
4637 static const StaticWarningCode NOT_ENOUGH_REQUIRED_ARGUMENTS =
4638 const StaticWarningCode('NOT_ENOUGH_REQUIRED_ARGUMENTS',
4639 "{0} required argument(s) expected, but {1} found");
4640
4641 /**
4642 * 14.3 Parts: It is a static warning if the referenced part declaration
4643 * <i>p</i> names a library other than the current library as the library to
4644 * which <i>p</i> belongs.
4645 *
4646 * Parameters:
4647 * 0: the name of expected library name
4648 * 1: the non-matching actual library name from the "part of" declaration
4649 */
4650 static const StaticWarningCode PART_OF_DIFFERENT_LIBRARY =
4651 const StaticWarningCode('PART_OF_DIFFERENT_LIBRARY',
4652 "Expected this library to be part of '{0}', not '{1}'");
4653
4654 /**
4655 * 7.6.2 Factories: It is a static warning if the function type of <i>k'</i>
4656 * is not a subtype of the type of <i>k</i>.
4657 *
4658 * Parameters:
4659 * 0: the name of the redirected constructor
4660 * 1: the name of the redirecting constructor
4661 */
4662 static const StaticWarningCode REDIRECT_TO_INVALID_FUNCTION_TYPE =
4663 const StaticWarningCode('REDIRECT_TO_INVALID_FUNCTION_TYPE',
4664 "The redirected constructor '{0}' has incompatible parameters with '{1 }'");
4665
4666 /**
4667 * 7.6.2 Factories: It is a static warning if the function type of <i>k'</i>
4668 * is not a subtype of the type of <i>k</i>.
4669 *
4670 * Parameters:
4671 * 0: the name of the redirected constructor return type
4672 * 1: the name of the redirecting constructor return type
4673 */
4674 static const StaticWarningCode REDIRECT_TO_INVALID_RETURN_TYPE =
4675 const StaticWarningCode('REDIRECT_TO_INVALID_RETURN_TYPE',
4676 "The return type '{0}' of the redirected constructor is not assignable to '{1}'");
4677
4678 /**
4679 * 7.6.2 Factories: It is a static warning if type does not denote a class
4680 * accessible in the current scope; if type does denote such a class <i>C</i>
4681 * it is a static warning if the referenced constructor (be it <i>type</i> or
4682 * <i>type.id</i>) is not a constructor of <i>C</i>.
4683 */
4684 static const StaticWarningCode REDIRECT_TO_MISSING_CONSTRUCTOR =
4685 const StaticWarningCode('REDIRECT_TO_MISSING_CONSTRUCTOR',
4686 "The constructor '{0}' could not be found in '{1}'");
4687
4688 /**
4689 * 7.6.2 Factories: It is a static warning if type does not denote a class
4690 * accessible in the current scope; if type does denote such a class <i>C</i>
4691 * it is a static warning if the referenced constructor (be it <i>type</i> or
4692 * <i>type.id</i>) is not a constructor of <i>C</i>.
4693 */
4694 static const StaticWarningCode REDIRECT_TO_NON_CLASS = const StaticWarningCode (
4695 'REDIRECT_TO_NON_CLASS',
4696 "The name '{0}' is not a type and cannot be used in a redirected construct or");
4697
4698 /**
4699 * 13.12 Return: Let <i>f</i> be the function immediately enclosing a return
4700 * statement of the form <i>return;</i> It is a static warning if both of the
4701 * following conditions hold:
4702 * * <i>f</i> is not a generative constructor.
4703 * * The return type of <i>f</i> may not be assigned to void.
4704 */
4705 static const StaticWarningCode RETURN_WITHOUT_VALUE = const StaticWarningCode(
4706 'RETURN_WITHOUT_VALUE', "Missing return value after 'return'");
4707
4708 /**
4709 * 12.16.3 Static Invocation: It is a static warning if <i>C</i> does not
4710 * declare a static method or getter <i>m</i>.
4711 *
4712 * Parameters:
4713 * 0: the name of the instance member
4714 */
4715 static const StaticWarningCode STATIC_ACCESS_TO_INSTANCE_MEMBER =
4716 const StaticWarningCode('STATIC_ACCESS_TO_INSTANCE_MEMBER',
4717 "Instance member '{0}' cannot be accessed using static access");
4718
4719 /**
4720 * 13.9 Switch: It is a static warning if the type of <i>e</i> may not be
4721 * assigned to the type of <i>e<sub>k</sub></i>.
4722 */
4723 static const StaticWarningCode SWITCH_EXPRESSION_NOT_ASSIGNABLE =
4724 const StaticWarningCode('SWITCH_EXPRESSION_NOT_ASSIGNABLE',
4725 "Type '{0}' of the switch expression is not assignable to the type '{1 }' of case expressions");
4726
4727 /**
4728 * 15.1 Static Types: It is a static warning to use a deferred type in a type
4729 * annotation.
4730 *
4731 * Parameters:
4732 * 0: the name of the type that is deferred and being used in a type
4733 * annotation
4734 */
4735 static const StaticWarningCode TYPE_ANNOTATION_DEFERRED_CLASS =
4736 const StaticWarningCode('TYPE_ANNOTATION_DEFERRED_CLASS',
4737 "The deferred type '{0}' cannot be used in a declaration, cast or type test");
4738
4739 /**
4740 * 12.31 Type Test: It is a static warning if <i>T</i> does not denote a type
4741 * available in the current lexical scope.
4742 */
4743 static const StaticWarningCode TYPE_TEST_WITH_NON_TYPE = const StaticWarningCo de(
4744 'TYPE_TEST_WITH_NON_TYPE',
4745 "The name '{0}' is not a type and cannot be used in an 'is' expression");
4746
4747 /**
4748 * 12.31 Type Test: It is a static warning if <i>T</i> does not denote a type
4749 * available in the current lexical scope.
4750 */
4751 static const StaticWarningCode TYPE_TEST_WITH_UNDEFINED_NAME =
4752 const StaticWarningCode('TYPE_TEST_WITH_UNDEFINED_NAME',
4753 "The name '{0}' is not defined and cannot be used in an 'is' expressio n");
4754
4755 /**
4756 * 10 Generics: However, a type parameter is considered to be a malformed type
4757 * when referenced by a static member.
4758 *
4759 * 15.1 Static Types: Any use of a malformed type gives rise to a static
4760 * warning. A malformed type is then interpreted as dynamic by the static type
4761 * checker and the runtime.
4762 */
4763 static const StaticWarningCode TYPE_PARAMETER_REFERENCED_BY_STATIC =
4764 const StaticWarningCode('TYPE_PARAMETER_REFERENCED_BY_STATIC',
4765 "Static members cannot reference type parameters");
4766
4767 /**
4768 * 12.16.3 Static Invocation: A static method invocation <i>i</i> has the form
4769 * <i>C.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
4770 * a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a
4771 * static warning if <i>C</i> does not denote a class in the current scope.
4772 *
4773 * Parameters:
4774 * 0: the name of the undefined class
4775 */
4776 static const StaticWarningCode UNDEFINED_CLASS =
4777 const StaticWarningCode('UNDEFINED_CLASS', "Undefined class '{0}'");
4778
4779 /**
4780 * Same as [UNDEFINED_CLASS], but to catch using "boolean" instead of "bool".
4781 */
4782 static const StaticWarningCode UNDEFINED_CLASS_BOOLEAN =
4783 const StaticWarningCode('UNDEFINED_CLASS_BOOLEAN',
4784 "Undefined class 'boolean'; did you mean 'bool'?");
4785
4786 /**
4787 * 12.17 Getter Invocation: It is a static warning if there is no class
4788 * <i>C</i> in the enclosing lexical scope of <i>i</i>, or if <i>C</i> does
4789 * not declare, implicitly or explicitly, a getter named <i>m</i>.
4790 *
4791 * Parameters:
4792 * 0: the name of the getter
4793 * 1: the name of the enclosing type where the getter is being looked for
4794 */
4795 static const StaticWarningCode UNDEFINED_GETTER = const StaticWarningCode(
4796 'UNDEFINED_GETTER',
4797 "The getter '{0}' is not defined for the class '{1}'");
4798
4799 /**
4800 * 12.30 Identifier Reference: It is as static warning if an identifier
4801 * expression of the form <i>id</i> occurs inside a top level or static
4802 * function (be it function, method, getter, or setter) or variable
4803 * initializer and there is no declaration <i>d</i> with name <i>id</i> in the
4804 * lexical scope enclosing the expression.
4805 *
4806 * Parameters:
4807 * 0: the name of the identifier
4808 */
4809 static const StaticWarningCode UNDEFINED_IDENTIFIER =
4810 const StaticWarningCode('UNDEFINED_IDENTIFIER', "Undefined name '{0}'");
4811
4812 /**
4813 * 12.14.2 Binding Actuals to Formals: Furthermore, each <i>q<sub>i</sub></i>,
4814 * <i>1<=i<=l</i>, must have a corresponding named parameter in the set
4815 * {<i>p<sub>n+1</sub></i> &hellip; <i>p<sub>n+k</sub></i>} or a static
4816 * warning occurs.
4817 *
4818 * Parameters:
4819 * 0: the name of the requested named parameter
4820 */
4821 static const StaticWarningCode UNDEFINED_NAMED_PARAMETER =
4822 const StaticWarningCode('UNDEFINED_NAMED_PARAMETER',
4823 "The named parameter '{0}' is not defined");
4824
4825 /**
4826 * 12.18 Assignment: It is as static warning if an assignment of the form
4827 * <i>v = e</i> occurs inside a top level or static function (be it function,
4828 * method, getter, or setter) or variable initializer and there is no
4829 * declaration <i>d</i> with name <i>v=</i> in the lexical scope enclosing the
4830 * assignment.
4831 *
4832 * 12.18 Assignment: It is a static warning if there is no class <i>C</i> in
4833 * the enclosing lexical scope of the assignment, or if <i>C</i> does not
4834 * declare, implicitly or explicitly, a setter <i>v=</i>.
4835 *
4836 * Parameters:
4837 * 0: the name of the getter
4838 * 1: the name of the enclosing type where the setter is being looked for
4839 */
4840 static const StaticWarningCode UNDEFINED_SETTER = const StaticWarningCode(
4841 'UNDEFINED_SETTER',
4842 "The setter '{0}' is not defined for the class '{1}'");
4843
4844 /**
4845 * 12.16.3 Static Invocation: It is a static warning if <i>C</i> does not
4846 * declare a static method or getter <i>m</i>.
4847 *
4848 * Parameters:
4849 * 0: the name of the method
4850 * 1: the name of the enclosing type where the method is being looked for
4851 */
4852 static const StaticWarningCode UNDEFINED_STATIC_METHOD_OR_GETTER =
4853 const StaticWarningCode('UNDEFINED_STATIC_METHOD_OR_GETTER',
4854 "The static method, getter or setter '{0}' is not defined for the clas s '{1}'");
4855
4856 /**
4857 * 12.17 Getter Invocation: It is a static warning if there is no class
4858 * <i>C</i> in the enclosing lexical scope of <i>i</i>, or if <i>C</i> does
4859 * not declare, implicitly or explicitly, a getter named <i>m</i>.
4860 *
4861 * Parameters:
4862 * 0: the name of the getter
4863 * 1: the name of the enclosing type where the getter is being looked for
4864 */
4865 static const StaticWarningCode UNDEFINED_SUPER_GETTER =
4866 const StaticWarningCode('UNDEFINED_SUPER_GETTER',
4867 "The getter '{0}' is not defined in a superclass of '{1}'");
4868
4869 /**
4870 * 12.18 Assignment: It is as static warning if an assignment of the form
4871 * <i>v = e</i> occurs inside a top level or static function (be it function,
4872 * method, getter, or setter) or variable initializer and there is no
4873 * declaration <i>d</i> with name <i>v=</i> in the lexical scope enclosing the
4874 * assignment.
4875 *
4876 * 12.18 Assignment: It is a static warning if there is no class <i>C</i> in
4877 * the enclosing lexical scope of the assignment, or if <i>C</i> does not
4878 * declare, implicitly or explicitly, a setter <i>v=</i>.
4879 *
4880 * Parameters:
4881 * 0: the name of the getter
4882 * 1: the name of the enclosing type where the setter is being looked for
4883 */
4884 static const StaticWarningCode UNDEFINED_SUPER_SETTER =
4885 const StaticWarningCode('UNDEFINED_SUPER_SETTER',
4886 "The setter '{0}' is not defined in a superclass of '{1}'");
4887
4888 /**
4889 * 7.2 Getters: It is a static warning if the return type of a getter is void.
4890 */
4891 static const StaticWarningCode VOID_RETURN_FOR_GETTER =
4892 const StaticWarningCode('VOID_RETURN_FOR_GETTER',
4893 "The return type of the getter must not be 'void'");
4894
4895 /**
4896 * Initialize a newly created error code to have the given [name]. The message
4897 * associated with the error will be created from the given [message]
4898 * template. The correction associated with the error will be created from the
4899 * given [correction] template.
4900 */
4901 const StaticWarningCode(String name, String message, [String correction])
4902 : super(name, message, correction);
4903
4904 @override
4905 ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity;
4906
4907 @override
4908 ErrorType get type => ErrorType.STATIC_WARNING;
4909 }
4910
4911 /**
4912 * The error code indicating a marker in code for work that needs to be finished
4913 * or revisited.
4914 */
4915 class TodoCode extends ErrorCode {
4916 /**
4917 * The single enum of TodoCode.
4918 */
4919 static const TodoCode TODO = const TodoCode('TODO');
4920
4921 /**
4922 * This matches the two common Dart task styles
4923 *
4924 * * TODO:
4925 * * TODO(username):
4926 *
4927 * As well as
4928 * * TODO
4929 *
4930 * But not
4931 * * todo
4932 * * TODOS
4933 */
4934 static RegExp TODO_REGEX =
4935 new RegExp("([\\s/\\*])((TODO[^\\w\\d][^\\r\\n]*)|(TODO:?\$))");
4936
4937 /**
4938 * Initialize a newly created error code to have the given [name].
4939 */
4940 const TodoCode(String name) : super(name, "{0}");
4941
4942 @override
4943 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
4944
4945 @override
4946 ErrorType get type => ErrorType.TODO;
4947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698