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

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

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

Powered by Google App Engine
This is Rietveld 408576698