| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of dart2js; | |
| 6 | |
| 7 const DONT_KNOW_HOW_TO_FIX = ""; | |
| 8 | |
| 9 /** | |
| 10 * The messages in this file should meet the following guide lines: | |
| 11 * | |
| 12 * 1. The message should be a complete sentence starting with an uppercase | |
| 13 * letter, and ending with a period. | |
| 14 * | |
| 15 * 2. Reserved words and embedded identifiers should be in single quotes, so | |
| 16 * prefer double quotes for the complete message. For example, "The | |
| 17 * class '#{className}' can't use 'super'." Notice that the word 'class' in the | |
| 18 * preceding message is not quoted as it refers to the concept 'class', not the | |
| 19 * reserved word. On the other hand, 'super' refers to the reserved word. Do | |
| 20 * not quote 'null' and numeric literals. | |
| 21 * | |
| 22 * 3. Do not try to compose messages, as it can make translating them hard. | |
| 23 * | |
| 24 * 4. Try to keep the error messages short, but informative. | |
| 25 * | |
| 26 * 5. Use simple words and terminology, assume the reader of the message | |
| 27 * doesn't have an advanced degree in math, and that English is not the | |
| 28 * reader's native language. Do not assume any formal computer science | |
| 29 * training. For example, do not use Latin abbreviations (prefer "that is" over | |
| 30 * "i.e.", and "for example" over "e.g."). Also avoid phrases such as "if and | |
| 31 * only if" and "iff", that level of precision is unnecessary. | |
| 32 * | |
| 33 * 6. Prefer contractions when they are in common use, for example, prefer | |
| 34 * "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is | |
| 35 * off-putting to people new to programming. | |
| 36 * | |
| 37 * 7. Use common terminology, preferably from the Dart Language | |
| 38 * Specification. This increases the user's chance of finding a good | |
| 39 * explanation on the web. | |
| 40 * | |
| 41 * 8. Do not try to be cute or funny. It is extremely frustrating to work on a | |
| 42 * product that crashes with a "tongue-in-cheek" message, especially if you did | |
| 43 * not want to use this product to begin with with. | |
| 44 * | |
| 45 * 9. Do not lie, that is, do not write error messages containing phrases like | |
| 46 * "can't happen". If the user ever saw this message, it would be a | |
| 47 * lie. Prefer messages like: "Internal error: This function should not be | |
| 48 * called when 'x' is null.". | |
| 49 * | |
| 50 * 10. Prefer to not use imperative tone. That is, the message should not sound | |
| 51 * accusing or like it is ordering the user around. The computer should | |
| 52 * describe the problem, not criticize for violating the specification. | |
| 53 * | |
| 54 * Other things to keep in mind: | |
| 55 * | |
| 56 * An INFO message should always be preceded by a non-INFO message, and the | |
| 57 * INFO messages are additional details about the preceding non-INFO | |
| 58 * message. For example, consider duplicated elements. First report a WARNING | |
| 59 * or ERROR about the duplicated element, and then report an INFO about the | |
| 60 * location of the existing element. | |
| 61 * | |
| 62 * Generally, we want to provide messages that consists of three sentences: | |
| 63 * 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we | |
| 64 * combine the first two in [template] and the last in [howToFix]. | |
| 65 */ | |
| 66 // TODO(johnnniwinther): For Infos, consider adding a reference to the | |
| 67 // error/warning/hint that they belong to. | |
| 68 class MessageKind { | |
| 69 /// Should describe what is wrong and why. | |
| 70 final String template; | |
| 71 | |
| 72 /// Should describe how to fix the problem. Elided when using --terse option. | |
| 73 final String howToFix; | |
| 74 | |
| 75 /** | |
| 76 * Examples will be checked by | |
| 77 * tests/compiler/dart2js/message_kind_test.dart. | |
| 78 * | |
| 79 * An example is either a String containing the example source code or a Map | |
| 80 * from filenames to source code. In the latter case, the filename for the | |
| 81 * main library code must be 'main.dart'. | |
| 82 */ | |
| 83 final List examples; | |
| 84 | |
| 85 const MessageKind(this.template, {this.howToFix, this.examples}); | |
| 86 | |
| 87 /// Do not use this. It is here for legacy and debugging. It violates item 4 | |
| 88 /// above. | |
| 89 static const MessageKind GENERIC = const MessageKind('#{text}'); | |
| 90 | |
| 91 static const MessageKind NOT_ASSIGNABLE = const MessageKind( | |
| 92 "'#{fromType}' is not assignable to '#{toType}'."); | |
| 93 | |
| 94 static const MessageKind VOID_EXPRESSION = const MessageKind( | |
| 95 "Expression does not yield a value."); | |
| 96 | |
| 97 static const MessageKind VOID_VARIABLE = const MessageKind( | |
| 98 "Variable cannot be of type void."); | |
| 99 | |
| 100 static const MessageKind RETURN_VALUE_IN_VOID = const MessageKind( | |
| 101 "Cannot return value from void function."); | |
| 102 | |
| 103 static const MessageKind RETURN_NOTHING = const MessageKind( | |
| 104 "Value of type '#{returnType}' expected."); | |
| 105 | |
| 106 static const MessageKind MISSING_ARGUMENT = const MessageKind( | |
| 107 "Missing argument of type '#{argumentType}'."); | |
| 108 | |
| 109 static const MessageKind ADDITIONAL_ARGUMENT = const MessageKind( | |
| 110 "Additional argument."); | |
| 111 | |
| 112 static const MessageKind NAMED_ARGUMENT_NOT_FOUND = const MessageKind( | |
| 113 "No named argument '#{argumentName}' found on method."); | |
| 114 | |
| 115 static const MessageKind MEMBER_NOT_FOUND = const MessageKind( | |
| 116 "No member named '#{memberName}' in class '#{className}'."); | |
| 117 | |
| 118 static const MessageKind METHOD_NOT_FOUND = const MessageKind( | |
| 119 "No method named '#{memberName}' in class '#{className}'."); | |
| 120 | |
| 121 static const MessageKind OPERATOR_NOT_FOUND = const MessageKind( | |
| 122 "No operator '#{memberName}' in class '#{className}'."); | |
| 123 | |
| 124 static const MessageKind SETTER_NOT_FOUND = const MessageKind( | |
| 125 "No setter named '#{memberName}' in class '#{className}'."); | |
| 126 | |
| 127 static const MessageKind GETTER_NOT_FOUND = const MessageKind( | |
| 128 "No getter named '#{memberName}' in class '#{className}'."); | |
| 129 | |
| 130 static const MessageKind NOT_CALLABLE = const MessageKind( | |
| 131 "'#{elementName}' is not callable."); | |
| 132 | |
| 133 static const MessageKind MEMBER_NOT_STATIC = const MessageKind( | |
| 134 "'#{className}.#{memberName}' is not static."); | |
| 135 | |
| 136 static const MessageKind NO_INSTANCE_AVAILABLE = const MessageKind( | |
| 137 "'#{name}' is only available in instance methods."); | |
| 138 | |
| 139 static const MessageKind PRIVATE_ACCESS = const MessageKind( | |
| 140 "'#{name}' is declared private within library " | |
| 141 "'#{libraryName}'."); | |
| 142 | |
| 143 static const MessageKind THIS_IS_THE_DECLARATION = const MessageKind( | |
| 144 "This is the declaration of '#{name}'."); | |
| 145 | |
| 146 static const MessageKind THIS_IS_THE_METHOD = const MessageKind( | |
| 147 "This is the method declaration."); | |
| 148 | |
| 149 static const MessageKind CANNOT_RESOLVE = const MessageKind( | |
| 150 "Cannot resolve '#{name}'."); | |
| 151 | |
| 152 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind( | |
| 153 "Cannot resolve constructor '#{constructorName}'."); | |
| 154 | |
| 155 static const MessageKind CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = | |
| 156 const MessageKind("cannot resolve constructor '#{constructorName}'" | |
| 157 " for implicit super call.", | |
| 158 howToFix: "Try explicitly invoking a constructor of the super class", | |
| 159 examples: const [""" | |
| 160 class A { | |
| 161 A.foo() {} | |
| 162 } | |
| 163 class B extends A { | |
| 164 B(); | |
| 165 } | |
| 166 main() => new B(); | |
| 167 """]); | |
| 168 | |
| 169 static const MessageKind INVALID_UNNAMED_CONSTRUCTOR_NAME = const MessageKind( | |
| 170 "Unnamed constructor name must be '#{name}'."); | |
| 171 | |
| 172 static const MessageKind INVALID_CONSTRUCTOR_NAME = const MessageKind( | |
| 173 "Constructor name must start with '#{name}'."); | |
| 174 | |
| 175 static const MessageKind CANNOT_RESOLVE_TYPE = const MessageKind( | |
| 176 "Cannot resolve type '#{typeName}'."); | |
| 177 | |
| 178 static const MessageKind DUPLICATE_DEFINITION = const MessageKind( | |
| 179 "Duplicate definition of '#{name}'."); | |
| 180 | |
| 181 static const MessageKind EXISTING_DEFINITION = const MessageKind( | |
| 182 "Existing definition of '#{name}'."); | |
| 183 | |
| 184 static const MessageKind DUPLICATE_IMPORT = const MessageKind( | |
| 185 "Duplicate import of '#{name}'."); | |
| 186 | |
| 187 static const MessageKind HIDDEN_IMPORT = const MessageKind( | |
| 188 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
| 189 "from library '#{hidingUri}'.", | |
| 190 howToFix: "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.", | |
| 191 examples: const [ | |
| 192 const { | |
| 193 'main.dart': | |
| 194 """ | |
| 195 import 'dart:async'; // This imports a class Future. | |
| 196 import 'future.dart'; | |
| 197 | |
| 198 void main() => new Future();""", | |
| 199 | |
| 200 'future.dart': | |
| 201 """ | |
| 202 library future; | |
| 203 | |
| 204 class Future {}"""}, | |
| 205 | |
| 206 const { | |
| 207 'main.dart': | |
| 208 """ | |
| 209 import 'future.dart'; | |
| 210 import 'dart:async'; // This imports a class Future. | |
| 211 | |
| 212 void main() => new Future();""", | |
| 213 | |
| 214 'future.dart': | |
| 215 """ | |
| 216 library future; | |
| 217 | |
| 218 class Future {}"""}, | |
| 219 | |
| 220 const { | |
| 221 'main.dart': | |
| 222 """ | |
| 223 import 'export.dart'; | |
| 224 import 'dart:async'; // This imports a class Future. | |
| 225 | |
| 226 void main() => new Future();""", | |
| 227 | |
| 228 'future.dart': | |
| 229 """ | |
| 230 library future; | |
| 231 | |
| 232 class Future {}""", | |
| 233 | |
| 234 'export.dart': | |
| 235 """ | |
| 236 library export; | |
| 237 | |
| 238 export 'future.dart';"""}, | |
| 239 | |
| 240 const { | |
| 241 'main.dart': | |
| 242 """ | |
| 243 import 'future.dart' as prefix; | |
| 244 import 'dart:async' as prefix; // This imports a class Future. | |
| 245 | |
| 246 void main() => new prefix.Future();""", | |
| 247 | |
| 248 'future.dart': | |
| 249 """ | |
| 250 library future; | |
| 251 | |
| 252 class Future {}"""}]); | |
| 253 | |
| 254 | |
| 255 static const MessageKind HIDDEN_IMPLICIT_IMPORT = const MessageKind( | |
| 256 "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
| 257 "from library '#{hidingUri}'.", | |
| 258 howToFix: "Try adding an explicit " | |
| 259 "'import \"#{hiddenUri}\" hide #{name}'.", | |
| 260 examples: const [ | |
| 261 const { | |
| 262 'main.dart': | |
| 263 """ | |
| 264 // This hides the implicit import of class Type from dart:core. | |
| 265 import 'type.dart'; | |
| 266 | |
| 267 void main() => new Type();""", | |
| 268 | |
| 269 'type.dart': | |
| 270 """ | |
| 271 library type; | |
| 272 | |
| 273 class Type {}"""}, | |
| 274 const { | |
| 275 'conflictsWithDart.dart': | |
| 276 """ | |
| 277 library conflictsWithDart; | |
| 278 | |
| 279 class Duration { | |
| 280 static var x = 100; | |
| 281 } | |
| 282 """, | |
| 283 | |
| 284 'conflictsWithDartAsWell.dart': | |
| 285 """ | |
| 286 library conflictsWithDartAsWell; | |
| 287 | |
| 288 class Duration { | |
| 289 static var x = 100; | |
| 290 } | |
| 291 """, | |
| 292 | |
| 293 'main.dart': | |
| 294 r""" | |
| 295 library testDartConflicts; | |
| 296 | |
| 297 import 'conflictsWithDart.dart'; | |
| 298 import 'conflictsWithDartAsWell.dart'; | |
| 299 | |
| 300 main() { | |
| 301 print("Hail Caesar ${Duration.x}"); | |
| 302 } | |
| 303 """}]); | |
| 304 | |
| 305 static const MessageKind DUPLICATE_EXPORT = const MessageKind( | |
| 306 "Duplicate export of '#{name}'.", | |
| 307 howToFix: "Trying adding 'hide #{name}' to one of the exports.", | |
| 308 examples: const [const { | |
| 309 'main.dart': """ | |
| 310 export 'decl1.dart'; | |
| 311 export 'decl2.dart'; | |
| 312 | |
| 313 main() {}""", | |
| 314 'decl1.dart': "class Class {}", | |
| 315 'decl2.dart': "class Class {}"}]); | |
| 316 | |
| 317 static const MessageKind DUPLICATE_EXPORT_CONT = const MessageKind( | |
| 318 "This is another export of '#{name}'."); | |
| 319 | |
| 320 static const MessageKind DUPLICATE_EXPORT_DECL = const MessageKind( | |
| 321 "The exported '#{name}' from export #{uriString} is defined here."); | |
| 322 | |
| 323 static const MessageKind NOT_A_TYPE = const MessageKind( | |
| 324 "'#{node}' is not a type."); | |
| 325 | |
| 326 static const MessageKind NOT_A_PREFIX = const MessageKind( | |
| 327 "'#{node}' is not a prefix."); | |
| 328 | |
| 329 static const MessageKind CANNOT_FIND_CONSTRUCTOR = const MessageKind( | |
| 330 "Cannot find constructor '#{constructorName}'."); | |
| 331 | |
| 332 static const MessageKind CYCLIC_CLASS_HIERARCHY = const MessageKind( | |
| 333 "'#{className}' creates a cycle in the class hierarchy."); | |
| 334 | |
| 335 static const MessageKind CYCLIC_REDIRECTING_FACTORY = const MessageKind( | |
| 336 'Redirecting factory leads to a cyclic redirection.'); | |
| 337 | |
| 338 static const MessageKind INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( | |
| 339 "Field initializer expected."); | |
| 340 | |
| 341 static const MessageKind NO_SUPER_IN_STATIC = const MessageKind( | |
| 342 "'super' is only available in instance methods."); | |
| 343 | |
| 344 static const MessageKind DUPLICATE_INITIALIZER = const MessageKind( | |
| 345 "Field '#{fieldName}' is initialized more than once."); | |
| 346 | |
| 347 static const MessageKind ALREADY_INITIALIZED = const MessageKind( | |
| 348 "'#{fieldName}' was already initialized here."); | |
| 349 | |
| 350 static const MessageKind INIT_STATIC_FIELD = const MessageKind( | |
| 351 "Cannot initialize static field '#{fieldName}'."); | |
| 352 | |
| 353 static const MessageKind NOT_A_FIELD = const MessageKind( | |
| 354 "'#{fieldName}' is not a field."); | |
| 355 | |
| 356 static const MessageKind CONSTRUCTOR_CALL_EXPECTED = const MessageKind( | |
| 357 "only call to 'this' or 'super' constructor allowed."); | |
| 358 | |
| 359 static const MessageKind INVALID_FOR_IN = const MessageKind( | |
| 360 "Invalid for-in variable declaration."); | |
| 361 | |
| 362 static const MessageKind INVALID_INITIALIZER = const MessageKind( | |
| 363 "Invalid initializer."); | |
| 364 | |
| 365 static const MessageKind FUNCTION_WITH_INITIALIZER = const MessageKind( | |
| 366 "Only constructors can have initializers."); | |
| 367 | |
| 368 static const MessageKind REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( | |
| 369 "Cyclic constructor redirection."); | |
| 370 | |
| 371 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( | |
| 372 "Redirecting constructor can't have a body."); | |
| 373 | |
| 374 static const MessageKind CONST_CONSTRUCTOR_HAS_BODY = const MessageKind( | |
| 375 "Const constructor or factory can't have a body.", | |
| 376 howToFix: "Remove the 'const' keyword or the body", | |
| 377 examples: const [""" | |
| 378 class C { | |
| 379 const C() {} | |
| 380 } | |
| 381 | |
| 382 main() => new C();"""]); | |
| 383 | |
| 384 static const MessageKind REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = | |
| 385 const MessageKind( | |
| 386 "Redirecting constructor cannot have other initializers."); | |
| 387 | |
| 388 static const MessageKind SUPER_INITIALIZER_IN_OBJECT = const MessageKind( | |
| 389 "'Object' cannot have a super initializer."); | |
| 390 | |
| 391 static const MessageKind DUPLICATE_SUPER_INITIALIZER = const MessageKind( | |
| 392 "Cannot have more than one super initializer."); | |
| 393 | |
| 394 static const MessageKind INVALID_CONSTRUCTOR_ARGUMENTS = const MessageKind( | |
| 395 "Arguments do not match the expected parameters of constructor " | |
| 396 "'#{constructorName}'."); | |
| 397 | |
| 398 static const MessageKind NO_MATCHING_CONSTRUCTOR = const MessageKind( | |
| 399 "'super' call arguments and constructor parameters do not match."); | |
| 400 | |
| 401 static const MessageKind NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = | |
| 402 const MessageKind( | |
| 403 "Implicit 'super' call arguments and constructor parameters " | |
| 404 "do not match."); | |
| 405 | |
| 406 static const MessageKind CONST_CALLS_NON_CONST = const MessageKind( | |
| 407 "'const' constructor cannot call a non-const constructor."); | |
| 408 | |
| 409 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS = | |
| 410 const MessageKind( | |
| 411 "Can't declare constructor 'const' on class #{className} " | |
| 412 "because the class contains non-final instance fields.", | |
| 413 howToFix: "Try making all fields final.", | |
| 414 examples: const [""" | |
| 415 class C { | |
| 416 // 'a' must be declared final to allow for the const constructor. | |
| 417 var a; | |
| 418 const C(this.a); | |
| 419 } | |
| 420 | |
| 421 main() => new C(0);"""]); | |
| 422 | |
| 423 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD = | |
| 424 const MessageKind("This non-final field prevents using const " | |
| 425 "constructors."); | |
| 426 | |
| 427 static const MessageKind CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR = | |
| 428 const MessageKind("This const constructor is not allowed due to " | |
| 429 "non-final fields."); | |
| 430 | |
| 431 | |
| 432 static const MessageKind INITIALIZING_FORMAL_NOT_ALLOWED = const MessageKind( | |
| 433 "Initializing formal parameter only allowed in generative " | |
| 434 "constructor."); | |
| 435 | |
| 436 static const MessageKind INVALID_PARAMETER = const MessageKind( | |
| 437 "Cannot resolve parameter."); | |
| 438 | |
| 439 static const MessageKind NOT_INSTANCE_FIELD = const MessageKind( | |
| 440 "'#{fieldName}' is not an instance field."); | |
| 441 | |
| 442 static const MessageKind NO_CATCH_NOR_FINALLY = const MessageKind( | |
| 443 "Expected 'catch' or 'finally'."); | |
| 444 | |
| 445 static const MessageKind EMPTY_CATCH_DECLARATION = const MessageKind( | |
| 446 "Expected an identifier in catch declaration."); | |
| 447 | |
| 448 static const MessageKind EXTRA_CATCH_DECLARATION = const MessageKind( | |
| 449 "Extra parameter in catch declaration."); | |
| 450 | |
| 451 static const MessageKind PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind( | |
| 452 "Cannot use type annotations in catch."); | |
| 453 | |
| 454 static const MessageKind PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind( | |
| 455 "Cannot use modifiers in catch."); | |
| 456 | |
| 457 static const MessageKind OPTIONAL_PARAMETER_IN_CATCH = const MessageKind( | |
| 458 "Cannot use optional parameters in catch."); | |
| 459 | |
| 460 static const MessageKind THROW_WITHOUT_EXPRESSION = const MessageKind( | |
| 461 "Cannot use re-throw outside of catch block " | |
| 462 "(expression expected after 'throw')."); | |
| 463 | |
| 464 static const MessageKind UNBOUND_LABEL = const MessageKind( | |
| 465 "Cannot resolve label '#{labelName}'."); | |
| 466 | |
| 467 static const MessageKind NO_BREAK_TARGET = const MessageKind( | |
| 468 "'break' statement not inside switch or loop."); | |
| 469 | |
| 470 static const MessageKind NO_CONTINUE_TARGET = const MessageKind( | |
| 471 "'continue' statement not inside loop."); | |
| 472 | |
| 473 static const MessageKind EXISTING_LABEL = const MessageKind( | |
| 474 "Original declaration of duplicate label '#{labelName}'."); | |
| 475 | |
| 476 static const MessageKind DUPLICATE_LABEL = const MessageKind( | |
| 477 "Duplicate declaration of label '#{labelName}'."); | |
| 478 | |
| 479 static const MessageKind UNUSED_LABEL = const MessageKind( | |
| 480 "Unused label '#{labelName}'."); | |
| 481 | |
| 482 static const MessageKind INVALID_CONTINUE = const MessageKind( | |
| 483 "Target of continue is not a loop or switch case."); | |
| 484 | |
| 485 static const MessageKind INVALID_BREAK = const MessageKind( | |
| 486 "Target of break is not a statement."); | |
| 487 | |
| 488 static const MessageKind DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind( | |
| 489 "Type variable '#{typeVariableName}' already declared."); | |
| 490 | |
| 491 static const MessageKind TYPE_VARIABLE_WITHIN_STATIC_MEMBER = | |
| 492 const MessageKind( | |
| 493 "Cannot refer to type variable '#{typeVariableName}' " | |
| 494 "within a static member."); | |
| 495 | |
| 496 static const MessageKind TYPE_VARIABLE_IN_CONSTANT = const MessageKind( | |
| 497 "Constant expressions can't refer to type variables.", | |
| 498 howToFix: "Try removing the type variable or replacing it with a " | |
| 499 "concrete type.", | |
| 500 examples: const [""" | |
| 501 class C<T> { | |
| 502 const C(); | |
| 503 | |
| 504 m(T t) => const C<T>(); | |
| 505 } | |
| 506 | |
| 507 void main() => new C().m(null); | |
| 508 """ | |
| 509 ]); | |
| 510 | |
| 511 | |
| 512 static const MessageKind INVALID_TYPE_VARIABLE_BOUND = const MessageKind( | |
| 513 "'#{typeArgument}' is not a subtype of bound '#{bound}' for " | |
| 514 "type variable '#{typeVariable}' of type '#{thisType}'.", | |
| 515 howToFix: "Try to change or remove the type argument.", | |
| 516 examples: const [""" | |
| 517 class C<T extends num> {} | |
| 518 | |
| 519 // 'String' is not a valid instantiation of T with bound num.'. | |
| 520 main() => new C<String>(); | |
| 521 """]); | |
| 522 | |
| 523 static const MessageKind INVALID_USE_OF_SUPER = const MessageKind( | |
| 524 "'super' not allowed here."); | |
| 525 | |
| 526 static const MessageKind INVALID_CASE_DEFAULT = const MessageKind( | |
| 527 "'default' only allowed on last case of a switch."); | |
| 528 | |
| 529 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind( | |
| 530 "'case' expressions do not all have type '#{type}'."); | |
| 531 | |
| 532 static const MessageKind SWITCH_CASE_TYPES_NOT_EQUAL_CASE = const MessageKind( | |
| 533 "'case' expression of type '#{type}'."); | |
| 534 | |
| 535 static const MessageKind SWITCH_CASE_FORBIDDEN = const MessageKind( | |
| 536 "'case' expression may not be of type '#{type}'."); | |
| 537 | |
| 538 static const MessageKind SWITCH_CASE_VALUE_OVERRIDES_EQUALS = | |
| 539 const MessageKind( | |
| 540 "'case' expression type '#{type}' overrides 'operator =='."); | |
| 541 | |
| 542 static const MessageKind INVALID_ARGUMENT_AFTER_NAMED = const MessageKind( | |
| 543 "Unnamed argument after named argument."); | |
| 544 | |
| 545 static const MessageKind NOT_A_COMPILE_TIME_CONSTANT = const MessageKind( | |
| 546 "Not a compile-time constant."); | |
| 547 | |
| 548 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT = const MessageKind( | |
| 549 "A Deferred value cannot be used as a compile-time constant."); | |
| 550 | |
| 551 static const MessageKind DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION = | |
| 552 const MessageKind("A deferred class cannot be used to create a" | |
| 553 "compile-time constant."); | |
| 554 | |
| 555 static const MessageKind CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind( | |
| 556 "Cycle in the compile-time constant computation."); | |
| 557 | |
| 558 static const MessageKind CONSTRUCTOR_IS_NOT_CONST = const MessageKind( | |
| 559 "Constructor is not a 'const' constructor."); | |
| 560 | |
| 561 static const MessageKind CONST_MAP_KEY_OVERRIDES_EQUALS = | |
| 562 const MessageKind( | |
| 563 "Const-map key type '#{type}' overrides 'operator =='."); | |
| 564 | |
| 565 static const MessageKind NO_SUCH_LIBRARY_MEMBER = const MessageKind( | |
| 566 "'#{libraryName}' has no member named '#{memberName}'."); | |
| 567 | |
| 568 static const MessageKind CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( | |
| 569 "Cannot instantiate typedef '#{typedefName}'."); | |
| 570 | |
| 571 static const MessageKind REQUIRED_PARAMETER_WITH_DEFAULT = const MessageKind( | |
| 572 "Non-optional parameters can't have a default value.", | |
| 573 howToFix: | |
| 574 "Try removing the default value or making the parameter optional.", | |
| 575 examples: const [""" | |
| 576 main() { | |
| 577 foo(a: 1) => print(a); | |
| 578 foo(2); | |
| 579 }""", """ | |
| 580 main() { | |
| 581 foo(a = 1) => print(a); | |
| 582 foo(2); | |
| 583 }"""]); | |
| 584 | |
| 585 static const MessageKind NAMED_PARAMETER_WITH_EQUALS = const MessageKind( | |
| 586 "Named optional parameters can't use '=' to specify a default " | |
| 587 "value.", | |
| 588 howToFix: "Try replacing '=' with ':'.", | |
| 589 examples: const [""" | |
| 590 main() { | |
| 591 foo({a = 1}) => print(a); | |
| 592 foo(a: 2); | |
| 593 }"""]); | |
| 594 | |
| 595 static const MessageKind POSITIONAL_PARAMETER_WITH_EQUALS = const MessageKind( | |
| 596 "Positional optional parameters can't use ':' to specify a " | |
| 597 "default value.", | |
| 598 howToFix: "Try replacing ':' with '='.", | |
| 599 examples: const [""" | |
| 600 main() { | |
| 601 foo([a: 1]) => print(a); | |
| 602 foo(2); | |
| 603 }"""]); | |
| 604 | |
| 605 static const MessageKind TYPEDEF_FORMAL_WITH_DEFAULT = const MessageKind( | |
| 606 "A parameter of a typedef can't specify a default value.", | |
| 607 howToFix: | |
| 608 "Try removing the default value.", | |
| 609 examples: const [""" | |
| 610 typedef void F([int arg = 0]); | |
| 611 | |
| 612 main() { | |
| 613 F f; | |
| 614 }""", """ | |
| 615 typedef void F({int arg: 0}); | |
| 616 | |
| 617 main() { | |
| 618 F f; | |
| 619 }"""]); | |
| 620 | |
| 621 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind
( | |
| 622 "A function type parameter can't specify a default value.", | |
| 623 howToFix: | |
| 624 "Try removing the default value.", | |
| 625 examples: const [""" | |
| 626 foo(f(int i, [a = 1])) {} | |
| 627 | |
| 628 main() { | |
| 629 foo(1, 2); | |
| 630 }""", """ | |
| 631 foo(f(int i, {a: 1})) {} | |
| 632 | |
| 633 main() { | |
| 634 foo(1, a: 2); | |
| 635 }"""]); | |
| 636 | |
| 637 static const MessageKind REDIRECTING_FACTORY_WITH_DEFAULT = const MessageKind( | |
| 638 "A parameter of a redirecting factory constructor can't specify a " | |
| 639 "default value.", | |
| 640 howToFix: | |
| 641 "Try removing the default value.", | |
| 642 examples: const [""" | |
| 643 class A { | |
| 644 A([a]); | |
| 645 factory A.foo([a = 1]) = A; | |
| 646 } | |
| 647 | |
| 648 main() { | |
| 649 new A.foo(1); | |
| 650 }""", """ | |
| 651 class A { | |
| 652 A({a}); | |
| 653 factory A.foo({a: 1}) = A; | |
| 654 } | |
| 655 | |
| 656 main() { | |
| 657 new A.foo(a: 1); | |
| 658 }"""]); | |
| 659 | |
| 660 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind( | |
| 661 "A formal parameter can't be declared const.", | |
| 662 howToFix: "Try removing 'const'.", | |
| 663 examples: const [""" | |
| 664 foo(const x) {} | |
| 665 main() => foo(42); | |
| 666 """, """ | |
| 667 foo({const x}) {} | |
| 668 main() => foo(42); | |
| 669 """, """ | |
| 670 foo([const x]) {} | |
| 671 main() => foo(42); | |
| 672 """]); | |
| 673 | |
| 674 static const MessageKind FORMAL_DECLARED_STATIC = const MessageKind( | |
| 675 "A formal parameter can't be declared static.", | |
| 676 howToFix: "Try removing 'static'.", | |
| 677 examples: const [""" | |
| 678 foo(static x) {} | |
| 679 main() => foo(42); | |
| 680 """, """ | |
| 681 foo({static x}) {} | |
| 682 main() => foo(42); | |
| 683 """, """ | |
| 684 foo([static x]) {} | |
| 685 main() => foo(42); | |
| 686 """]); | |
| 687 | |
| 688 static const MessageKind FINAL_FUNCTION_TYPE_PARAMETER = const MessageKind( | |
| 689 "A function type parameter can't be declared final.", | |
| 690 howToFix: "Try removing 'final'.", | |
| 691 examples: const [""" | |
| 692 foo(final int x(int a)) {} | |
| 693 main() => foo((y) => 42); | |
| 694 """, """ | |
| 695 foo({final int x(int a)}) {} | |
| 696 main() => foo((y) => 42); | |
| 697 """, """ | |
| 698 foo([final int x(int a)]) {} | |
| 699 main() => foo((y) => 42); | |
| 700 """]); | |
| 701 | |
| 702 static const MessageKind VAR_FUNCTION_TYPE_PARAMETER = const MessageKind( | |
| 703 "A function type parameter can't be declared with 'var'.", | |
| 704 howToFix: "Try removing 'var'.", | |
| 705 examples: const [""" | |
| 706 foo(var int x(int a)) {} | |
| 707 main() => foo((y) => 42); | |
| 708 """, """ | |
| 709 foo({var int x(int a)}) {} | |
| 710 main() => foo((y) => 42); | |
| 711 """, """ | |
| 712 foo([var int x(int a)]) {} | |
| 713 main() => foo((y) => 42); | |
| 714 """]); | |
| 715 | |
| 716 static const MessageKind CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind( | |
| 717 "Cannot instantiate type variable '#{typeVariableName}'."); | |
| 718 | |
| 719 static const MessageKind CYCLIC_TYPE_VARIABLE = const MessageKind( | |
| 720 "Type variable '#{typeVariableName}' is a supertype of itself."); | |
| 721 | |
| 722 static const CYCLIC_TYPEDEF = const MessageKind( | |
| 723 "A typedef can't refer to itself.", | |
| 724 howToFix: "Try removing all references to '#{typedefName}' " | |
| 725 "in the definition of '#{typedefName}'.", | |
| 726 examples: const [""" | |
| 727 typedef F F(); // The return type 'F' is a self-reference. | |
| 728 main() { F f = null; }"""]); | |
| 729 | |
| 730 static const CYCLIC_TYPEDEF_ONE = const MessageKind( | |
| 731 "A typedef can't refer to itself through another typedef.", | |
| 732 howToFix: "Try removing all references to " | |
| 733 "'#{otherTypedefName}' in the definition of '#{typedefName}'.", | |
| 734 examples: const [""" | |
| 735 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'. | |
| 736 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'. | |
| 737 main() { F f = null; }""", | |
| 738 """ | |
| 739 typedef G F(); // The return type 'G' creates a self-reference. | |
| 740 typedef H G(); // The return type 'H' creates a self-reference. | |
| 741 typedef H(F f); // The argument type 'F' creates a self-reference. | |
| 742 main() { F f = null; }"""]); | |
| 743 | |
| 744 static const MessageKind CLASS_NAME_EXPECTED = const MessageKind( | |
| 745 "Class name expected."); | |
| 746 | |
| 747 static const MessageKind CANNOT_EXTEND = const MessageKind( | |
| 748 "'#{type}' cannot be extended."); | |
| 749 | |
| 750 static const MessageKind CANNOT_IMPLEMENT = const MessageKind( | |
| 751 "'#{type}' cannot be implemented."); | |
| 752 | |
| 753 // TODO(johnnwinther): Split messages into reasons for malformedness. | |
| 754 static const MessageKind CANNOT_EXTEND_MALFORMED = const MessageKind( | |
| 755 "Class '#{className}' can't extend the type '#{malformedType}' because " | |
| 756 "it is malformed.", | |
| 757 howToFix: "Try correcting the malformed type annotation or removing the " | |
| 758 "'extends' clause.", | |
| 759 examples: const [""" | |
| 760 class A extends Malformed {} | |
| 761 main() => new A();"""]); | |
| 762 | |
| 763 static const MessageKind CANNOT_IMPLEMENT_MALFORMED = const MessageKind( | |
| 764 "Class '#{className}' can't implement the type '#{malformedType}' " | |
| 765 "because it is malformed.", | |
| 766 howToFix: "Try correcting the malformed type annotation or removing the " | |
| 767 "type from the 'implements' clause.", | |
| 768 examples: const [""" | |
| 769 class A implements Malformed {} | |
| 770 main() => new A();"""]); | |
| 771 | |
| 772 static const MessageKind CANNOT_MIXIN_MALFORMED = const MessageKind( | |
| 773 "Class '#{className}' can't mixin the type '#{malformedType}' because it " | |
| 774 "is malformed.", | |
| 775 howToFix: "Try correcting the malformed type annotation or removing the " | |
| 776 "type from the 'with' clause.", | |
| 777 examples: const [""" | |
| 778 class A extends Object with Malformed {} | |
| 779 main() => new A();"""]); | |
| 780 | |
| 781 static const MessageKind CANNOT_MIXIN = const MessageKind( | |
| 782 "The type '#{type}' can't be mixed in.", | |
| 783 howToFix: "Try removing '#{type}' from the 'with' clause.", | |
| 784 examples: const [""" | |
| 785 class C extends Object with String {} | |
| 786 | |
| 787 main() => new C(); | |
| 788 """, """ | |
| 789 typedef C = Object with String; | |
| 790 | |
| 791 main() => new C(); | |
| 792 """]); | |
| 793 | |
| 794 static const MessageKind DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( | |
| 795 "'#{type}' can not be both extended and implemented."); | |
| 796 | |
| 797 static const MessageKind DUPLICATE_IMPLEMENTS = const MessageKind( | |
| 798 "'#{type}' must not occur more than once " | |
| 799 "in the implements clause."); | |
| 800 | |
| 801 static const MessageKind MULTI_INHERITANCE = const MessageKind( | |
| 802 "Dart2js does not currently support inheritance of the same class with " | |
| 803 "different type arguments: Both #{firstType} and #{secondType} are " | |
| 804 "supertypes of #{thisType}."); | |
| 805 | |
| 806 static const MessageKind ILLEGAL_SUPER_SEND = const MessageKind( | |
| 807 "'#{name}' cannot be called on super."); | |
| 808 | |
| 809 static const MessageKind NO_SUCH_SUPER_MEMBER = const MessageKind( | |
| 810 "Cannot resolve '#{memberName}' in a superclass of '#{className}'."); | |
| 811 | |
| 812 static const MessageKind ADDITIONAL_TYPE_ARGUMENT = const MessageKind( | |
| 813 "Additional type argument."); | |
| 814 | |
| 815 static const MessageKind MISSING_TYPE_ARGUMENT = const MessageKind( | |
| 816 "Missing type argument."); | |
| 817 | |
| 818 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT | |
| 819 // instead. | |
| 820 static const MessageKind TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind( | |
| 821 "Incorrect number of type arguments on '#{type}'."); | |
| 822 | |
| 823 static const MessageKind GETTER_MISMATCH = const MessageKind( | |
| 824 "Setter disagrees on: '#{modifiers}'."); | |
| 825 | |
| 826 static const MessageKind SETTER_MISMATCH = const MessageKind( | |
| 827 "Getter disagrees on: '#{modifiers}'."); | |
| 828 | |
| 829 static const MessageKind ILLEGAL_SETTER_FORMALS = const MessageKind( | |
| 830 "A setter must have exactly one argument."); | |
| 831 | |
| 832 static const MessageKind NO_STATIC_OVERRIDE = const MessageKind( | |
| 833 "Static member cannot override instance member '#{memberName}' of " | |
| 834 "'#{className}'."); | |
| 835 | |
| 836 static const MessageKind NO_STATIC_OVERRIDE_CONT = const MessageKind( | |
| 837 "This is the instance member that cannot be overridden " | |
| 838 "by a static member."); | |
| 839 | |
| 840 static const MessageKind INSTANCE_STATIC_SAME_NAME = const MessageKind( | |
| 841 "Instance member '#{memberName}' and static member of " | |
| 842 "superclass '#{className}' have the same name."); | |
| 843 | |
| 844 static const MessageKind INSTANCE_STATIC_SAME_NAME_CONT = const MessageKind( | |
| 845 "This is the static member with the same name."); | |
| 846 | |
| 847 static const MessageKind INVALID_OVERRIDE_METHOD = const MessageKind( | |
| 848 "The type '#{declaredType}' of method '#{name}' declared in " | |
| 849 "'#{class}' is not a subtype of the overridden method type " | |
| 850 "'#{inheritedType}' inherited from '#{inheritedClass}'."); | |
| 851 | |
| 852 static const MessageKind INVALID_OVERRIDDEN_METHOD = const MessageKind( | |
| 853 "This is the overridden method '#{name}' declared in class " | |
| 854 "'#{class}'."); | |
| 855 | |
| 856 static const MessageKind INVALID_OVERRIDE_GETTER = const MessageKind( | |
| 857 "The type '#{declaredType}' of getter '#{name}' declared in " | |
| 858 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 859 "overridden getter inherited from '#{inheritedClass}'."); | |
| 860 | |
| 861 static const MessageKind INVALID_OVERRIDDEN_GETTER = const MessageKind( | |
| 862 "This is the overridden getter '#{name}' declared in class " | |
| 863 "'#{class}'."); | |
| 864 | |
| 865 static const MessageKind INVALID_OVERRIDE_GETTER_WITH_FIELD = | |
| 866 const MessageKind( | |
| 867 "The type '#{declaredType}' of field '#{name}' declared in " | |
| 868 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 869 "overridden getter inherited from '#{inheritedClass}'."); | |
| 870 | |
| 871 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_GETTER = | |
| 872 const MessageKind( | |
| 873 "The type '#{declaredType}' of getter '#{name}' declared in " | |
| 874 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 875 "overridden field inherited from '#{inheritedClass}'."); | |
| 876 | |
| 877 static const MessageKind INVALID_OVERRIDE_SETTER = const MessageKind( | |
| 878 "The type '#{declaredType}' of setter '#{name}' declared in " | |
| 879 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 880 "overridden setter inherited from '#{inheritedClass}'."); | |
| 881 | |
| 882 static const MessageKind INVALID_OVERRIDDEN_SETTER = const MessageKind( | |
| 883 "This is the overridden setter '#{name}' declared in class " | |
| 884 "'#{class}'."); | |
| 885 | |
| 886 static const MessageKind INVALID_OVERRIDE_SETTER_WITH_FIELD = | |
| 887 const MessageKind( | |
| 888 "The type '#{declaredType}' of field '#{name}' declared in " | |
| 889 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 890 "overridden setter inherited from '#{inheritedClass}'."); | |
| 891 | |
| 892 static const MessageKind INVALID_OVERRIDE_FIELD_WITH_SETTER = | |
| 893 const MessageKind( | |
| 894 "The type '#{declaredType}' of setter '#{name}' declared in " | |
| 895 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 896 "overridden field inherited from '#{inheritedClass}'."); | |
| 897 | |
| 898 static const MessageKind INVALID_OVERRIDE_FIELD = const MessageKind( | |
| 899 "The type '#{declaredType}' of field '#{name}' declared in " | |
| 900 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 901 "overridden field inherited from '#{inheritedClass}'."); | |
| 902 | |
| 903 static const MessageKind INVALID_OVERRIDDEN_FIELD = const MessageKind( | |
| 904 "This is the overridden field '#{name}' declared in class " | |
| 905 "'#{class}'."); | |
| 906 | |
| 907 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD = | |
| 908 const MessageKind( | |
| 909 "Method '#{name}' in '#{class}' can't override field from " | |
| 910 "'#{inheritedClass}'."); | |
| 911 | |
| 912 static const MessageKind CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = | |
| 913 const MessageKind( | |
| 914 "This is the field that cannot be overridden by a method."); | |
| 915 | |
| 916 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD = | |
| 917 const MessageKind( | |
| 918 "Field '#{name}' in '#{class}' can't override method from " | |
| 919 "'#{inheritedClass}'."); | |
| 920 | |
| 921 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = | |
| 922 const MessageKind( | |
| 923 "This is the method that cannot be overridden by a field."); | |
| 924 | |
| 925 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD = | |
| 926 const MessageKind( | |
| 927 "Method '#{name}' in '#{class}' can't override getter from " | |
| 928 "'#{inheritedClass}'."); | |
| 929 | |
| 930 static const MessageKind CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT = | |
| 931 const MessageKind( | |
| 932 "This is the getter that cannot be overridden by a method."); | |
| 933 | |
| 934 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER = | |
| 935 const MessageKind( | |
| 936 "Getter '#{name}' in '#{class}' can't override method from " | |
| 937 "'#{inheritedClass}'."); | |
| 938 | |
| 939 static const MessageKind CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT = | |
| 940 const MessageKind( | |
| 941 "This is the method that cannot be overridden by a getter."); | |
| 942 | |
| 943 static const MessageKind MISSING_FORMALS = const MessageKind( | |
| 944 "Formal parameters are missing."); | |
| 945 | |
| 946 static const MessageKind EXTRA_FORMALS = const MessageKind( | |
| 947 "Formal parameters are not allowed here."); | |
| 948 | |
| 949 static const MessageKind UNARY_OPERATOR_BAD_ARITY = const MessageKind( | |
| 950 "Operator '#{operatorName}' must have no parameters."); | |
| 951 | |
| 952 static const MessageKind MINUS_OPERATOR_BAD_ARITY = const MessageKind( | |
| 953 "Operator '-' must have 0 or 1 parameters."); | |
| 954 | |
| 955 static const MessageKind BINARY_OPERATOR_BAD_ARITY = const MessageKind( | |
| 956 "Operator '#{operatorName}' must have exactly 1 parameter."); | |
| 957 | |
| 958 static const MessageKind TERNARY_OPERATOR_BAD_ARITY = const MessageKind( | |
| 959 "Operator '#{operatorName}' must have exactly 2 parameters."); | |
| 960 | |
| 961 static const MessageKind OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( | |
| 962 "Operator '#{operatorName}' cannot have optional parameters."); | |
| 963 | |
| 964 static const MessageKind OPERATOR_NAMED_PARAMETERS = const MessageKind( | |
| 965 "Operator '#{operatorName}' cannot have named parameters."); | |
| 966 | |
| 967 static const MessageKind CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( | |
| 968 "Cannot have return type for constructor."); | |
| 969 | |
| 970 static const MessageKind CANNOT_RETURN_FROM_CONSTRUCTOR = const MessageKind( | |
| 971 "Constructors can't return values.", | |
| 972 howToFix: "Remove the return statement or use a factory constructor.", | |
| 973 examples: const [""" | |
| 974 class C { | |
| 975 C() { | |
| 976 return 1; | |
| 977 } | |
| 978 } | |
| 979 | |
| 980 main() => new C();"""]); | |
| 981 | |
| 982 static const MessageKind ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( | |
| 983 "Cannot have final modifier on method."); | |
| 984 | |
| 985 static const MessageKind ILLEGAL_CONST_FIELD_MODIFIER = const MessageKind( | |
| 986 "Cannot have const modifier on non-static field.", | |
| 987 howToFix: "Try adding a static modifier, or removing the const modifier.", | |
| 988 examples: const [""" | |
| 989 class C { | |
| 990 const int a = 1; | |
| 991 } | |
| 992 | |
| 993 main() => new C();"""]); | |
| 994 | |
| 995 static const MessageKind ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( | |
| 996 "Illegal constructor modifiers: '#{modifiers}'."); | |
| 997 | |
| 998 static const MessageKind ILLEGAL_MIXIN_APPLICATION_MODIFIERS = | |
| 999 const MessageKind( | |
| 1000 "Illegal mixin application modifiers: '#{modifiers}'."); | |
| 1001 | |
| 1002 static const MessageKind ILLEGAL_MIXIN_SUPERCLASS = const MessageKind( | |
| 1003 "Class used as mixin must have Object as superclass."); | |
| 1004 | |
| 1005 static const MessageKind ILLEGAL_MIXIN_OBJECT = const MessageKind( | |
| 1006 "Cannot use Object as mixin."); | |
| 1007 | |
| 1008 static const MessageKind ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind( | |
| 1009 "Class used as mixin cannot have non-factory constructor."); | |
| 1010 | |
| 1011 static const MessageKind ILLEGAL_MIXIN_CYCLE = const MessageKind( | |
| 1012 "Class used as mixin introduces mixin cycle: " | |
| 1013 "'#{mixinName1}' <-> '#{mixinName2}'."); | |
| 1014 | |
| 1015 static const MessageKind ILLEGAL_MIXIN_WITH_SUPER = const MessageKind( | |
| 1016 "Cannot use class '#{className}' as a mixin because it uses " | |
| 1017 "'super'."); | |
| 1018 | |
| 1019 static const MessageKind ILLEGAL_MIXIN_SUPER_USE = const MessageKind( | |
| 1020 "Use of 'super' in class used as mixin."); | |
| 1021 | |
| 1022 static const MessageKind PARAMETER_NAME_EXPECTED = const MessageKind( | |
| 1023 "parameter name expected."); | |
| 1024 | |
| 1025 static const MessageKind CANNOT_RESOLVE_GETTER = const MessageKind( | |
| 1026 "Cannot resolve getter."); | |
| 1027 | |
| 1028 static const MessageKind CANNOT_RESOLVE_SETTER = const MessageKind( | |
| 1029 "Cannot resolve setter."); | |
| 1030 | |
| 1031 static const MessageKind ASSIGNING_METHOD = const MessageKind( | |
| 1032 "Cannot assign a value to a method."); | |
| 1033 | |
| 1034 static const MessageKind ASSIGNING_TYPE = const MessageKind( | |
| 1035 "Cannot assign a value to a type."); | |
| 1036 | |
| 1037 static const MessageKind VOID_NOT_ALLOWED = const MessageKind( | |
| 1038 "Type 'void' can't be used here because it isn't a return type.", | |
| 1039 howToFix: "Try removing 'void' keyword or replace it with 'var', 'final'," | |
| 1040 " or a type.", | |
| 1041 examples: const [ | |
| 1042 "void x; main() {}", | |
| 1043 "foo(void x) {} main() { foo(null); }", | |
| 1044 ]); | |
| 1045 | |
| 1046 static const MessageKind NULL_NOT_ALLOWED = const MessageKind( | |
| 1047 "`null` can't be used here."); | |
| 1048 | |
| 1049 static const MessageKind BEFORE_TOP_LEVEL = const MessageKind( | |
| 1050 "Part header must come before top-level definitions."); | |
| 1051 | |
| 1052 static const MessageKind LIBRARY_NAME_MISMATCH = const MessageKind( | |
| 1053 "Expected part of library name '#{libraryName}'.", | |
| 1054 howToFix: "Trying changing the directive to 'part of #{libraryName};'.", | |
| 1055 examples: const [const { | |
| 1056 'main.dart': """ | |
| 1057 library lib.foo; | |
| 1058 | |
| 1059 part 'part.dart'; | |
| 1060 | |
| 1061 main() {} | |
| 1062 """, | |
| 1063 | |
| 1064 'part.dart': """ | |
| 1065 part of lib.bar; | |
| 1066 """}]); | |
| 1067 | |
| 1068 static const MessageKind MISSING_LIBRARY_NAME = const MessageKind( | |
| 1069 "Library has no name. Part directive expected library name " | |
| 1070 "to be '#{libraryName}'.", | |
| 1071 howToFix: "Trying adding 'library #{libraryName};' to the library.", | |
| 1072 examples: const [const { | |
| 1073 'main.dart': """ | |
| 1074 part 'part.dart'; | |
| 1075 | |
| 1076 main() {} | |
| 1077 """, | |
| 1078 | |
| 1079 'part.dart': """ | |
| 1080 part of lib.foo; | |
| 1081 """}]); | |
| 1082 | |
| 1083 static const MessageKind THIS_IS_THE_PART_OF_TAG = const MessageKind( | |
| 1084 "This is the part of directive."); | |
| 1085 | |
| 1086 static const MessageKind MISSING_PART_OF_TAG = const MessageKind( | |
| 1087 "This file has no part-of tag, but it is being used as a part."); | |
| 1088 | |
| 1089 static const MessageKind DUPLICATED_PART_OF = const MessageKind( | |
| 1090 "Duplicated part-of directive."); | |
| 1091 | |
| 1092 static const MessageKind ILLEGAL_DIRECTIVE = const MessageKind( | |
| 1093 "Directive not allowed here."); | |
| 1094 | |
| 1095 static const MessageKind DUPLICATED_LIBRARY_NAME = const MessageKind( | |
| 1096 "Duplicated library name '#{libraryName}'."); | |
| 1097 | |
| 1098 static const MessageKind DUPLICATED_RESOURCE = const MessageKind( | |
| 1099 "The resource '#{resourceUri}' is loaded through both " | |
| 1100 "'#{canonicalUri1}' and '#{canonicalUri2}'."); | |
| 1101 | |
| 1102 static const MessageKind DUPLICATED_LIBRARY_RESOURCE = | |
| 1103 const MessageKind( | |
| 1104 "The library '#{libraryName}' in '#{resourceUri}' is loaded through " | |
| 1105 "both '#{canonicalUri1}' and '#{canonicalUri2}'."); | |
| 1106 | |
| 1107 // This is used as an exception. | |
| 1108 static const MessageKind INVALID_SOURCE_FILE_LOCATION = const MessageKind(''' | |
| 1109 Invalid offset (#{offset}) in source map. | |
| 1110 File: #{fileName} | |
| 1111 Length: #{length}'''); | |
| 1112 | |
| 1113 static const MessageKind TOP_LEVEL_VARIABLE_DECLARED_STATIC = | |
| 1114 const MessageKind( | |
| 1115 "Top-level variable cannot be declared static."); | |
| 1116 | |
| 1117 static const MessageKind REFERENCE_IN_INITIALIZATION = const MessageKind( | |
| 1118 "Variable '#{variableName}' is referenced during its " | |
| 1119 "initialization.", | |
| 1120 howToFix: "If you are trying to reference a shadowed variable, rename" | |
| 1121 " one of the variables.", | |
| 1122 examples: const [""" | |
| 1123 foo(t) { | |
| 1124 var t = t; | |
| 1125 return t; | |
| 1126 } | |
| 1127 | |
| 1128 main() => foo(1); | |
| 1129 """]); | |
| 1130 | |
| 1131 static const MessageKind CONST_WITHOUT_INITIALIZER = const MessageKind( | |
| 1132 "A constant variable must be initialized.", | |
| 1133 howToFix: "Try adding an initializer or " | |
| 1134 "removing the 'const' modifier.", | |
| 1135 examples: const [""" | |
| 1136 void main() { | |
| 1137 const c; // This constant variable must be initialized. | |
| 1138 }"""]); | |
| 1139 | |
| 1140 static const MessageKind FINAL_WITHOUT_INITIALIZER = const MessageKind( | |
| 1141 "A final variable must be initialized.", | |
| 1142 howToFix: "Try adding an initializer or " | |
| 1143 "removing the 'final' modifier.", | |
| 1144 examples: const [ | |
| 1145 "class C { static final field; } main() => C.field;"]); | |
| 1146 | |
| 1147 static const MessageKind MEMBER_USES_CLASS_NAME = const MessageKind( | |
| 1148 "Member variable can't have the same name as the class it is " | |
| 1149 "declared in.", | |
| 1150 howToFix: "Try renaming the variable.", | |
| 1151 examples: const [""" | |
| 1152 class A { var A; } | |
| 1153 main() { | |
| 1154 var a = new A(); | |
| 1155 a.A = 1; | |
| 1156 } | |
| 1157 """, """ | |
| 1158 class A { static var A; } | |
| 1159 main() => A.A = 1; | |
| 1160 """]); | |
| 1161 | |
| 1162 static const MessageKind WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = | |
| 1163 const MessageKind( | |
| 1164 "Wrong number of arguments to assert. Should be 1, but given " | |
| 1165 "#{argumentCount}."); | |
| 1166 | |
| 1167 static const MessageKind ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind( | |
| 1168 "'assert' takes no named arguments, but given #{argumentCount}."); | |
| 1169 | |
| 1170 static const MessageKind FACTORY_REDIRECTION_IN_NON_FACTORY = | |
| 1171 const MessageKind( | |
| 1172 "Factory redirection only allowed in factories."); | |
| 1173 | |
| 1174 static const MessageKind MISSING_FACTORY_KEYWORD = const MessageKind( | |
| 1175 "Did you forget a factory keyword here?"); | |
| 1176 | |
| 1177 static const MessageKind DEFERRED_LIBRARY_DART_2_DART = | |
| 1178 const MessageKind( | |
| 1179 "Deferred loading is not supported by the dart backend yet." | |
| 1180 "The output will not be split."); | |
| 1181 | |
| 1182 static const MessageKind DEFERRED_LIBRARY_WITHOUT_PREFIX = | |
| 1183 const MessageKind( | |
| 1184 "This import is deferred but there is no prefix keyword.", | |
| 1185 howToFix: | |
| 1186 "Try adding a prefix to the import."); | |
| 1187 | |
| 1188 static const MessageKind DEFERRED_OLD_SYNTAX = | |
| 1189 const MessageKind( | |
| 1190 "The DeferredLibrary annotation is obsolete.", | |
| 1191 howToFix: | |
| 1192 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead."); | |
| 1193 | |
| 1194 static const MessageKind DEFERRED_LIBRARY_DUPLICATE_PREFIX = | |
| 1195 const MessageKind( | |
| 1196 "The prefix of this deferred import is not unique.", | |
| 1197 howToFix: | |
| 1198 "Try changing the import prefix."); | |
| 1199 | |
| 1200 static const MessageKind DEFERRED_TYPE_ANNOTATION = | |
| 1201 const MessageKind( | |
| 1202 "The type #{node} is deferred. " | |
| 1203 "Deferred types are not valid as type annotations.", | |
| 1204 howToFix: | |
| 1205 "Try using a non-deferred abstract class as an interface."); | |
| 1206 | |
| 1207 static const MessageKind ILLEGAL_STATIC = const MessageKind( | |
| 1208 "Modifier static is only allowed on functions declared in " | |
| 1209 "a class."); | |
| 1210 | |
| 1211 static const MessageKind STATIC_FUNCTION_BLOAT = const MessageKind( | |
| 1212 "Using '#{class}.#{name}' may lead to unnecessarily large " | |
| 1213 "generated code.", | |
| 1214 howToFix: | |
| 1215 "Try adding '@MirrorsUsed(...)' as described at " | |
| 1216 "https://goo.gl/Akrrog."); | |
| 1217 | |
| 1218 static const MessageKind NON_CONST_BLOAT = const MessageKind( | |
| 1219 "Using 'new #{name}' may lead to unnecessarily large generated " | |
| 1220 "code.", | |
| 1221 howToFix: | |
| 1222 "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as " | |
| 1223 "described at https://goo.gl/Akrrog."); | |
| 1224 | |
| 1225 static const MessageKind STRING_EXPECTED = const MessageKind( | |
| 1226 "Expected a 'String', but got an instance of '#{type}'."); | |
| 1227 | |
| 1228 static const MessageKind PRIVATE_IDENTIFIER = const MessageKind( | |
| 1229 "'#{value}' is not a valid Symbol name because it starts with " | |
| 1230 "'_'."); | |
| 1231 | |
| 1232 static const MessageKind PRIVATE_NAMED_PARAMETER = const MessageKind( | |
| 1233 "Named optional parameter can't have a library private name.", | |
| 1234 howToFix: "Try removing the '_' or making the parameter positional or " | |
| 1235 "required.", | |
| 1236 examples: const ["""foo({int _p}) {} main() => foo();"""] | |
| 1237 ); | |
| 1238 | |
| 1239 static const MessageKind UNSUPPORTED_LITERAL_SYMBOL = const MessageKind( | |
| 1240 "Symbol literal '##{value}' is currently unsupported by dart2js."); | |
| 1241 | |
| 1242 static const MessageKind INVALID_SYMBOL = const MessageKind(''' | |
| 1243 '#{value}' is not a valid Symbol name because is not: | |
| 1244 * an empty String, | |
| 1245 * a user defined operator, | |
| 1246 * a qualified non-private identifier optionally followed by '=', or | |
| 1247 * a qualified non-private identifier followed by '.' and a user-defined ''' | |
| 1248 "operator."); | |
| 1249 | |
| 1250 static const MessageKind AMBIGUOUS_REEXPORT = const MessageKind( | |
| 1251 "'#{name}' is (re)exported by multiple libraries."); | |
| 1252 | |
| 1253 static const MessageKind AMBIGUOUS_LOCATION = const MessageKind( | |
| 1254 "'#{name}' is defined here."); | |
| 1255 | |
| 1256 static const MessageKind IMPORTED_HERE = const MessageKind( | |
| 1257 "'#{name}' is imported here."); | |
| 1258 | |
| 1259 static const MessageKind OVERRIDE_EQUALS_NOT_HASH_CODE = const MessageKind( | |
| 1260 "The class '#{class}' overrides 'operator==', " | |
| 1261 "but not 'get hashCode'."); | |
| 1262 | |
| 1263 static const MessageKind PACKAGE_ROOT_NOT_SET = const MessageKind( | |
| 1264 "Cannot resolve '#{uri}'. Package root has not been set."); | |
| 1265 | |
| 1266 static const MessageKind INTERNAL_LIBRARY_FROM = const MessageKind( | |
| 1267 "Internal library '#{resolvedUri}' is not accessible from " | |
| 1268 "'#{importingUri}'."); | |
| 1269 | |
| 1270 static const MessageKind INTERNAL_LIBRARY = const MessageKind( | |
| 1271 "Internal library '#{resolvedUri}' is not accessible."); | |
| 1272 | |
| 1273 static const MessageKind LIBRARY_NOT_FOUND = const MessageKind( | |
| 1274 "Library not found '#{resolvedUri}'."); | |
| 1275 | |
| 1276 static const MessageKind UNSUPPORTED_EQ_EQ_EQ = const MessageKind( | |
| 1277 "'===' is not an operator. " | |
| 1278 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?"); | |
| 1279 | |
| 1280 static const MessageKind UNSUPPORTED_BANG_EQ_EQ = const MessageKind( | |
| 1281 "'!==' is not an operator. " | |
| 1282 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?"); | |
| 1283 | |
| 1284 static const MessageKind UNSUPPORTED_PREFIX_PLUS = const MessageKind( | |
| 1285 "'+' is not a prefix operator. ", | |
| 1286 howToFix: "Try removing '+'.", | |
| 1287 examples: const [ | |
| 1288 "main() => +2; // No longer a valid way to write '2'" | |
| 1289 ]); | |
| 1290 | |
| 1291 static const MessageKind UNSUPPORTED_THROW_WITHOUT_EXP = const MessageKind( | |
| 1292 "No expression after 'throw'. " | |
| 1293 "Did you mean 'rethrow'?"); | |
| 1294 | |
| 1295 static const MessageKind DEPRECATED_TYPEDEF_MIXIN_SYNTAX = const MessageKind( | |
| 1296 "'typedef' not allowed here. ", | |
| 1297 howToFix: "Try replacing 'typedef' with 'class'.", | |
| 1298 examples: const [ | |
| 1299 """ | |
| 1300 class B { } | |
| 1301 class M1 { } | |
| 1302 typedef C = B with M1; // Need to replace 'typedef' with 'class'. | |
| 1303 main() { new C(); } | |
| 1304 """] | |
| 1305 ); | |
| 1306 | |
| 1307 static const MessageKind MIRRORS_EXPECTED_STRING = const MessageKind( | |
| 1308 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 1309 "and a 'String' value is expected.", | |
| 1310 howToFix: "Did you forget to add quotes?", | |
| 1311 examples: const [ | |
| 1312 """ | |
| 1313 // 'Foo' is a type literal, not a string. | |
| 1314 @MirrorsUsed(symbols: const [Foo]) | |
| 1315 import 'dart:mirrors'; | |
| 1316 | |
| 1317 class Foo {} | |
| 1318 | |
| 1319 main() {} | |
| 1320 """]); | |
| 1321 | |
| 1322 static const MessageKind MIRRORS_EXPECTED_STRING_OR_TYPE = const MessageKind( | |
| 1323 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 1324 "and a 'String' or 'Type' value is expected.", | |
| 1325 howToFix: "Did you forget to add quotes?", | |
| 1326 examples: const [ | |
| 1327 """ | |
| 1328 // 'main' is a method, not a class. | |
| 1329 @MirrorsUsed(targets: const [main]) | |
| 1330 import 'dart:mirrors'; | |
| 1331 | |
| 1332 main() {} | |
| 1333 """]); | |
| 1334 | |
| 1335 static const MessageKind MIRRORS_EXPECTED_STRING_OR_LIST = const MessageKind( | |
| 1336 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 1337 "and a 'String' or 'List' value is expected.", | |
| 1338 howToFix: "Did you forget to add quotes?", | |
| 1339 examples: const [ | |
| 1340 """ | |
| 1341 // 'Foo' is not a string. | |
| 1342 @MirrorsUsed(symbols: Foo) | |
| 1343 import 'dart:mirrors'; | |
| 1344 | |
| 1345 class Foo {} | |
| 1346 | |
| 1347 main() {} | |
| 1348 """]); | |
| 1349 | |
| 1350 static const MessageKind MIRRORS_EXPECTED_STRING_TYPE_OR_LIST = | |
| 1351 const MessageKind( | |
| 1352 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 1353 "but a 'String', 'Type', or 'List' value is expected.", | |
| 1354 howToFix: "Did you forget to add quotes?", | |
| 1355 examples: const [ | |
| 1356 """ | |
| 1357 // '1' is not a string. | |
| 1358 @MirrorsUsed(targets: 1) | |
| 1359 import 'dart:mirrors'; | |
| 1360 | |
| 1361 main() {} | |
| 1362 """]); | |
| 1363 | |
| 1364 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY = | |
| 1365 const MessageKind( | |
| 1366 "Can't find '#{name}' in the current library.", | |
| 1367 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 1368 howToFix: "Did you forget to add an import?", | |
| 1369 examples: const [ | |
| 1370 """ | |
| 1371 // 'window' is not in scope because dart:html isn't imported. | |
| 1372 @MirrorsUsed(targets: 'window') | |
| 1373 import 'dart:mirrors'; | |
| 1374 | |
| 1375 main() {} | |
| 1376 """]); | |
| 1377 | |
| 1378 static const MessageKind MIRRORS_CANNOT_RESOLVE_IN_LIBRARY = | |
| 1379 const MessageKind( | |
| 1380 "Can't find '#{name}' in the library '#{library}'.", | |
| 1381 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 1382 howToFix: "Is '#{name}' spelled right?", | |
| 1383 examples: const [ | |
| 1384 """ | |
| 1385 // 'List' is misspelled. | |
| 1386 @MirrorsUsed(targets: 'dart.core.Lsit') | |
| 1387 import 'dart:mirrors'; | |
| 1388 | |
| 1389 main() {} | |
| 1390 """]); | |
| 1391 | |
| 1392 static const MessageKind MIRRORS_CANNOT_FIND_IN_ELEMENT = | |
| 1393 const MessageKind( | |
| 1394 "Can't find '#{name}' in '#{element}'.", | |
| 1395 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 1396 howToFix: "Is '#{name}' spelled right?", | |
| 1397 examples: const [ | |
| 1398 """ | |
| 1399 // 'addAll' is misspelled. | |
| 1400 @MirrorsUsed(targets: 'dart.core.List.addAl') | |
| 1401 import 'dart:mirrors'; | |
| 1402 | |
| 1403 main() {} | |
| 1404 """]); | |
| 1405 | |
| 1406 static const MessageKind READ_SCRIPT_ERROR = const MessageKind( | |
| 1407 "Can't read '#{uri}' (#{exception}).", | |
| 1408 // Don't know how to fix since the underlying error is unknown. | |
| 1409 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1410 examples: const [ | |
| 1411 """ | |
| 1412 // 'foo.dart' does not exist. | |
| 1413 import 'foo.dart'; | |
| 1414 | |
| 1415 main() {} | |
| 1416 """]); | |
| 1417 | |
| 1418 static const MessageKind EXTRANEOUS_MODIFIER = const MessageKind( | |
| 1419 "Can't have modifier '#{modifier}' here.", | |
| 1420 howToFix: "Try removing '#{modifier}'.", | |
| 1421 examples: const [ | |
| 1422 "var String foo; main(){}", | |
| 1423 // "var get foo; main(){}", | |
| 1424 "var set foo; main(){}", | |
| 1425 "var final foo; main(){}", | |
| 1426 "var var foo; main(){}", | |
| 1427 "var const foo; main(){}", | |
| 1428 "var abstract foo; main(){}", | |
| 1429 "var static foo; main(){}", | |
| 1430 "var external foo; main(){}", | |
| 1431 "get var foo; main(){}", | |
| 1432 "set var foo; main(){}", | |
| 1433 "final var foo; main(){}", | |
| 1434 "var var foo; main(){}", | |
| 1435 "const var foo; main(){}", | |
| 1436 "abstract var foo; main(){}", | |
| 1437 "static var foo; main(){}", | |
| 1438 "external var foo; main(){}"]); | |
| 1439 | |
| 1440 static const MessageKind EXTRANEOUS_MODIFIER_REPLACE = const MessageKind( | |
| 1441 "Can't have modifier '#{modifier}' here.", | |
| 1442 howToFix: "Try replacing modifier '#{modifier}' with 'var', 'final'," | |
| 1443 " or a type.", | |
| 1444 examples: const [ | |
| 1445 // "get foo; main(){}", | |
| 1446 "set foo; main(){}", | |
| 1447 "abstract foo; main(){}", | |
| 1448 "static foo; main(){}", | |
| 1449 "external foo; main(){}"]); | |
| 1450 | |
| 1451 static const MessageKind ABSTRACT_CLASS_INSTANTIATION = const MessageKind( | |
| 1452 "Can't instantiate abstract class.", | |
| 1453 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1454 examples: const ["abstract class A {} main() { new A(); }"]); | |
| 1455 | |
| 1456 static const MessageKind BODY_EXPECTED = const MessageKind( | |
| 1457 "Expected a function body or '=>'.", | |
| 1458 // TODO(ahe): In some scenarios, we can suggest removing the 'static' | |
| 1459 // keyword. | |
| 1460 howToFix: "Try adding {}.", | |
| 1461 examples: const [ | |
| 1462 "main();"]); | |
| 1463 | |
| 1464 static const MessageKind MIRROR_BLOAT = const MessageKind( | |
| 1465 "#{count} methods retained for use by dart:mirrors out of #{total}" | |
| 1466 " total methods (#{percentage}%)."); | |
| 1467 | |
| 1468 static const MessageKind MIRROR_IMPORT = const MessageKind( | |
| 1469 "Import of 'dart:mirrors'."); | |
| 1470 | |
| 1471 static const MessageKind MIRROR_IMPORT_NO_USAGE = const MessageKind( | |
| 1472 "This import is not annotated with @MirrorsUsed, which may lead to " | |
| 1473 "unnecessarily large generated code.", | |
| 1474 howToFix: | |
| 1475 "Try adding '@MirrorsUsed(...)' as described at " | |
| 1476 "https://goo.gl/Akrrog."); | |
| 1477 | |
| 1478 static const MessageKind WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT = | |
| 1479 const MessageKind( | |
| 1480 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant."); | |
| 1481 | |
| 1482 static const MessageKind EXPECTED_IDENTIFIER_NOT_RESERVED_WORD = | |
| 1483 const MessageKind( | |
| 1484 "'#{keyword}' is a reserved word and can't be used here.", | |
| 1485 howToFix: "Try using a different name.", | |
| 1486 examples: const ["do() {} main() {}"]); | |
| 1487 | |
| 1488 static const MessageKind NAMED_FUNCTION_EXPRESSION = | |
| 1489 const MessageKind("Function expression '#{name}' cannot be named.", | |
| 1490 howToFix: "Try removing the name.", | |
| 1491 examples: const ["main() { var f = func() {}; }"]); | |
| 1492 | |
| 1493 static const MessageKind UNUSED_METHOD = const MessageKind( | |
| 1494 "The method '#{name}' is never called.", | |
| 1495 howToFix: "Consider deleting it.", | |
| 1496 examples: const ["deadCode() {} main() {}"]); | |
| 1497 | |
| 1498 static const MessageKind UNUSED_CLASS = const MessageKind( | |
| 1499 "The class '#{name}' is never used.", | |
| 1500 howToFix: "Consider deleting it.", | |
| 1501 examples: const ["class DeadCode {} main() {}"]); | |
| 1502 | |
| 1503 static const MessageKind UNUSED_TYPEDEF = const MessageKind( | |
| 1504 "The typedef '#{name}' is never used.", | |
| 1505 howToFix: "Consider deleting it.", | |
| 1506 examples: const ["typedef DeadCode(); main() {}"]); | |
| 1507 | |
| 1508 static const MessageKind ABSTRACT_METHOD = const MessageKind( | |
| 1509 "The method '#{name}' has no implementation in " | |
| 1510 "class '#{class}'.", | |
| 1511 howToFix: "Try adding a body to '#{name}' or declaring " | |
| 1512 "'#{class}' to be 'abstract'.", | |
| 1513 examples: const [""" | |
| 1514 class Class { | |
| 1515 method(); | |
| 1516 } | |
| 1517 main() => new Class().method(); | |
| 1518 """]); | |
| 1519 | |
| 1520 static const MessageKind ABSTRACT_GETTER = const MessageKind( | |
| 1521 "The getter '#{name}' has no implementation in " | |
| 1522 "class '#{class}'.", | |
| 1523 howToFix: "Try adding a body to '#{name}' or declaring " | |
| 1524 "'#{class}' to be 'abstract'.", | |
| 1525 examples: const [""" | |
| 1526 class Class { | |
| 1527 get getter; | |
| 1528 } | |
| 1529 main() => new Class(); | |
| 1530 """]); | |
| 1531 | |
| 1532 static const MessageKind ABSTRACT_SETTER = const MessageKind( | |
| 1533 "The setter '#{name}' has no implementation in " | |
| 1534 "class '#{class}'.", | |
| 1535 howToFix: "Try adding a body to '#{name}' or declaring " | |
| 1536 "'#{class}' to be 'abstract'.", | |
| 1537 examples: const [""" | |
| 1538 class Class { | |
| 1539 set setter(_); | |
| 1540 } | |
| 1541 main() => new Class(); | |
| 1542 """]); | |
| 1543 | |
| 1544 static const MessageKind INHERIT_GETTER_AND_METHOD = const MessageKind( | |
| 1545 "The class '#{class}' can't inherit both getters and methods " | |
| 1546 "by the named '#{name}'.", | |
| 1547 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1548 examples: const [""" | |
| 1549 class A { | |
| 1550 get member => null; | |
| 1551 } | |
| 1552 class B { | |
| 1553 member() {} | |
| 1554 } | |
| 1555 class Class implements A, B { | |
| 1556 } | |
| 1557 main() => new Class(); | |
| 1558 """]); | |
| 1559 | |
| 1560 static const MessageKind INHERITED_METHOD = const MessageKind( | |
| 1561 "The inherited method '#{name}' is declared here in class " | |
| 1562 "'#{class}'."); | |
| 1563 | |
| 1564 static const MessageKind INHERITED_EXPLICIT_GETTER = const MessageKind( | |
| 1565 "The inherited getter '#{name}' is declared here in class " | |
| 1566 "'#{class}'."); | |
| 1567 | |
| 1568 static const MessageKind INHERITED_IMPLICIT_GETTER = const MessageKind( | |
| 1569 "The inherited getter '#{name}' is implicitly declared by this " | |
| 1570 "field in class '#{class}'."); | |
| 1571 | |
| 1572 static const MessageKind UNIMPLEMENTED_METHOD_ONE = const MessageKind( | |
| 1573 "'#{class}' doesn't implement '#{method}' " | |
| 1574 "declared in '#{declarer}'.", | |
| 1575 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1576 "'#{class}' to be 'abstract'.", | |
| 1577 examples: const [""" | |
| 1578 abstract class I { | |
| 1579 m(); | |
| 1580 } | |
| 1581 class C implements I {} | |
| 1582 main() => new C(); | |
| 1583 """, """ | |
| 1584 abstract class I { | |
| 1585 m(); | |
| 1586 } | |
| 1587 class C extends I {} | |
| 1588 main() => new C(); | |
| 1589 """]); | |
| 1590 | |
| 1591 static const MessageKind UNIMPLEMENTED_METHOD = const MessageKind( | |
| 1592 "'#{class}' doesn't implement '#{method}'.", | |
| 1593 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1594 "'#{class}' to be 'abstract'.", | |
| 1595 examples: const [""" | |
| 1596 abstract class I { | |
| 1597 m(); | |
| 1598 } | |
| 1599 | |
| 1600 abstract class J { | |
| 1601 m(); | |
| 1602 } | |
| 1603 | |
| 1604 class C implements I, J {} | |
| 1605 | |
| 1606 main() { | |
| 1607 new C(); | |
| 1608 } | |
| 1609 """, """ | |
| 1610 abstract class I { | |
| 1611 m(); | |
| 1612 } | |
| 1613 | |
| 1614 abstract class J { | |
| 1615 m(); | |
| 1616 } | |
| 1617 | |
| 1618 class C extends I implements J {} | |
| 1619 | |
| 1620 main() { | |
| 1621 new C(); | |
| 1622 } | |
| 1623 """]); | |
| 1624 | |
| 1625 static const MessageKind UNIMPLEMENTED_METHOD_CONT = const MessageKind( | |
| 1626 "The method '#{name}' is declared here in class '#{class}'."); | |
| 1627 | |
| 1628 static const MessageKind UNIMPLEMENTED_SETTER_ONE = const MessageKind( | |
| 1629 "'#{class}' doesn't implement the setter '#{name}' " | |
| 1630 "declared in '#{declarer}'.", | |
| 1631 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1632 "'#{class}' to be 'abstract'.", | |
| 1633 examples: const [""" | |
| 1634 abstract class I { | |
| 1635 set m(_); | |
| 1636 } | |
| 1637 class C implements I {} | |
| 1638 class D implements I { | |
| 1639 set m(_) {} | |
| 1640 } | |
| 1641 main() { | |
| 1642 new D().m = 0; | |
| 1643 new C(); | |
| 1644 } | |
| 1645 """]); | |
| 1646 | |
| 1647 static const MessageKind UNIMPLEMENTED_SETTER = const MessageKind( | |
| 1648 "'#{class}' doesn't implement the setter '#{name}'.", | |
| 1649 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1650 "'#{class}' to be 'abstract'.", | |
| 1651 examples: const [""" | |
| 1652 abstract class I { | |
| 1653 set m(_); | |
| 1654 } | |
| 1655 abstract class J { | |
| 1656 set m(_); | |
| 1657 } | |
| 1658 class C implements I, J {} | |
| 1659 main() => new C(); | |
| 1660 """, """ | |
| 1661 abstract class I { | |
| 1662 set m(_); | |
| 1663 } | |
| 1664 abstract class J { | |
| 1665 set m(_); | |
| 1666 } | |
| 1667 class C extends I implements J {} | |
| 1668 main() => new C(); | |
| 1669 """]); | |
| 1670 | |
| 1671 static const MessageKind UNIMPLEMENTED_EXPLICIT_SETTER = const MessageKind( | |
| 1672 "The setter '#{name}' is declared here in class '#{class}'."); | |
| 1673 | |
| 1674 static const MessageKind UNIMPLEMENTED_IMPLICIT_SETTER = const MessageKind( | |
| 1675 "The setter '#{name}' is implicitly declared by this field " | |
| 1676 "in class '#{class}'."); | |
| 1677 | |
| 1678 static const MessageKind UNIMPLEMENTED_GETTER_ONE = const MessageKind( | |
| 1679 "'#{class}' doesn't implement the getter '#{name}' " | |
| 1680 "declared in '#{declarer}'.", | |
| 1681 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1682 "'#{class}' to be 'abstract'.", | |
| 1683 examples: const [""" | |
| 1684 abstract class I { | |
| 1685 get m; | |
| 1686 } | |
| 1687 class C implements I {} | |
| 1688 main() => new C(); | |
| 1689 """, """ | |
| 1690 abstract class I { | |
| 1691 get m; | |
| 1692 } | |
| 1693 class C extends I {} | |
| 1694 main() => new C(); | |
| 1695 """]); | |
| 1696 | |
| 1697 static const MessageKind UNIMPLEMENTED_GETTER = const MessageKind( | |
| 1698 "'#{class}' doesn't implement the getter '#{name}'.", | |
| 1699 howToFix: "Try adding an implementation of '#{name}' or declaring " | |
| 1700 "'#{class}' to be 'abstract'.", | |
| 1701 examples: const [""" | |
| 1702 abstract class I { | |
| 1703 get m; | |
| 1704 } | |
| 1705 abstract class J { | |
| 1706 get m; | |
| 1707 } | |
| 1708 class C implements I, J {} | |
| 1709 main() => new C(); | |
| 1710 """, """ | |
| 1711 abstract class I { | |
| 1712 get m; | |
| 1713 } | |
| 1714 abstract class J { | |
| 1715 get m; | |
| 1716 } | |
| 1717 class C extends I implements J {} | |
| 1718 main() => new C(); | |
| 1719 """]); | |
| 1720 | |
| 1721 static const MessageKind UNIMPLEMENTED_EXPLICIT_GETTER = const MessageKind( | |
| 1722 "The getter '#{name}' is declared here in class '#{class}'."); | |
| 1723 | |
| 1724 static const MessageKind UNIMPLEMENTED_IMPLICIT_GETTER = const MessageKind( | |
| 1725 "The getter '#{name}' is implicitly declared by this field " | |
| 1726 "in class '#{class}'."); | |
| 1727 | |
| 1728 static const MessageKind EQUAL_MAP_ENTRY_KEY = const MessageKind( | |
| 1729 "An entry with the same key already exists in the map.", | |
| 1730 howToFix: "Try removing the previous entry or changing the key in one " | |
| 1731 "of the entries.", | |
| 1732 examples: const [""" | |
| 1733 main() { | |
| 1734 var m = const {'foo': 1, 'foo': 2}; | |
| 1735 }"""]); | |
| 1736 | |
| 1737 static const MessageKind BAD_INPUT_CHARACTER = const MessageKind( | |
| 1738 "Character U+#{characterHex} isn't allowed here.", | |
| 1739 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1740 examples: const [""" | |
| 1741 main() { | |
| 1742 String x = ç; | |
| 1743 } | |
| 1744 """]); | |
| 1745 | |
| 1746 static const MessageKind UNTERMINATED_STRING = const MessageKind( | |
| 1747 "String must end with #{quote}.", | |
| 1748 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1749 examples: const [""" | |
| 1750 main() { | |
| 1751 return ' | |
| 1752 ; | |
| 1753 } | |
| 1754 """, | |
| 1755 """ | |
| 1756 main() { | |
| 1757 return \" | |
| 1758 ; | |
| 1759 } | |
| 1760 """, | |
| 1761 """ | |
| 1762 main() { | |
| 1763 return r' | |
| 1764 ; | |
| 1765 } | |
| 1766 """, | |
| 1767 """ | |
| 1768 main() { | |
| 1769 return r\" | |
| 1770 ; | |
| 1771 } | |
| 1772 """, | |
| 1773 """ | |
| 1774 main() => ''' | |
| 1775 """, | |
| 1776 """ | |
| 1777 main() => \"\"\" | |
| 1778 """, | |
| 1779 """ | |
| 1780 main() => r''' | |
| 1781 """, | |
| 1782 """ | |
| 1783 main() => r\"\"\" | |
| 1784 """]); | |
| 1785 | |
| 1786 static const MessageKind UNMATCHED_TOKEN = const MessageKind( | |
| 1787 "Can't find '#{end}' to match '#{begin}'.", | |
| 1788 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1789 examples: const[ | |
| 1790 "main(", | |
| 1791 "main(){", | |
| 1792 "main(){]}", | |
| 1793 ]); | |
| 1794 | |
| 1795 static const MessageKind UNTERMINATED_TOKEN = const MessageKind( | |
| 1796 // This is a fall-back message that shouldn't happen. | |
| 1797 "Incomplete token."); | |
| 1798 | |
| 1799 static const MessageKind EXPONENT_MISSING = const MessageKind( | |
| 1800 "Numbers in exponential notation should always contain an exponent" | |
| 1801 " (an integer number with an optional sign).", | |
| 1802 howToFix: "Make sure there is an exponent, and remove any whitespace " | |
| 1803 "before it.", | |
| 1804 examples: const [""" | |
| 1805 main() { | |
| 1806 var i = 1e; | |
| 1807 } | |
| 1808 """]); | |
| 1809 | |
| 1810 static const MessageKind HEX_DIGIT_EXPECTED = const MessageKind( | |
| 1811 "A hex digit (0-9 or A-F) must follow '0x'.", | |
| 1812 howToFix: DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message. | |
| 1813 examples: const [""" | |
| 1814 main() { | |
| 1815 var i = 0x; | |
| 1816 } | |
| 1817 """]); | |
| 1818 | |
| 1819 static const MessageKind MALFORMED_STRING_LITERAL = const MessageKind( | |
| 1820 r"A '$' has special meaning inside a string, and must be followed by an" | |
| 1821 " identifier or an expression in curly braces ({}).", | |
| 1822 howToFix: r"Try adding a backslash (\) to escape the '$'.", | |
| 1823 examples: const [r""" | |
| 1824 main() { | |
| 1825 return '$'; | |
| 1826 } | |
| 1827 """, | |
| 1828 r''' | |
| 1829 main() { | |
| 1830 return "$"; | |
| 1831 } | |
| 1832 ''', | |
| 1833 r""" | |
| 1834 main() { | |
| 1835 return '''$'''; | |
| 1836 } | |
| 1837 """, | |
| 1838 r''' | |
| 1839 main() { | |
| 1840 return """$"""; | |
| 1841 } | |
| 1842 ''']); | |
| 1843 | |
| 1844 static const MessageKind UNTERMINATED_COMMENT = const MessageKind( | |
| 1845 "Comment starting with '/*' must end with '*/'.", | |
| 1846 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1847 examples: const [r""" | |
| 1848 main() { | |
| 1849 } | |
| 1850 /*"""]); | |
| 1851 | |
| 1852 static const MessageKind MISSING_TOKEN_BEFORE_THIS = const MessageKind( | |
| 1853 "Expected '#{token}' before this.", | |
| 1854 // Consider the second example below: the parser expects a ')' before | |
| 1855 // 'y', but a ',' would also have worked. We don't have enough | |
| 1856 // information to give a good suggestion. | |
| 1857 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1858 examples: const [ | |
| 1859 "main() => true ? 1;", | |
| 1860 "main() => foo(x: 1 y: 2);", | |
| 1861 ]); | |
| 1862 | |
| 1863 static const MessageKind MISSING_TOKEN_AFTER_THIS = const MessageKind( | |
| 1864 "Expected '#{token}' after this.", | |
| 1865 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information to | |
| 1866 // give a good suggestion. | |
| 1867 howToFix: DONT_KNOW_HOW_TO_FIX, | |
| 1868 examples: const [ | |
| 1869 "main(x) {x}", | |
| 1870 """ | |
| 1871 class S1 {} | |
| 1872 class S2 {} | |
| 1873 class S3 {} | |
| 1874 class A = S1 with S2, S3 | |
| 1875 main() => new A(); | |
| 1876 """ | |
| 1877 ]); | |
| 1878 | |
| 1879 static const MessageKind CONSIDER_ANALYZE_ALL = const MessageKind( | |
| 1880 "Could not find '#{main}'. Nothing will be analyzed.", | |
| 1881 howToFix: "Try using '--analyze-all' to analyze everything.", | |
| 1882 examples: const ['']); | |
| 1883 | |
| 1884 static const MessageKind MISSING_MAIN = const MessageKind( | |
| 1885 "Could not find '#{main}'.", | |
| 1886 howToFix: "Try adding a method named '#{main}' to your program." | |
| 1887 /* No example, test uses '--analyze-only' which will produce the above | |
| 1888 * message [CONSIDER_ANALYZE_ALL]. An example for a human operator would | |
| 1889 * be an empty file. */); | |
| 1890 | |
| 1891 static const MessageKind MAIN_NOT_A_FUNCTION = const MessageKind( | |
| 1892 "'#{main}' is not a function.", | |
| 1893 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ | |
| 1894 examples: const ['var main;']); | |
| 1895 | |
| 1896 static const MessageKind MAIN_WITH_EXTRA_PARAMETER = const MessageKind( | |
| 1897 "'#{main}' cannot have more than two parameters.", | |
| 1898 howToFix: DONT_KNOW_HOW_TO_FIX, /* Don't state the obvious. */ | |
| 1899 examples: const ['main(a, b, c) {}']); | |
| 1900 | |
| 1901 static const MessageKind COMPILER_CRASHED = const MessageKind( | |
| 1902 "The compiler crashed when compiling this element."); | |
| 1903 | |
| 1904 static const MessageKind PLEASE_REPORT_THE_CRASH = const MessageKind(''' | |
| 1905 The compiler is broken. | |
| 1906 | |
| 1907 When compiling the above element, the compiler crashed. It is not | |
| 1908 possible to tell if this is caused by a problem in your program or | |
| 1909 not. Regardless, the compiler should not crash. | |
| 1910 | |
| 1911 The Dart team would greatly appreciate if you would take a moment to | |
| 1912 report this problem at http://dartbug.com/new. | |
| 1913 | |
| 1914 Please include the following information: | |
| 1915 | |
| 1916 * the name and version of your operating system, | |
| 1917 | |
| 1918 * the Dart SDK build number (#{buildId}), and | |
| 1919 | |
| 1920 * the entire message you see here (including the full stack trace | |
| 1921 below as well as the source location above). | |
| 1922 '''); | |
| 1923 | |
| 1924 static const MessageKind POTENTIAL_MUTATION = const MessageKind( | |
| 1925 "Variable '#{variableName}' is not known to be of type " | |
| 1926 "'#{shownType}' because it is potentially mutated in the scope for " | |
| 1927 "promotion."); | |
| 1928 | |
| 1929 static const MessageKind POTENTIAL_MUTATION_HERE = const MessageKind( | |
| 1930 "Variable '#{variableName}' is potentially mutated here."); | |
| 1931 | |
| 1932 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE = const MessageKind( | |
| 1933 "Variable '#{variableName}' is not known to be of type " | |
| 1934 "'#{shownType}' because it is potentially mutated within a closure."); | |
| 1935 | |
| 1936 static const MessageKind POTENTIAL_MUTATION_IN_CLOSURE_HERE = | |
| 1937 const MessageKind( | |
| 1938 "Variable '#{variableName}' is potentially mutated in a " | |
| 1939 "closure here."); | |
| 1940 | |
| 1941 static const MessageKind ACCESSED_IN_CLOSURE = const MessageKind( | |
| 1942 "Variable '#{variableName}' is not known to be of type " | |
| 1943 "'#{shownType}' because it is accessed by a closure in the scope for " | |
| 1944 "promotion and potentially mutated in the scope of '#{variableName}'."); | |
| 1945 | |
| 1946 static const MessageKind ACCESSED_IN_CLOSURE_HERE = const MessageKind( | |
| 1947 "Variable '#{variableName}' is accessed in a closure here."); | |
| 1948 | |
| 1949 static const MessageKind NOT_MORE_SPECIFIC = const MessageKind( | |
| 1950 "Variable '#{variableName}' is not shown to have type " | |
| 1951 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
| 1952 "known type '#{knownType}' of '#{variableName}'."); | |
| 1953 | |
| 1954 static const MessageKind NOT_MORE_SPECIFIC_SUBTYPE = const MessageKind( | |
| 1955 "Variable '#{variableName}' is not shown to have type " | |
| 1956 "'#{shownType}' because '#{shownType}' is not a subtype of the " | |
| 1957 "known type '#{knownType}' of '#{variableName}'."); | |
| 1958 | |
| 1959 static const MessageKind NOT_MORE_SPECIFIC_SUGGESTION = const MessageKind( | |
| 1960 "Variable '#{variableName}' is not shown to have type " | |
| 1961 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
| 1962 "known type '#{knownType}' of '#{variableName}'.", | |
| 1963 howToFix: "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'."); | |
| 1964 | |
| 1965 static const MessageKind HIDDEN_WARNINGS_HINTS = const MessageKind( | |
| 1966 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}."); | |
| 1967 | |
| 1968 static const MessageKind HIDDEN_WARNINGS = const MessageKind( | |
| 1969 "#{warnings} warning(s) suppressed in #{uri}."); | |
| 1970 | |
| 1971 static const MessageKind HIDDEN_HINTS = const MessageKind( | |
| 1972 "#{hints} hint(s) suppressed in #{uri}."); | |
| 1973 | |
| 1974 static const MessageKind PREAMBLE = const MessageKind( | |
| 1975 "When run on the command-line, the compiled output might" | |
| 1976 " require a preamble file located in:\n" | |
| 1977 " <sdk>/lib/_internal/compiler/js_lib/preambles."); | |
| 1978 | |
| 1979 ////////////////////////////////////////////////////////////////////////////// | |
| 1980 // Patch errors start. | |
| 1981 ////////////////////////////////////////////////////////////////////////////// | |
| 1982 | |
| 1983 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind( | |
| 1984 "Patch return type '#{patchReturnType}' does not match " | |
| 1985 "'#{originReturnType}' on origin method '#{methodName}'."); | |
| 1986 | |
| 1987 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = | |
| 1988 const MessageKind( | |
| 1989 "Required parameter count of patch method " | |
| 1990 "(#{patchParameterCount}) does not match parameter count on origin " | |
| 1991 "method '#{methodName}' (#{originParameterCount})."); | |
| 1992 | |
| 1993 static const MessageKind PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = | |
| 1994 const MessageKind( | |
| 1995 "Optional parameter count of patch method " | |
| 1996 "(#{patchParameterCount}) does not match parameter count on origin " | |
| 1997 "method '#{methodName}' (#{originParameterCount})."); | |
| 1998 | |
| 1999 static const MessageKind PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = | |
| 2000 const MessageKind( | |
| 2001 "Optional parameters of origin and patch method " | |
| 2002 "'#{methodName}' must both be either named or positional."); | |
| 2003 | |
| 2004 static const MessageKind PATCH_PARAMETER_MISMATCH = const MessageKind( | |
| 2005 "Patch method parameter '#{patchParameter}' does not match " | |
| 2006 "'#{originParameter}' on origin method '#{methodName}'."); | |
| 2007 | |
| 2008 static const MessageKind PATCH_PARAMETER_TYPE_MISMATCH = const MessageKind( | |
| 2009 "Patch method parameter '#{parameterName}' type " | |
| 2010 "'#{patchParameterType}' does not match '#{originParameterType}' on " | |
| 2011 "origin method '#{methodName}'."); | |
| 2012 | |
| 2013 static const MessageKind PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION = | |
| 2014 const MessageKind("External method without an implementation."); | |
| 2015 | |
| 2016 static const MessageKind PATCH_POINT_TO_FUNCTION = const MessageKind( | |
| 2017 "This is the function patch '#{functionName}'."); | |
| 2018 | |
| 2019 static const MessageKind PATCH_POINT_TO_CLASS = const MessageKind( | |
| 2020 "This is the class patch '#{className}'."); | |
| 2021 | |
| 2022 static const MessageKind PATCH_POINT_TO_GETTER = const MessageKind( | |
| 2023 "This is the getter patch '#{getterName}'."); | |
| 2024 | |
| 2025 static const MessageKind PATCH_POINT_TO_SETTER = const MessageKind( | |
| 2026 "This is the setter patch '#{setterName}'."); | |
| 2027 | |
| 2028 static const MessageKind PATCH_POINT_TO_CONSTRUCTOR = const MessageKind( | |
| 2029 "This is the constructor patch '#{constructorName}'."); | |
| 2030 | |
| 2031 static const MessageKind PATCH_POINT_TO_PARAMETER = const MessageKind( | |
| 2032 "This is the patch parameter '#{parameterName}'."); | |
| 2033 | |
| 2034 static const MessageKind PATCH_NON_EXISTING = const MessageKind( | |
| 2035 "Origin does not exist for patch '#{name}'."); | |
| 2036 | |
| 2037 // TODO(ahe): Eventually, this error should be removed as it will be handled | |
| 2038 // by the regular parser. | |
| 2039 static const MessageKind PATCH_NONPATCHABLE = const MessageKind( | |
| 2040 "Only classes and functions can be patched."); | |
| 2041 | |
| 2042 static const MessageKind PATCH_NON_EXTERNAL = const MessageKind( | |
| 2043 "Only external functions can be patched."); | |
| 2044 | |
| 2045 static const MessageKind PATCH_NON_CLASS = const MessageKind( | |
| 2046 "Patching non-class with class patch '#{className}'."); | |
| 2047 | |
| 2048 static const MessageKind PATCH_NON_GETTER = const MessageKind( | |
| 2049 "Cannot patch non-getter '#{name}' with getter patch."); | |
| 2050 | |
| 2051 static const MessageKind PATCH_NO_GETTER = const MessageKind( | |
| 2052 "No getter found for getter patch '#{getterName}'."); | |
| 2053 | |
| 2054 static const MessageKind PATCH_NON_SETTER = const MessageKind( | |
| 2055 "Cannot patch non-setter '#{name}' with setter patch."); | |
| 2056 | |
| 2057 static const MessageKind PATCH_NO_SETTER = const MessageKind( | |
| 2058 "No setter found for setter patch '#{setterName}'."); | |
| 2059 | |
| 2060 static const MessageKind PATCH_NON_CONSTRUCTOR = const MessageKind( | |
| 2061 "Cannot patch non-constructor with constructor patch " | |
| 2062 "'#{constructorName}'."); | |
| 2063 | |
| 2064 static const MessageKind PATCH_NON_FUNCTION = const MessageKind( | |
| 2065 "Cannot patch non-function with function patch " | |
| 2066 "'#{functionName}'."); | |
| 2067 | |
| 2068 ////////////////////////////////////////////////////////////////////////////// | |
| 2069 // Patch errors end. | |
| 2070 ////////////////////////////////////////////////////////////////////////////// | |
| 2071 | |
| 2072 static const MessageKind CALL_NOT_SUPPORTED_ON_NATIVE_CLASS = | |
| 2073 const MessageKind( | |
| 2074 "Non-supported 'call' member on a native class, or a " | |
| 2075 "subclass of a native class."); | |
| 2076 | |
| 2077 toString() => template; | |
| 2078 | |
| 2079 Message message([Map arguments = const {}, bool terse = false]) { | |
| 2080 return new Message(this, arguments, terse); | |
| 2081 } | |
| 2082 | |
| 2083 bool get hasHowToFix => howToFix != null && howToFix != DONT_KNOW_HOW_TO_FIX; | |
| 2084 } | |
| 2085 | |
| 2086 class Message { | |
| 2087 final MessageKind kind; | |
| 2088 final Map arguments; | |
| 2089 final bool terse; | |
| 2090 String message; | |
| 2091 | |
| 2092 Message(this.kind, this.arguments, this.terse) { | |
| 2093 assert(() { computeMessage(); return true; }); | |
| 2094 } | |
| 2095 | |
| 2096 String computeMessage() { | |
| 2097 if (message == null) { | |
| 2098 message = kind.template; | |
| 2099 arguments.forEach((key, value) { | |
| 2100 message = message.replaceAll('#{${key}}', convertToString(value)); | |
| 2101 }); | |
| 2102 assert(invariant( | |
| 2103 CURRENT_ELEMENT_SPANNABLE, | |
| 2104 kind == MessageKind.GENERIC || | |
| 2105 !message.contains(new RegExp(r'#\{.+\}')), | |
| 2106 message: 'Missing arguments in error message: "$message"')); | |
| 2107 if (!terse && kind.hasHowToFix) { | |
| 2108 String howToFix = kind.howToFix; | |
| 2109 arguments.forEach((key, value) { | |
| 2110 howToFix = howToFix.replaceAll('#{${key}}', convertToString(value)); | |
| 2111 }); | |
| 2112 message = '$message\n$howToFix'; | |
| 2113 } | |
| 2114 } | |
| 2115 return message; | |
| 2116 } | |
| 2117 | |
| 2118 String toString() { | |
| 2119 return computeMessage(); | |
| 2120 } | |
| 2121 | |
| 2122 bool operator==(other) { | |
| 2123 if (other is !Message) return false; | |
| 2124 return (kind == other.kind) && (toString() == other.toString()); | |
| 2125 } | |
| 2126 | |
| 2127 int get hashCode => throw new UnsupportedError('Message.hashCode'); | |
| 2128 | |
| 2129 static String convertToString(value) { | |
| 2130 if (value is ErrorToken) { | |
| 2131 // Shouldn't happen. | |
| 2132 return value.assertionMessage; | |
| 2133 } else if (value is Token) { | |
| 2134 value = value.value; | |
| 2135 } | |
| 2136 return '$value'; | |
| 2137 } | |
| 2138 } | |
| OLD | NEW |