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

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

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

Powered by Google App Engine
This is Rietveld 408576698