| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, 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 // The messages in this file should meet the following guide lines: | |
| 6 // | |
| 7 // 1. The message should be a complete sentence starting with an uppercase | |
| 8 // letter, and ending with a period. | |
| 9 // | |
| 10 // 2. Reserved words and embedded identifiers should be in single quotes, so | |
| 11 // prefer double quotes for the complete message. For example, "The | |
| 12 // class '#{className}' can't use 'super'." Notice that the word 'class' in the | |
| 13 // preceding message is not quoted as it refers to the concept 'class', not the | |
| 14 // reserved word. On the other hand, 'super' refers to the reserved word. Do | |
| 15 // not quote 'null' and numeric literals. | |
| 16 // | |
| 17 // 3. Do not try to compose messages, as it can make translating them hard. | |
| 18 // | |
| 19 // 4. Try to keep the error messages short, but informative. | |
| 20 // | |
| 21 // 5. Use simple words and terminology, assume the reader of the message | |
| 22 // doesn't have an advanced degree in math, and that English is not the | |
| 23 // reader's native language. Do not assume any formal computer science | |
| 24 // training. For example, do not use Latin abbreviations (prefer "that is" over | |
| 25 // "i.e.", and "for example" over "e.g."). Also avoid phrases such as "if and | |
| 26 // only if" and "iff", that level of precision is unnecessary. | |
| 27 // | |
| 28 // 6. Prefer contractions when they are in common use, for example, prefer | |
| 29 // "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is | |
| 30 // off-putting to people new to programming. | |
| 31 // | |
| 32 // 7. Use common terminology, preferably from the Dart Language | |
| 33 // Specification. This increases the user's chance of finding a good | |
| 34 // explanation on the web. | |
| 35 // | |
| 36 // 8. Do not try to be cute or funny. It is extremely frustrating to work on a | |
| 37 // product that crashes with a "tongue-in-cheek" message, especially if you did | |
| 38 // not want to use this product to begin with. | |
| 39 // | |
| 40 // 9. Do not lie, that is, do not write error messages containing phrases like | |
| 41 // "can't happen". If the user ever saw this message, it would be a | |
| 42 // lie. Prefer messages like: "Internal error: This function should not be | |
| 43 // called when 'x' is null.". | |
| 44 // | |
| 45 // 10. Prefer to not use imperative tone. That is, the message should not sound | |
| 46 // accusing or like it is ordering the user around. The computer should | |
| 47 // describe the problem, not criticize for violating the specification. | |
| 48 // | |
| 49 // Other things to keep in mind: | |
| 50 // | |
| 51 // An INFO message should always be preceded by a non-INFO message, and the | |
| 52 // INFO messages are additional details about the preceding non-INFO | |
| 53 // message. For example, consider duplicated elements. First report a WARNING | |
| 54 // or ERROR about the duplicated element, and then report an INFO about the | |
| 55 // location of the existing element. | |
| 56 // | |
| 57 // Generally, we want to provide messages that consists of three sentences: | |
| 58 // 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we | |
| 59 // combine the first two in [template] and the last in [howToFix]. | |
| 60 | |
| 61 /// Padding used before and between import chains in the message for | |
| 62 /// [MessageKind.IMPORT_EXPERIMENTAL_MIRRORS]. | |
| 63 const String IMPORT_EXPERIMENTAL_MIRRORS_PADDING = '\n* '; | |
| 64 | |
| 65 /// Padding used before and between import chains in the message for | |
| 66 /// [MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND]. | |
| 67 const String MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING = '\n '; | |
| 68 | |
| 69 /// Padding used before and between import chains in the message for | |
| 70 /// [MessageKind.DISALLOWED_LIBRARY_IMPORT]. | |
| 71 const String DISALLOWED_LIBRARY_IMPORT_PADDING = '\n '; | |
| 72 | |
| 73 const DONT_KNOW_HOW_TO_FIX = "Computer says no!"; | |
| 74 | |
| 75 final Map<String, Map> MESSAGES = { | |
| 76 /// Do not use this. It is here for legacy and debugging. It violates item | |
| 77 /// 4 of the guide lines for error messages in the beginning of the file. | |
| 78 'GENERIC': {'id': 'SOWPSL', 'template': "#{text}",}, | |
| 79 | |
| 80 'NOT_ASSIGNABLE': { | |
| 81 'id': 'VYNMAP', | |
| 82 'template': "'#{fromType}' is not assignable to '#{toType}'.", | |
| 83 }, | |
| 84 | |
| 85 'FORIN_NOT_ASSIGNABLE': { | |
| 86 'id': 'XQSRXO', | |
| 87 'template': "The element type '#{currentType}' of '#{expressionType}' " | |
| 88 "is not assignable to '#{elementType}'.", | |
| 89 }, | |
| 90 | |
| 91 'VOID_EXPRESSION': { | |
| 92 'id': 'QHEVSC', | |
| 93 'template': "Expression does not yield a value.", | |
| 94 }, | |
| 95 | |
| 96 'VOID_VARIABLE': { | |
| 97 'id': 'RFEURK', | |
| 98 'template': "Variable cannot be of type void.", | |
| 99 }, | |
| 100 | |
| 101 'RETURN_VALUE_IN_VOID': { | |
| 102 'id': 'FUNYDS', | |
| 103 'template': "Cannot return value from void function.", | |
| 104 }, | |
| 105 | |
| 106 'RETURN_NOTHING': { | |
| 107 'id': 'HPPODJ', | |
| 108 'template': "Value of type '#{returnType}' expected.", | |
| 109 }, | |
| 110 | |
| 111 'MISSING_ARGUMENT': { | |
| 112 'id': 'LHMCIK', | |
| 113 'template': "Missing argument of type '#{argumentType}'.", | |
| 114 }, | |
| 115 | |
| 116 'ADDITIONAL_ARGUMENT': {'id': 'GMITMA', 'template': "Additional argument.",}, | |
| 117 | |
| 118 'NAMED_ARGUMENT_NOT_FOUND': { | |
| 119 'id': 'UCEARQ', | |
| 120 'template': "No named argument '#{argumentName}' found on method.", | |
| 121 }, | |
| 122 | |
| 123 'MEMBER_NOT_FOUND': { | |
| 124 'id': 'MMQODC', | |
| 125 'template': "No member named '#{memberName}' in class '#{className}'.", | |
| 126 }, | |
| 127 | |
| 128 'AWAIT_MEMBER_NOT_FOUND': { | |
| 129 'id': 'XIDLIP', | |
| 130 'template': "No member named 'await' in class '#{className}'.", | |
| 131 'howToFix': "Did you mean to add the 'async' marker " | |
| 132 "to '#{functionName}'?", | |
| 133 'examples': [ | |
| 134 """ | |
| 135 class A { | |
| 136 m() => await -3; | |
| 137 } | |
| 138 main() => new A().m(); | |
| 139 """ | |
| 140 ], | |
| 141 }, | |
| 142 | |
| 143 'AWAIT_MEMBER_NOT_FOUND_IN_CLOSURE': { | |
| 144 'id': 'HBIYGN', | |
| 145 'template': "No member named 'await' in class '#{className}'.", | |
| 146 'howToFix': "Did you mean to add the 'async' marker " | |
| 147 "to the enclosing function?", | |
| 148 'examples': [ | |
| 149 """ | |
| 150 class A { | |
| 151 m() => () => await -3; | |
| 152 } | |
| 153 main() => new A().m(); | |
| 154 """ | |
| 155 ], | |
| 156 }, | |
| 157 | |
| 158 'METHOD_NOT_FOUND': { | |
| 159 'id': 'QYYHBU', | |
| 160 'template': "No method named '#{memberName}' in class '#{className}'.", | |
| 161 }, | |
| 162 | |
| 163 'OPERATOR_NOT_FOUND': { | |
| 164 'id': 'SXGOYS', | |
| 165 'template': "No operator '#{memberName}' in class '#{className}'.", | |
| 166 }, | |
| 167 | |
| 168 'SETTER_NOT_FOUND': { | |
| 169 'id': 'ADFRVF', | |
| 170 'template': "No setter named '#{memberName}' in class '#{className}'.", | |
| 171 }, | |
| 172 | |
| 173 'SETTER_NOT_FOUND_IN_SUPER': { | |
| 174 'id': 'OCVRNJ', | |
| 175 'template': "No setter named '#{name}' in superclass of '#{className}'.", | |
| 176 }, | |
| 177 | |
| 178 'GETTER_NOT_FOUND': { | |
| 179 'id': 'PBNXAC', | |
| 180 'template': "No getter named '#{memberName}' in class '#{className}'.", | |
| 181 }, | |
| 182 | |
| 183 'NOT_CALLABLE': { | |
| 184 'id': 'SEMKJO', | |
| 185 'template': "'#{elementName}' is not callable.", | |
| 186 }, | |
| 187 | |
| 188 'MEMBER_NOT_STATIC': { | |
| 189 'id': 'QIOISX', | |
| 190 'template': "'#{className}.#{memberName}' is not static.", | |
| 191 }, | |
| 192 | |
| 193 'NO_INSTANCE_AVAILABLE': { | |
| 194 'id': 'FQPYLR', | |
| 195 'template': "'#{name}' is only available in instance methods.", | |
| 196 }, | |
| 197 | |
| 198 'NO_THIS_AVAILABLE': { | |
| 199 'id': 'LXPXKG', | |
| 200 'template': "'this' is only available in instance methods.", | |
| 201 }, | |
| 202 | |
| 203 'PRIVATE_ACCESS': { | |
| 204 'id': 'DIMHCR', | |
| 205 'template': "'#{name}' is declared private within library " | |
| 206 "'#{libraryName}'.", | |
| 207 }, | |
| 208 | |
| 209 'THIS_IS_THE_DECLARATION': { | |
| 210 'id': 'YIJWTO', | |
| 211 'template': "This is the declaration of '#{name}'.", | |
| 212 }, | |
| 213 | |
| 214 'THIS_IS_THE_METHOD': { | |
| 215 'id': 'PYXWLF', | |
| 216 'template': "This is the method declaration.", | |
| 217 }, | |
| 218 | |
| 219 'CANNOT_RESOLVE': {'id': 'SPVJYO', 'template': "Cannot resolve '#{name}'.",}, | |
| 220 | |
| 221 'CANNOT_RESOLVE_AWAIT': { | |
| 222 'id': 'YQYLRS', | |
| 223 'template': "Cannot resolve '#{name}'.", | |
| 224 'howToFix': "Did you mean to add the 'async' marker " | |
| 225 "to '#{functionName}'?", | |
| 226 'examples': ["main() => await -3;", "foo() => await -3; main() => foo();"], | |
| 227 }, | |
| 228 | |
| 229 'CANNOT_RESOLVE_AWAIT_IN_CLOSURE': { | |
| 230 'id': 'SIXRAA', | |
| 231 'template': "Cannot resolve '#{name}'.", | |
| 232 'howToFix': "Did you mean to add the 'async' marker " | |
| 233 "to the enclosing function?", | |
| 234 'examples': ["main() { (() => await -3)(); }",], | |
| 235 }, | |
| 236 | |
| 237 'CANNOT_RESOLVE_IN_INITIALIZER': { | |
| 238 'id': 'VVEQFD', | |
| 239 'template': | |
| 240 "Cannot resolve '#{name}'. It would be implicitly looked up on this " | |
| 241 "instance, but instances are not available in initializers.", | |
| 242 'howToFix': "Try correcting the unresolved reference or move the " | |
| 243 "initialization to a constructor body.", | |
| 244 'examples': [ | |
| 245 """ | |
| 246 class A { | |
| 247 var test = unresolvedName; | |
| 248 } | |
| 249 main() => new A(); | |
| 250 """ | |
| 251 ], | |
| 252 }, | |
| 253 | |
| 254 'CANNOT_RESOLVE_CONSTRUCTOR': { | |
| 255 'id': 'QRPATN', | |
| 256 'template': "Cannot resolve constructor '#{constructorName}'.", | |
| 257 }, | |
| 258 | |
| 259 'CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT': { | |
| 260 'id': 'IFKCHF', | |
| 261 'template': "cannot resolve constructor '#{constructorName}' " | |
| 262 "for implicit super call.", | |
| 263 'howToFix': "Try explicitly invoking a constructor of the super class", | |
| 264 'examples': [ | |
| 265 """ | |
| 266 class A { | |
| 267 A.foo() {} | |
| 268 } | |
| 269 class B extends A { | |
| 270 B(); | |
| 271 } | |
| 272 main() => new B(); | |
| 273 """ | |
| 274 ], | |
| 275 }, | |
| 276 | |
| 277 'INVALID_UNNAMED_CONSTRUCTOR_NAME': { | |
| 278 'id': 'VPJLVI', | |
| 279 'template': "Unnamed constructor name must be '#{name}'.", | |
| 280 }, | |
| 281 | |
| 282 'INVALID_CONSTRUCTOR_NAME': { | |
| 283 'id': 'LMDCAS', | |
| 284 'template': "Constructor name must start with '#{name}'.", | |
| 285 }, | |
| 286 | |
| 287 'CANNOT_RESOLVE_TYPE': { | |
| 288 'id': 'PQIAPG', | |
| 289 'template': "Cannot resolve type '#{typeName}'.", | |
| 290 }, | |
| 291 | |
| 292 'DUPLICATE_DEFINITION': { | |
| 293 'id': 'LVTYNW', | |
| 294 'template': "Duplicate definition of '#{name}'.", | |
| 295 'howToFix': "Try to rename or remove this definition.", | |
| 296 'examples': [ | |
| 297 """ | |
| 298 class C { | |
| 299 void f() {} | |
| 300 int get f => 1; | |
| 301 } | |
| 302 | |
| 303 main() { | |
| 304 new C(); | |
| 305 } | |
| 306 | |
| 307 """ | |
| 308 ], | |
| 309 }, | |
| 310 | |
| 311 'EXISTING_DEFINITION': { | |
| 312 'id': 'DAUYKK', | |
| 313 'template': "Existing definition of '#{name}'.", | |
| 314 }, | |
| 315 | |
| 316 'DUPLICATE_IMPORT': { | |
| 317 'id': 'KYJFJN', | |
| 318 'template': "Duplicate import of '#{name}'.", | |
| 319 }, | |
| 320 | |
| 321 'HIDDEN_IMPORT': { | |
| 322 'id': 'ACRDPR', | |
| 323 'template': "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
| 324 "from library '#{hidingUri}'.", | |
| 325 'howToFix': "Try adding 'hide #{name}' to the import of '#{hiddenUri}'.", | |
| 326 'examples': [ | |
| 327 { | |
| 328 'main.dart': """ | |
| 329 import 'dart:async'; // This imports a class Future. | |
| 330 import 'future.dart'; | |
| 331 | |
| 332 void main() => new Future();""", | |
| 333 'future.dart': """ | |
| 334 library future; | |
| 335 | |
| 336 class Future {}""" | |
| 337 }, | |
| 338 { | |
| 339 'main.dart': """ | |
| 340 import 'future.dart'; | |
| 341 import 'dart:async'; // This imports a class Future. | |
| 342 | |
| 343 void main() => new Future();""", | |
| 344 'future.dart': """ | |
| 345 library future; | |
| 346 | |
| 347 class Future {}""" | |
| 348 }, | |
| 349 { | |
| 350 'main.dart': """ | |
| 351 import 'export.dart'; | |
| 352 import 'dart:async'; // This imports a class Future. | |
| 353 | |
| 354 void main() => new Future();""", | |
| 355 'future.dart': """ | |
| 356 library future; | |
| 357 | |
| 358 class Future {}""", | |
| 359 'export.dart': """ | |
| 360 library export; | |
| 361 | |
| 362 export 'future.dart';""" | |
| 363 }, | |
| 364 { | |
| 365 'main.dart': """ | |
| 366 import 'future.dart' as prefix; | |
| 367 import 'dart:async' as prefix; // This imports a class Future. | |
| 368 | |
| 369 void main() => new prefix.Future();""", | |
| 370 'future.dart': """ | |
| 371 library future; | |
| 372 | |
| 373 class Future {}""" | |
| 374 } | |
| 375 ], | |
| 376 }, | |
| 377 | |
| 378 'HIDDEN_IMPLICIT_IMPORT': { | |
| 379 'id': 'WDNFSI', | |
| 380 'template': "'#{name}' from library '#{hiddenUri}' is hidden by '#{name}' " | |
| 381 "from library '#{hidingUri}'.", | |
| 382 'howToFix': "Try adding an explicit " | |
| 383 "'import \"#{hiddenUri}\" hide #{name}'.", | |
| 384 'examples': [ | |
| 385 { | |
| 386 'main.dart': """ | |
| 387 // This hides the implicit import of class Type from dart:core. | |
| 388 import 'type.dart'; | |
| 389 | |
| 390 void main() => new Type();""", | |
| 391 'type.dart': """ | |
| 392 library type; | |
| 393 | |
| 394 class Type {}""" | |
| 395 }, | |
| 396 { | |
| 397 'conflictsWithDart.dart': """ | |
| 398 library conflictsWithDart; | |
| 399 | |
| 400 class Duration { | |
| 401 static var x = 100; | |
| 402 } | |
| 403 """, | |
| 404 'conflictsWithDartAsWell.dart': """ | |
| 405 library conflictsWithDartAsWell; | |
| 406 | |
| 407 class Duration { | |
| 408 static var x = 100; | |
| 409 } | |
| 410 """, | |
| 411 'main.dart': r""" | |
| 412 library testDartConflicts; | |
| 413 | |
| 414 import 'conflictsWithDart.dart'; | |
| 415 import 'conflictsWithDartAsWell.dart'; | |
| 416 | |
| 417 main() { | |
| 418 print("Hail Caesar ${Duration.x}"); | |
| 419 } | |
| 420 """ | |
| 421 } | |
| 422 ], | |
| 423 }, | |
| 424 | |
| 425 'DUPLICATE_EXPORT': { | |
| 426 'id': 'XGNOCL', | |
| 427 'template': "Duplicate export of '#{name}'.", | |
| 428 'howToFix': "Try adding 'hide #{name}' to one of the exports.", | |
| 429 'examples': [ | |
| 430 { | |
| 431 'main.dart': """ | |
| 432 export 'decl1.dart'; | |
| 433 export 'decl2.dart'; | |
| 434 | |
| 435 main() {}""", | |
| 436 'decl1.dart': "class Class {}", | |
| 437 'decl2.dart': "class Class {}" | |
| 438 } | |
| 439 ], | |
| 440 }, | |
| 441 | |
| 442 'DUPLICATE_EXPORT_CONT': { | |
| 443 'id': 'BDROED', | |
| 444 'template': "This is another export of '#{name}'.", | |
| 445 }, | |
| 446 | |
| 447 'DUPLICATE_EXPORT_DECL': { | |
| 448 'id': 'GFFLMA', | |
| 449 'template': | |
| 450 "The exported '#{name}' from export #{uriString} is defined here.", | |
| 451 }, | |
| 452 | |
| 453 'EMPTY_HIDE': { | |
| 454 'id': 'ODFAOC', | |
| 455 'template': "Library '#{uri}' doesn't export a '#{name}' declaration.", | |
| 456 'howToFix': "Try removing '#{name}' the 'hide' clause.", | |
| 457 'examples': [ | |
| 458 { | |
| 459 'main.dart': """ | |
| 460 import 'dart:core' hide Foo; | |
| 461 | |
| 462 main() {}""" | |
| 463 }, | |
| 464 { | |
| 465 'main.dart': """ | |
| 466 export 'dart:core' hide Foo; | |
| 467 | |
| 468 main() {}""" | |
| 469 }, | |
| 470 ], | |
| 471 }, | |
| 472 | |
| 473 'EMPTY_SHOW': { | |
| 474 'id': 'EXONIK', | |
| 475 'template': "Library '#{uri}' doesn't export a '#{name}' declaration.", | |
| 476 'howToFix': "Try removing '#{name}' from the 'show' clause.", | |
| 477 'examples': [ | |
| 478 { | |
| 479 'main.dart': """ | |
| 480 import 'dart:core' show Foo; | |
| 481 | |
| 482 main() {}""" | |
| 483 }, | |
| 484 { | |
| 485 'main.dart': """ | |
| 486 export 'dart:core' show Foo; | |
| 487 | |
| 488 main() {}""" | |
| 489 }, | |
| 490 ], | |
| 491 }, | |
| 492 | |
| 493 'NOT_A_TYPE': {'id': 'CTTAXD', 'template': "'#{node}' is not a type.",}, | |
| 494 | |
| 495 'NOT_A_PREFIX': {'id': 'LKEUMI', 'template': "'#{node}' is not a prefix.",}, | |
| 496 | |
| 497 'PREFIX_AS_EXPRESSION': { | |
| 498 'id': 'CYIMBJ', | |
| 499 'template': "Library prefix '#{prefix}' is not a valid expression.", | |
| 500 }, | |
| 501 | |
| 502 'CANNOT_FIND_CONSTRUCTOR': { | |
| 503 'id': 'DROVNH', | |
| 504 'template': "Cannot find constructor '#{constructorName}' in class " | |
| 505 "'#{className}'.", | |
| 506 }, | |
| 507 | |
| 508 'CANNOT_FIND_UNNAMED_CONSTRUCTOR': { | |
| 509 'id': 'GDCTGB', | |
| 510 'template': "Cannot find unnamed constructor in class " | |
| 511 "'#{className}'.", | |
| 512 }, | |
| 513 | |
| 514 'CYCLIC_CLASS_HIERARCHY': { | |
| 515 'id': 'HKFYOA', | |
| 516 'template': "'#{className}' creates a cycle in the class hierarchy.", | |
| 517 }, | |
| 518 | |
| 519 'CYCLIC_REDIRECTING_FACTORY': { | |
| 520 'id': 'QGETJC', | |
| 521 'template': "Redirecting factory leads to a cyclic redirection.", | |
| 522 }, | |
| 523 | |
| 524 'INVALID_RECEIVER_IN_INITIALIZER': { | |
| 525 'id': 'SYUTHA', | |
| 526 'template': "Field initializer expected.", | |
| 527 }, | |
| 528 | |
| 529 'NO_SUPER_IN_STATIC': { | |
| 530 'id': 'HSCESG', | |
| 531 'template': "'super' is only available in instance methods.", | |
| 532 }, | |
| 533 | |
| 534 'DUPLICATE_INITIALIZER': { | |
| 535 'id': 'GKVFEP', | |
| 536 'template': "Field '#{fieldName}' is initialized more than once.", | |
| 537 }, | |
| 538 | |
| 539 'ALREADY_INITIALIZED': { | |
| 540 'id': 'NCRMVD', | |
| 541 'template': "'#{fieldName}' was already initialized here.", | |
| 542 }, | |
| 543 | |
| 544 'INIT_STATIC_FIELD': { | |
| 545 'id': 'DBSRHA', | |
| 546 'template': "Cannot initialize static field '#{fieldName}'.", | |
| 547 }, | |
| 548 | |
| 549 'NOT_A_FIELD': { | |
| 550 'id': 'FYEPLC', | |
| 551 'template': "'#{fieldName}' is not a field.", | |
| 552 }, | |
| 553 | |
| 554 'CONSTRUCTOR_CALL_EXPECTED': { | |
| 555 'id': 'GEJCDX', | |
| 556 'template': "only call to 'this' or 'super' constructor allowed.", | |
| 557 }, | |
| 558 | |
| 559 'INVALID_FOR_IN': { | |
| 560 'id': 'AUQJBG', | |
| 561 'template': "Invalid for-in variable declaration.", | |
| 562 }, | |
| 563 | |
| 564 'INVALID_INITIALIZER': {'id': 'JKUKSA', 'template': "Invalid initializer.",}, | |
| 565 | |
| 566 'FUNCTION_WITH_INITIALIZER': { | |
| 567 'id': 'BNRDDK', | |
| 568 'template': "Only constructors can have initializers.", | |
| 569 }, | |
| 570 | |
| 571 'REDIRECTING_CONSTRUCTOR_CYCLE': { | |
| 572 'id': 'CQTMEP', | |
| 573 'template': "Cyclic constructor redirection.", | |
| 574 }, | |
| 575 | |
| 576 'REDIRECTING_CONSTRUCTOR_HAS_BODY': { | |
| 577 'id': 'WXJQNE', | |
| 578 'template': "Redirecting constructor can't have a body.", | |
| 579 }, | |
| 580 | |
| 581 'CONST_CONSTRUCTOR_HAS_BODY': { | |
| 582 'id': 'GNEFQG', | |
| 583 'template': "Const constructor or factory can't have a body.", | |
| 584 'howToFix': "Remove the 'const' keyword or the body", | |
| 585 'examples': [ | |
| 586 """ | |
| 587 class C { | |
| 588 const C() {} | |
| 589 } | |
| 590 | |
| 591 main() => new C();""" | |
| 592 ], | |
| 593 }, | |
| 594 | |
| 595 'REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER': { | |
| 596 'id': 'NUIDSF', | |
| 597 'template': "Redirecting constructor cannot have other initializers.", | |
| 598 }, | |
| 599 | |
| 600 'SUPER_INITIALIZER_IN_OBJECT': { | |
| 601 'id': 'DXYGND', | |
| 602 'template': "'Object' cannot have a super initializer.", | |
| 603 }, | |
| 604 | |
| 605 'DUPLICATE_SUPER_INITIALIZER': { | |
| 606 'id': 'FFKOWP', | |
| 607 'template': "Cannot have more than one super initializer.", | |
| 608 }, | |
| 609 | |
| 610 'SUPER_CALL_TO_FACTORY': { | |
| 611 'id': 'YTOWGV', | |
| 612 'template': "The target of the superinitializer must be a generative " | |
| 613 "constructor.", | |
| 614 'howToFix': "Try calling another constructor on the superclass.", | |
| 615 'examples': [ | |
| 616 """ | |
| 617 class Super { | |
| 618 factory Super() => null; | |
| 619 } | |
| 620 class Class extends Super {} | |
| 621 main() => new Class(); | |
| 622 """, | |
| 623 """ | |
| 624 class Super { | |
| 625 factory Super() => null; | |
| 626 } | |
| 627 class Class extends Super { | |
| 628 Class(); | |
| 629 } | |
| 630 main() => new Class(); | |
| 631 """, | |
| 632 """ | |
| 633 class Super { | |
| 634 factory Super() => null; | |
| 635 } | |
| 636 class Class extends Super { | |
| 637 Class() : super(); | |
| 638 } | |
| 639 main() => new Class(); | |
| 640 """, | |
| 641 """ | |
| 642 class Super { | |
| 643 factory Super.foo() => null; | |
| 644 } | |
| 645 class Class extends Super { | |
| 646 Class() : super.foo(); | |
| 647 } | |
| 648 main() => new Class(); | |
| 649 """ | |
| 650 ], | |
| 651 }, | |
| 652 | |
| 653 'THIS_CALL_TO_FACTORY': { | |
| 654 'id': 'JLATDB', | |
| 655 'template': "The target of the redirection clause must be a generative " | |
| 656 "constructor", | |
| 657 'howToFix': "Try redirecting to another constructor.", | |
| 658 'examples': [ | |
| 659 """ | |
| 660 class Class { | |
| 661 factory Class() => null; | |
| 662 Class.foo() : this(); | |
| 663 } | |
| 664 main() => new Class.foo(); | |
| 665 """, | |
| 666 """ | |
| 667 class Class { | |
| 668 factory Class.foo() => null; | |
| 669 Class() : this.foo(); | |
| 670 } | |
| 671 main() => new Class(); | |
| 672 """ | |
| 673 ], | |
| 674 }, | |
| 675 | |
| 676 'INVALID_CONSTRUCTOR_ARGUMENTS': { | |
| 677 'id': 'WVPLKL', | |
| 678 'template': "Arguments do not match the expected parameters of constructor " | |
| 679 "'#{constructorName}'.", | |
| 680 }, | |
| 681 | |
| 682 'NO_MATCHING_CONSTRUCTOR': { | |
| 683 'id': 'OJQQLE', | |
| 684 'template': | |
| 685 "'super' call arguments and constructor parameters do not match.", | |
| 686 }, | |
| 687 | |
| 688 'NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT': { | |
| 689 'id': 'WHCVID', | |
| 690 'template': "Implicit 'super' call arguments and constructor parameters " | |
| 691 "do not match.", | |
| 692 }, | |
| 693 | |
| 694 'CONST_CALLS_NON_CONST': { | |
| 695 'id': 'CQFHXC', | |
| 696 'template': "'const' constructor cannot call a non-const constructor.", | |
| 697 }, | |
| 698 | |
| 699 'CONST_CALLS_NON_CONST_FOR_IMPLICIT': { | |
| 700 'id': 'SFCEXS', | |
| 701 'template': "'const' constructor cannot call a non-const constructor. " | |
| 702 "This constructor has an implicit call to a " | |
| 703 "super non-const constructor.", | |
| 704 'howToFix': "Try making the super constructor const.", | |
| 705 'examples': [ | |
| 706 """ | |
| 707 class C { | |
| 708 C(); // missing const | |
| 709 } | |
| 710 class D extends C { | |
| 711 final d; | |
| 712 const D(this.d); | |
| 713 } | |
| 714 main() => new D(0);""" | |
| 715 ], | |
| 716 }, | |
| 717 | |
| 718 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS': { | |
| 719 'id': 'XBHUDL', | |
| 720 'template': "Can't declare constructor 'const' on class #{className} " | |
| 721 "because the class contains non-final instance fields.", | |
| 722 'howToFix': "Try making all fields final.", | |
| 723 'examples': [ | |
| 724 """ | |
| 725 class C { | |
| 726 // 'a' must be declared final to allow for the const constructor. | |
| 727 var a; | |
| 728 const C(this.a); | |
| 729 } | |
| 730 | |
| 731 main() => new C(0);""" | |
| 732 ], | |
| 733 }, | |
| 734 | |
| 735 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD': { | |
| 736 'id': 'YYAHVD', | |
| 737 'template': "This non-final field prevents using const constructors.", | |
| 738 }, | |
| 739 | |
| 740 'CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR': { | |
| 741 'id': 'FROWJB', | |
| 742 'template': "This const constructor is not allowed due to " | |
| 743 "non-final fields.", | |
| 744 }, | |
| 745 | |
| 746 'INITIALIZING_FORMAL_NOT_ALLOWED': { | |
| 747 'id': 'YIPXYP', | |
| 748 'template': "Initializing formal parameter only allowed in generative " | |
| 749 "constructor.", | |
| 750 }, | |
| 751 | |
| 752 'INVALID_PARAMETER': { | |
| 753 'id': 'OWWLIX', | |
| 754 'template': "Cannot resolve parameter.", | |
| 755 }, | |
| 756 | |
| 757 'NOT_INSTANCE_FIELD': { | |
| 758 'id': 'VSPKMU', | |
| 759 'template': "'#{fieldName}' is not an instance field.", | |
| 760 }, | |
| 761 | |
| 762 'THIS_PROPERTY': {'id': 'MWFIGH', 'template': "Expected an identifier.",}, | |
| 763 | |
| 764 'NO_CATCH_NOR_FINALLY': { | |
| 765 'id': 'OPJXPP', | |
| 766 'template': "Expected 'catch' or 'finally'.", | |
| 767 }, | |
| 768 | |
| 769 'EMPTY_CATCH_DECLARATION': { | |
| 770 'id': 'UNHCPY', | |
| 771 'template': "Expected an identifier in catch declaration.", | |
| 772 }, | |
| 773 | |
| 774 'EXTRA_CATCH_DECLARATION': { | |
| 775 'id': 'YGGRAK', | |
| 776 'template': "Extra parameter in catch declaration.", | |
| 777 }, | |
| 778 | |
| 779 'PARAMETER_WITH_TYPE_IN_CATCH': { | |
| 780 'id': 'EXQVDU', | |
| 781 'template': "Cannot use type annotations in catch.", | |
| 782 }, | |
| 783 | |
| 784 'PARAMETER_WITH_MODIFIER_IN_CATCH': { | |
| 785 'id': 'BQLKRF', | |
| 786 'template': "Cannot use modifiers in catch.", | |
| 787 }, | |
| 788 | |
| 789 'OPTIONAL_PARAMETER_IN_CATCH': { | |
| 790 'id': 'DAICPP', | |
| 791 'template': "Cannot use optional parameters in catch.", | |
| 792 }, | |
| 793 | |
| 794 'THROW_WITHOUT_EXPRESSION': { | |
| 795 'id': 'YHACYV', | |
| 796 'template': "Cannot use re-throw outside of catch block " | |
| 797 "(expression expected after 'throw').", | |
| 798 }, | |
| 799 | |
| 800 'UNBOUND_LABEL': { | |
| 801 'id': 'GLDXHY', | |
| 802 'template': "Cannot resolve label '#{labelName}'.", | |
| 803 }, | |
| 804 | |
| 805 'NO_BREAK_TARGET': { | |
| 806 'id': 'VBXXBE', | |
| 807 'template': "'break' statement not inside switch or loop.", | |
| 808 }, | |
| 809 | |
| 810 'NO_CONTINUE_TARGET': { | |
| 811 'id': 'JTTHHM', | |
| 812 'template': "'continue' statement not inside loop.", | |
| 813 }, | |
| 814 | |
| 815 'EXISTING_LABEL': { | |
| 816 'id': 'AHCSXF', | |
| 817 'template': "Original declaration of duplicate label '#{labelName}'.", | |
| 818 }, | |
| 819 | |
| 820 'DUPLICATE_LABEL': { | |
| 821 'id': 'HPULLI', | |
| 822 'template': "Duplicate declaration of label '#{labelName}'.", | |
| 823 }, | |
| 824 | |
| 825 'UNUSED_LABEL': {'id': 'KFREJO', 'template': "Unused label '#{labelName}'.",}, | |
| 826 | |
| 827 'INVALID_CONTINUE': { | |
| 828 'id': 'DSKTPX', | |
| 829 'template': "Target of continue is not a loop or switch case.", | |
| 830 }, | |
| 831 | |
| 832 'INVALID_BREAK': { | |
| 833 'id': 'MFCCWX', | |
| 834 'template': "Target of break is not a statement.", | |
| 835 }, | |
| 836 | |
| 837 'DUPLICATE_TYPE_VARIABLE_NAME': { | |
| 838 'id': 'BAYCCM', | |
| 839 'template': "Type variable '#{typeVariableName}' already declared.", | |
| 840 }, | |
| 841 | |
| 842 'TYPE_VARIABLE_WITHIN_STATIC_MEMBER': { | |
| 843 'id': 'XQLXRL', | |
| 844 'template': "Cannot refer to type variable '#{typeVariableName}' " | |
| 845 "within a static member.", | |
| 846 }, | |
| 847 | |
| 848 'TYPE_VARIABLE_IN_CONSTANT': { | |
| 849 'id': 'ANDEVG', | |
| 850 'template': "Constant expressions can't refer to type variables.", | |
| 851 'howToFix': "Try removing the type variable or replacing it with a " | |
| 852 "concrete type.", | |
| 853 'examples': [ | |
| 854 """ | |
| 855 class C<T> { | |
| 856 const C(); | |
| 857 | |
| 858 m(T t) => const C<T>(); | |
| 859 } | |
| 860 | |
| 861 void main() => new C().m(null); | |
| 862 """ | |
| 863 ], | |
| 864 }, | |
| 865 | |
| 866 'INVALID_TYPE_VARIABLE_BOUND': { | |
| 867 'id': 'WQAEDK', | |
| 868 'template': "'#{typeArgument}' is not a subtype of bound '#{bound}' for " | |
| 869 "type variable '#{typeVariable}' of type '#{thisType}'.", | |
| 870 'howToFix': "Try to change or remove the type argument.", | |
| 871 'examples': [ | |
| 872 """ | |
| 873 class C<T extends num> {} | |
| 874 | |
| 875 // 'String' is not a valid instantiation of T with bound num.'. | |
| 876 main() => new C<String>(); | |
| 877 """ | |
| 878 ], | |
| 879 }, | |
| 880 | |
| 881 'INVALID_USE_OF_SUPER': { | |
| 882 'id': 'JKYYSN', | |
| 883 'template': "'super' not allowed here.", | |
| 884 }, | |
| 885 | |
| 886 'INVALID_CASE_DEFAULT': { | |
| 887 'id': 'ABSPBM', | |
| 888 'template': "'default' only allowed on last case of a switch.", | |
| 889 }, | |
| 890 | |
| 891 'SWITCH_CASE_TYPES_NOT_EQUAL': { | |
| 892 'id': 'UFQPBC', | |
| 893 'template': "'case' expressions do not all have type '#{type}'.", | |
| 894 }, | |
| 895 | |
| 896 'SWITCH_CASE_TYPES_NOT_EQUAL_CASE': { | |
| 897 'id': 'RDMVAC', | |
| 898 'template': "'case' expression of type '#{type}'.", | |
| 899 }, | |
| 900 | |
| 901 'SWITCH_CASE_FORBIDDEN': { | |
| 902 'id': 'UHSCSU', | |
| 903 'template': "'case' expression may not be of type '#{type}'.", | |
| 904 }, | |
| 905 | |
| 906 'SWITCH_CASE_VALUE_OVERRIDES_EQUALS': { | |
| 907 'id': 'NRTWXL', | |
| 908 'template': "'case' expression type '#{type}' overrides 'operator =='.", | |
| 909 }, | |
| 910 | |
| 911 'INVALID_ARGUMENT_AFTER_NAMED': { | |
| 912 'id': 'WAJURC', | |
| 913 'template': "Unnamed argument after named argument.", | |
| 914 }, | |
| 915 | |
| 916 'NOT_A_COMPILE_TIME_CONSTANT': { | |
| 917 'id': 'SBCHWL', | |
| 918 'template': "Not a compile-time constant.", | |
| 919 }, | |
| 920 | |
| 921 'DEFERRED_COMPILE_TIME_CONSTANT': { | |
| 922 'id': 'FHXTCK', | |
| 923 'template': "A deferred value cannot be used as a compile-time constant.", | |
| 924 }, | |
| 925 | |
| 926 'DEFERRED_COMPILE_TIME_CONSTANT_CONSTRUCTION': { | |
| 927 'id': 'TSBXLG', | |
| 928 'template': "A deferred class cannot be used to create a " | |
| 929 "compile-time constant.", | |
| 930 }, | |
| 931 | |
| 932 'CYCLIC_COMPILE_TIME_CONSTANTS': { | |
| 933 'id': 'JJWJYE', | |
| 934 'template': "Cycle in the compile-time constant computation.", | |
| 935 }, | |
| 936 | |
| 937 'CONSTRUCTOR_IS_NOT_CONST': { | |
| 938 'id': 'DOJCUX', | |
| 939 'template': "Constructor is not a 'const' constructor.", | |
| 940 }, | |
| 941 | |
| 942 'CONST_MAP_KEY_OVERRIDES_EQUALS': { | |
| 943 'id': 'VJNWEL', | |
| 944 'template': "Const-map key type '#{type}' overrides 'operator =='.", | |
| 945 }, | |
| 946 | |
| 947 'NO_SUCH_LIBRARY_MEMBER': { | |
| 948 'id': 'IOXVBA', | |
| 949 'template': "'#{libraryName}' has no member named '#{memberName}'.", | |
| 950 }, | |
| 951 | |
| 952 'CANNOT_INSTANTIATE_TYPEDEF': { | |
| 953 'id': 'KOYNMU', | |
| 954 'template': "Cannot instantiate typedef '#{typedefName}'.", | |
| 955 }, | |
| 956 | |
| 957 'REQUIRED_PARAMETER_WITH_DEFAULT': { | |
| 958 'id': 'CJWECI', | |
| 959 'template': "Non-optional parameters can't have a default value.", | |
| 960 'howToFix': | |
| 961 "Try removing the default value or making the parameter optional.", | |
| 962 'examples': [ | |
| 963 """ | |
| 964 main() { | |
| 965 foo(a: 1) => print(a); | |
| 966 foo(2); | |
| 967 }""", | |
| 968 """ | |
| 969 main() { | |
| 970 foo(a = 1) => print(a); | |
| 971 foo(2); | |
| 972 }""" | |
| 973 ], | |
| 974 }, | |
| 975 | |
| 976 'NAMED_PARAMETER_WITH_EQUALS': { | |
| 977 'id': 'RPJDXD', | |
| 978 'template': "Named optional parameters can't use '=' to specify a default " | |
| 979 "value.", | |
| 980 'howToFix': "Try replacing '=' with ':'.", | |
| 981 'examples': [ | |
| 982 """ | |
| 983 main() { | |
| 984 foo({a = 1}) => print(a); | |
| 985 foo(a: 2); | |
| 986 }""" | |
| 987 ], | |
| 988 }, | |
| 989 | |
| 990 'POSITIONAL_PARAMETER_WITH_EQUALS': { | |
| 991 'id': 'JMSSDX', | |
| 992 'template': "Positional optional parameters can't use ':' to specify a " | |
| 993 "default value.", | |
| 994 'howToFix': "Try replacing ':' with '='.", | |
| 995 'examples': [ | |
| 996 """ | |
| 997 main() { | |
| 998 foo([a: 1]) => print(a); | |
| 999 foo(2); | |
| 1000 }""" | |
| 1001 ], | |
| 1002 }, | |
| 1003 | |
| 1004 'TYPEDEF_FORMAL_WITH_DEFAULT': { | |
| 1005 'id': 'NABHHS', | |
| 1006 'template': "A parameter of a typedef can't specify a default value.", | |
| 1007 'howToFix': "Try removing the default value.", | |
| 1008 'examples': [ | |
| 1009 """ | |
| 1010 typedef void F([int arg = 0]); | |
| 1011 | |
| 1012 main() { | |
| 1013 F f; | |
| 1014 }""", | |
| 1015 """ | |
| 1016 typedef void F({int arg: 0}); | |
| 1017 | |
| 1018 main() { | |
| 1019 F f; | |
| 1020 }""" | |
| 1021 ], | |
| 1022 }, | |
| 1023 | |
| 1024 'FUNCTION_TYPE_FORMAL_WITH_DEFAULT': { | |
| 1025 'id': 'APKYLU', | |
| 1026 'template': "A function type parameter can't specify a default value.", | |
| 1027 'howToFix': "Try removing the default value.", | |
| 1028 'examples': [ | |
| 1029 """ | |
| 1030 foo(f(int i, [a = 1])) {} | |
| 1031 | |
| 1032 main() { | |
| 1033 foo(1, 2); | |
| 1034 }""", | |
| 1035 """ | |
| 1036 foo(f(int i, {a: 1})) {} | |
| 1037 | |
| 1038 main() { | |
| 1039 foo(1, a: 2); | |
| 1040 }""" | |
| 1041 ], | |
| 1042 }, | |
| 1043 | |
| 1044 'REDIRECTING_FACTORY_WITH_DEFAULT': { | |
| 1045 'id': 'AWSSEY', | |
| 1046 'template': | |
| 1047 "A parameter of a redirecting factory constructor can't specify a " | |
| 1048 "default value.", | |
| 1049 'howToFix': "Try removing the default value.", | |
| 1050 'examples': [ | |
| 1051 """ | |
| 1052 class A { | |
| 1053 A([a]); | |
| 1054 factory A.foo([a = 1]) = A; | |
| 1055 } | |
| 1056 | |
| 1057 main() { | |
| 1058 new A.foo(1); | |
| 1059 }""", | |
| 1060 """ | |
| 1061 class A { | |
| 1062 A({a}); | |
| 1063 factory A.foo({a: 1}) = A; | |
| 1064 } | |
| 1065 | |
| 1066 main() { | |
| 1067 new A.foo(a: 1); | |
| 1068 }""" | |
| 1069 ], | |
| 1070 }, | |
| 1071 | |
| 1072 'FORMAL_DECLARED_CONST': { | |
| 1073 'id': 'AVPRDK', | |
| 1074 'template': "A formal parameter can't be declared const.", | |
| 1075 'howToFix': "Try removing 'const'.", | |
| 1076 'examples': [ | |
| 1077 """ | |
| 1078 foo(const x) {} | |
| 1079 main() => foo(42); | |
| 1080 """, | |
| 1081 """ | |
| 1082 foo({const x}) {} | |
| 1083 main() => foo(42); | |
| 1084 """, | |
| 1085 """ | |
| 1086 foo([const x]) {} | |
| 1087 main() => foo(42); | |
| 1088 """ | |
| 1089 ], | |
| 1090 }, | |
| 1091 | |
| 1092 'FORMAL_DECLARED_STATIC': { | |
| 1093 'id': 'PJKDMX', | |
| 1094 'template': "A formal parameter can't be declared static.", | |
| 1095 'howToFix': "Try removing 'static'.", | |
| 1096 'examples': [ | |
| 1097 """ | |
| 1098 foo(static x) {} | |
| 1099 main() => foo(42); | |
| 1100 """, | |
| 1101 """ | |
| 1102 foo({static x}) {} | |
| 1103 main() => foo(42); | |
| 1104 """, | |
| 1105 """ | |
| 1106 foo([static x]) {} | |
| 1107 main() => foo(42); | |
| 1108 """ | |
| 1109 ], | |
| 1110 }, | |
| 1111 | |
| 1112 'FINAL_FUNCTION_TYPE_PARAMETER': { | |
| 1113 'id': 'JIOPIQ', | |
| 1114 'template': "A function type parameter can't be declared final.", | |
| 1115 'howToFix': "Try removing 'final'.", | |
| 1116 'examples': [ | |
| 1117 """ | |
| 1118 foo(final int x(int a)) {} | |
| 1119 main() => foo((y) => 42); | |
| 1120 """, | |
| 1121 """ | |
| 1122 foo({final int x(int a)}) {} | |
| 1123 main() => foo((y) => 42); | |
| 1124 """, | |
| 1125 """ | |
| 1126 foo([final int x(int a)]) {} | |
| 1127 main() => foo((y) => 42); | |
| 1128 """ | |
| 1129 ], | |
| 1130 }, | |
| 1131 | |
| 1132 'VAR_FUNCTION_TYPE_PARAMETER': { | |
| 1133 'id': 'FOQOHK', | |
| 1134 'template': "A function type parameter can't be declared with 'var'.", | |
| 1135 'howToFix': "Try removing 'var'.", | |
| 1136 'examples': [ | |
| 1137 """ | |
| 1138 foo(var int x(int a)) {} | |
| 1139 main() => foo((y) => 42); | |
| 1140 """, | |
| 1141 """ | |
| 1142 foo({var int x(int a)}) {} | |
| 1143 main() => foo((y) => 42); | |
| 1144 """, | |
| 1145 """ | |
| 1146 foo([var int x(int a)]) {} | |
| 1147 main() => foo((y) => 42); | |
| 1148 """ | |
| 1149 ], | |
| 1150 }, | |
| 1151 | |
| 1152 'CANNOT_INSTANTIATE_TYPE_VARIABLE': { | |
| 1153 'id': 'JAYHCH', | |
| 1154 'template': "Cannot instantiate type variable '#{typeVariableName}'.", | |
| 1155 }, | |
| 1156 | |
| 1157 'CYCLIC_TYPE_VARIABLE': { | |
| 1158 'id': 'RQMPSO', | |
| 1159 'template': "Type variable '#{typeVariableName}' is a supertype of itself.", | |
| 1160 }, | |
| 1161 | |
| 1162 'CYCLIC_TYPEDEF': { | |
| 1163 'id': 'VFERCQ', | |
| 1164 'template': "A typedef can't refer to itself.", | |
| 1165 'howToFix': "Try removing all references to '#{typedefName}' " | |
| 1166 "in the definition of '#{typedefName}'.", | |
| 1167 'examples': [ | |
| 1168 """ | |
| 1169 typedef F F(); // The return type 'F' is a self-reference. | |
| 1170 main() { F f = null; }""" | |
| 1171 ], | |
| 1172 }, | |
| 1173 | |
| 1174 'CYCLIC_TYPEDEF_ONE': { | |
| 1175 'id': 'ASWLWR', | |
| 1176 'template': "A typedef can't refer to itself through another typedef.", | |
| 1177 'howToFix': "Try removing all references to " | |
| 1178 "'#{otherTypedefName}' in the definition of '#{typedefName}'.", | |
| 1179 'examples': [ | |
| 1180 """ | |
| 1181 typedef G F(); // The return type 'G' is a self-reference through typedef 'G'. | |
| 1182 typedef F G(); // The return type 'F' is a self-reference through typedef 'F'. | |
| 1183 main() { F f = null; }""", | |
| 1184 """ | |
| 1185 typedef G F(); // The return type 'G' creates a self-reference. | |
| 1186 typedef H G(); // The return type 'H' creates a self-reference. | |
| 1187 typedef H(F f); // The argument type 'F' creates a self-reference. | |
| 1188 main() { F f = null; }""" | |
| 1189 ], | |
| 1190 }, | |
| 1191 | |
| 1192 'CLASS_NAME_EXPECTED': {'id': 'DPKNHY', 'template': "Class name expected.",}, | |
| 1193 | |
| 1194 'CANNOT_EXTEND': { | |
| 1195 'id': 'GCIQXD', | |
| 1196 'template': "'#{type}' cannot be extended.", | |
| 1197 }, | |
| 1198 | |
| 1199 'CANNOT_IMPLEMENT': { | |
| 1200 'id': 'IBOQKV', | |
| 1201 'template': "'#{type}' cannot be implemented.", | |
| 1202 }, | |
| 1203 | |
| 1204 // TODO(johnnwinther): Split messages into reasons for malformedness. | |
| 1205 'CANNOT_EXTEND_MALFORMED': { | |
| 1206 'id': 'YPFJBD', | |
| 1207 'template': "Class '#{className}' can't extend the type '#{malformedType}' " | |
| 1208 "because it is malformed.", | |
| 1209 'howToFix': "Try correcting the malformed type annotation or removing the " | |
| 1210 "'extends' clause.", | |
| 1211 'examples': [ | |
| 1212 """ | |
| 1213 class A extends Malformed {} | |
| 1214 main() => new A();""" | |
| 1215 ], | |
| 1216 }, | |
| 1217 | |
| 1218 'CANNOT_IMPLEMENT_MALFORMED': { | |
| 1219 'id': 'XJUIAQ', | |
| 1220 'template': | |
| 1221 "Class '#{className}' can't implement the type '#{malformedType}' " | |
| 1222 "because it is malformed.", | |
| 1223 'howToFix': "Try correcting the malformed type annotation or removing the " | |
| 1224 "type from the 'implements' clause.", | |
| 1225 'examples': [ | |
| 1226 """ | |
| 1227 class A implements Malformed {} | |
| 1228 main() => new A();""" | |
| 1229 ], | |
| 1230 }, | |
| 1231 | |
| 1232 'CANNOT_MIXIN_MALFORMED': { | |
| 1233 'id': 'SSMNXN', | |
| 1234 'template': "Class '#{className}' can't mixin the type '#{malformedType}' " | |
| 1235 "because it is malformed.", | |
| 1236 'howToFix': "Try correcting the malformed type annotation or removing the " | |
| 1237 "type from the 'with' clause.", | |
| 1238 'examples': [ | |
| 1239 """ | |
| 1240 class A extends Object with Malformed {} | |
| 1241 main() => new A();""" | |
| 1242 ], | |
| 1243 }, | |
| 1244 | |
| 1245 'CANNOT_MIXIN': { | |
| 1246 'id': 'KLSXDQ', | |
| 1247 'template': "The type '#{type}' can't be mixed in.", | |
| 1248 'howToFix': "Try removing '#{type}' from the 'with' clause.", | |
| 1249 'examples': [ | |
| 1250 """ | |
| 1251 class C extends Object with String {} | |
| 1252 | |
| 1253 main() => new C(); | |
| 1254 """, | |
| 1255 """ | |
| 1256 typedef C = Object with String; | |
| 1257 | |
| 1258 main() => new C(); | |
| 1259 """ | |
| 1260 ], | |
| 1261 }, | |
| 1262 | |
| 1263 'CANNOT_EXTEND_ENUM': { | |
| 1264 'id': 'JEPRST', | |
| 1265 'template': | |
| 1266 "Class '#{className}' can't extend the type '#{enumType}' because " | |
| 1267 "it is declared by an enum.", | |
| 1268 'howToFix': "Try making '#{enumType}' a normal class or removing the " | |
| 1269 "'extends' clause.", | |
| 1270 'examples': [ | |
| 1271 """ | |
| 1272 enum Enum { A } | |
| 1273 class B extends Enum {} | |
| 1274 main() => new B();""" | |
| 1275 ], | |
| 1276 }, | |
| 1277 | |
| 1278 'CANNOT_IMPLEMENT_ENUM': { | |
| 1279 'id': 'JMJMSH', | |
| 1280 'template': "Class '#{className}' can't implement the type '#{enumType}' " | |
| 1281 "because it is declared by an enum.", | |
| 1282 'howToFix': "Try making '#{enumType}' a normal class or removing the " | |
| 1283 "type from the 'implements' clause.", | |
| 1284 'examples': [ | |
| 1285 """ | |
| 1286 enum Enum { A } | |
| 1287 class B implements Enum {} | |
| 1288 main() => new B();""" | |
| 1289 ], | |
| 1290 }, | |
| 1291 | |
| 1292 'CANNOT_MIXIN_ENUM': { | |
| 1293 'id': 'YSYDIM', | |
| 1294 'template': | |
| 1295 "Class '#{className}' can't mixin the type '#{enumType}' because it " | |
| 1296 "is declared by an enum.", | |
| 1297 'howToFix': "Try making '#{enumType}' a normal class or removing the " | |
| 1298 "type from the 'with' clause.", | |
| 1299 'examples': [ | |
| 1300 """ | |
| 1301 enum Enum { A } | |
| 1302 class B extends Object with Enum {} | |
| 1303 main() => new B();""" | |
| 1304 ], | |
| 1305 }, | |
| 1306 | |
| 1307 'CANNOT_INSTANTIATE_ENUM': { | |
| 1308 'id': 'CQYIFU', | |
| 1309 'template': "Enum type '#{enumName}' cannot be instantiated.", | |
| 1310 'howToFix': "Try making '#{enumType}' a normal class or use an enum " | |
| 1311 "constant.", | |
| 1312 'examples': [ | |
| 1313 """ | |
| 1314 enum Enum { A } | |
| 1315 main() => new Enum(0);""", | |
| 1316 """ | |
| 1317 enum Enum { A } | |
| 1318 main() => const Enum(0);""" | |
| 1319 ], | |
| 1320 }, | |
| 1321 | |
| 1322 'EMPTY_ENUM_DECLARATION': { | |
| 1323 'id': 'JFPDOH', | |
| 1324 'template': "Enum '#{enumName}' must contain at least one value.", | |
| 1325 'howToFix': "Try adding an enum constant or making #{enumName} a " | |
| 1326 "normal class.", | |
| 1327 'examples': [ | |
| 1328 """ | |
| 1329 enum Enum {} | |
| 1330 main() { Enum e; }""" | |
| 1331 ], | |
| 1332 }, | |
| 1333 | |
| 1334 'MISSING_ENUM_CASES': { | |
| 1335 'id': 'HHEOIW', | |
| 1336 'template': "Missing enum constants in switch statement: #{enumValues}.", | |
| 1337 'howToFix': "Try adding the missing constants or a default case.", | |
| 1338 'examples': [ | |
| 1339 """ | |
| 1340 enum Enum { A, B } | |
| 1341 main() { | |
| 1342 switch (Enum.A) { | |
| 1343 case Enum.B: break; | |
| 1344 } | |
| 1345 }""", | |
| 1346 """ | |
| 1347 enum Enum { A, B, C } | |
| 1348 main() { | |
| 1349 switch (Enum.A) { | |
| 1350 case Enum.B: break; | |
| 1351 } | |
| 1352 }""" | |
| 1353 ], | |
| 1354 }, | |
| 1355 | |
| 1356 'DUPLICATE_EXTENDS_IMPLEMENTS': { | |
| 1357 'id': 'BKRKEO', | |
| 1358 'template': "'#{type}' can not be both extended and implemented.", | |
| 1359 }, | |
| 1360 | |
| 1361 'DUPLICATE_IMPLEMENTS': { | |
| 1362 'id': 'IWJFTU', | |
| 1363 'template': "'#{type}' must not occur more than once " | |
| 1364 "in the implements clause.", | |
| 1365 }, | |
| 1366 | |
| 1367 'MULTI_INHERITANCE': { | |
| 1368 'id': 'NWXGOI', | |
| 1369 'template': | |
| 1370 "Dart2js does not currently support inheritance of the same class " | |
| 1371 "with different type arguments: Both #{firstType} and #{secondType} " | |
| 1372 "are supertypes of #{thisType}.", | |
| 1373 }, | |
| 1374 | |
| 1375 'ILLEGAL_SUPER_SEND': { | |
| 1376 'id': 'LDRGIU', | |
| 1377 'template': "'#{name}' cannot be called on super.", | |
| 1378 }, | |
| 1379 | |
| 1380 'NO_SUCH_SUPER_MEMBER': { | |
| 1381 'id': 'HIJJVG', | |
| 1382 'template': | |
| 1383 "Cannot resolve '#{memberName}' in a superclass of '#{className}'.", | |
| 1384 }, | |
| 1385 | |
| 1386 'ADDITIONAL_TYPE_ARGUMENT': { | |
| 1387 'id': 'HWYHWH', | |
| 1388 'template': "Additional type argument.", | |
| 1389 }, | |
| 1390 | |
| 1391 'MISSING_TYPE_ARGUMENT': { | |
| 1392 'id': 'KYTQWA', | |
| 1393 'template': "Missing type argument.", | |
| 1394 }, | |
| 1395 | |
| 1396 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or | |
| 1397 // MISSING_TYPE_ARGUMENT instead. | |
| 1398 'TYPE_ARGUMENT_COUNT_MISMATCH': { | |
| 1399 'id': 'ECXGRM', | |
| 1400 'template': "Incorrect number of type arguments on '#{type}'.", | |
| 1401 }, | |
| 1402 | |
| 1403 'GETTER_MISMATCH': { | |
| 1404 'id': 'MNODFW', | |
| 1405 'template': "Setter disagrees on: '#{modifiers}'.", | |
| 1406 }, | |
| 1407 | |
| 1408 'SETTER_MISMATCH': { | |
| 1409 'id': 'FMNHPL', | |
| 1410 'template': "Getter disagrees on: '#{modifiers}'.", | |
| 1411 }, | |
| 1412 | |
| 1413 'ILLEGAL_SETTER_FORMALS': { | |
| 1414 'id': 'COTPVN', | |
| 1415 'template': "A setter must have exactly one argument.", | |
| 1416 }, | |
| 1417 | |
| 1418 'NO_STATIC_OVERRIDE': { | |
| 1419 'id': 'EHINXB', | |
| 1420 'template': | |
| 1421 "Static member cannot override instance member '#{memberName}' of " | |
| 1422 "'#{className}'.", | |
| 1423 }, | |
| 1424 | |
| 1425 'NO_STATIC_OVERRIDE_CONT': { | |
| 1426 'id': 'TEVJMA', | |
| 1427 'template': "This is the instance member that cannot be overridden " | |
| 1428 "by a static member.", | |
| 1429 }, | |
| 1430 | |
| 1431 'INSTANCE_STATIC_SAME_NAME': { | |
| 1432 'id': 'LTBFBO', | |
| 1433 'template': "Instance member '#{memberName}' and static member of " | |
| 1434 "superclass '#{className}' have the same name.", | |
| 1435 }, | |
| 1436 | |
| 1437 'INSTANCE_STATIC_SAME_NAME_CONT': { | |
| 1438 'id': 'CHSUCQ', | |
| 1439 'template': "This is the static member with the same name.", | |
| 1440 }, | |
| 1441 | |
| 1442 'INVALID_OVERRIDE_METHOD': { | |
| 1443 'id': 'NINKPI', | |
| 1444 'template': "The type '#{declaredType}' of method '#{name}' declared in " | |
| 1445 "'#{class}' is not a subtype of the overridden method type " | |
| 1446 "'#{inheritedType}' inherited from '#{inheritedClass}'.", | |
| 1447 }, | |
| 1448 | |
| 1449 'INVALID_OVERRIDDEN_METHOD': { | |
| 1450 'id': 'BQHUPY', | |
| 1451 'template': "This is the overridden method '#{name}' declared in class " | |
| 1452 "'#{class}'.", | |
| 1453 }, | |
| 1454 | |
| 1455 'INVALID_OVERRIDE_GETTER': { | |
| 1456 'id': 'KLMPWO', | |
| 1457 'template': "The type '#{declaredType}' of getter '#{name}' declared in " | |
| 1458 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1459 "overridden getter inherited from '#{inheritedClass}'.", | |
| 1460 }, | |
| 1461 | |
| 1462 'INVALID_OVERRIDDEN_GETTER': { | |
| 1463 'id': 'ASSKCT', | |
| 1464 'template': "This is the overridden getter '#{name}' declared in class " | |
| 1465 "'#{class}'.", | |
| 1466 }, | |
| 1467 | |
| 1468 'INVALID_OVERRIDE_GETTER_WITH_FIELD': { | |
| 1469 'id': 'TCCGXU', | |
| 1470 'template': "The type '#{declaredType}' of field '#{name}' declared in " | |
| 1471 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1472 "overridden getter inherited from '#{inheritedClass}'.", | |
| 1473 }, | |
| 1474 | |
| 1475 'INVALID_OVERRIDE_FIELD_WITH_GETTER': { | |
| 1476 'id': 'UMMEXO', | |
| 1477 'template': "The type '#{declaredType}' of getter '#{name}' declared in " | |
| 1478 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1479 "overridden field inherited from '#{inheritedClass}'.", | |
| 1480 }, | |
| 1481 | |
| 1482 'INVALID_OVERRIDE_SETTER': { | |
| 1483 'id': 'BWRGEC', | |
| 1484 'template': "The type '#{declaredType}' of setter '#{name}' declared in " | |
| 1485 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1486 "overridden setter inherited from '#{inheritedClass}'.", | |
| 1487 }, | |
| 1488 | |
| 1489 'INVALID_OVERRIDDEN_SETTER': { | |
| 1490 'id': 'XQUOLL', | |
| 1491 'template': "This is the overridden setter '#{name}' declared in class " | |
| 1492 "'#{class}'.", | |
| 1493 }, | |
| 1494 | |
| 1495 'INVALID_OVERRIDE_SETTER_WITH_FIELD': { | |
| 1496 'id': 'GKGOFA', | |
| 1497 'template': "The type '#{declaredType}' of field '#{name}' declared in " | |
| 1498 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1499 "overridden setter inherited from '#{inheritedClass}'.", | |
| 1500 }, | |
| 1501 | |
| 1502 'INVALID_OVERRIDE_FIELD_WITH_SETTER': { | |
| 1503 'id': 'OOXKHQ', | |
| 1504 'template': "The type '#{declaredType}' of setter '#{name}' declared in " | |
| 1505 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1506 "overridden field inherited from '#{inheritedClass}'.", | |
| 1507 }, | |
| 1508 | |
| 1509 'INVALID_OVERRIDE_FIELD': { | |
| 1510 'id': 'LDPKOL', | |
| 1511 'template': "The type '#{declaredType}' of field '#{name}' declared in " | |
| 1512 "'#{class}' is not assignable to the type '#{inheritedType}' of the " | |
| 1513 "overridden field inherited from '#{inheritedClass}'.", | |
| 1514 }, | |
| 1515 | |
| 1516 'INVALID_OVERRIDDEN_FIELD': { | |
| 1517 'id': 'UNQFWX', | |
| 1518 'template': "This is the overridden field '#{name}' declared in class " | |
| 1519 "'#{class}'.", | |
| 1520 }, | |
| 1521 | |
| 1522 'CANNOT_OVERRIDE_FIELD_WITH_METHOD': { | |
| 1523 'id': 'SYKCSK', | |
| 1524 'template': "Method '#{name}' in '#{class}' can't override field from " | |
| 1525 "'#{inheritedClass}'.", | |
| 1526 }, | |
| 1527 | |
| 1528 'CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT': { | |
| 1529 'id': 'HYHQSO', | |
| 1530 'template': "This is the field that cannot be overridden by a method.", | |
| 1531 }, | |
| 1532 | |
| 1533 'CANNOT_OVERRIDE_METHOD_WITH_FIELD': { | |
| 1534 'id': 'UROMAS', | |
| 1535 'template': "Field '#{name}' in '#{class}' can't override method from " | |
| 1536 "'#{inheritedClass}'.", | |
| 1537 }, | |
| 1538 | |
| 1539 'CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT': { | |
| 1540 'id': 'NSORYS', | |
| 1541 'template': "This is the method that cannot be overridden by a field.", | |
| 1542 }, | |
| 1543 | |
| 1544 'CANNOT_OVERRIDE_GETTER_WITH_METHOD': { | |
| 1545 'id': 'MMFIOH', | |
| 1546 'template': "Method '#{name}' in '#{class}' can't override getter from " | |
| 1547 "'#{inheritedClass}'.", | |
| 1548 }, | |
| 1549 | |
| 1550 'CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT': { | |
| 1551 'id': 'YGWPDH', | |
| 1552 'template': "This is the getter that cannot be overridden by a method.", | |
| 1553 }, | |
| 1554 | |
| 1555 'CANNOT_OVERRIDE_METHOD_WITH_GETTER': { | |
| 1556 'id': 'BNKNXO', | |
| 1557 'template': "Getter '#{name}' in '#{class}' can't override method from " | |
| 1558 "'#{inheritedClass}'.", | |
| 1559 }, | |
| 1560 | |
| 1561 'CANNOT_OVERRIDE_METHOD_WITH_GETTER_CONT': { | |
| 1562 'id': 'KFBCYX', | |
| 1563 'template': "This is the method that cannot be overridden by a getter.", | |
| 1564 }, | |
| 1565 | |
| 1566 'MISSING_FORMALS': { | |
| 1567 'id': 'BOERAF', | |
| 1568 'template': "Formal parameters are missing.", | |
| 1569 }, | |
| 1570 | |
| 1571 'EXTRA_FORMALS': { | |
| 1572 'id': 'UTWRIU', | |
| 1573 'template': "Formal parameters are not allowed here.", | |
| 1574 }, | |
| 1575 | |
| 1576 'UNARY_OPERATOR_BAD_ARITY': { | |
| 1577 'id': 'TNHLAL', | |
| 1578 'template': "Operator '#{operatorName}' must have no parameters.", | |
| 1579 }, | |
| 1580 | |
| 1581 'MINUS_OPERATOR_BAD_ARITY': { | |
| 1582 'id': 'SXDRRU', | |
| 1583 'template': "Operator '-' must have 0 or 1 parameters.", | |
| 1584 }, | |
| 1585 | |
| 1586 'BINARY_OPERATOR_BAD_ARITY': { | |
| 1587 'id': 'QKWAUM', | |
| 1588 'template': "Operator '#{operatorName}' must have exactly 1 parameter.", | |
| 1589 }, | |
| 1590 | |
| 1591 'TERNARY_OPERATOR_BAD_ARITY': { | |
| 1592 'id': 'LSMQGF', | |
| 1593 'template': "Operator '#{operatorName}' must have exactly 2 parameters.", | |
| 1594 }, | |
| 1595 | |
| 1596 'OPERATOR_OPTIONAL_PARAMETERS': { | |
| 1597 'id': 'HSGRBV', | |
| 1598 'template': "Operator '#{operatorName}' cannot have optional parameters.", | |
| 1599 }, | |
| 1600 | |
| 1601 'OPERATOR_NAMED_PARAMETERS': { | |
| 1602 'id': 'EACWGS', | |
| 1603 'template': "Operator '#{operatorName}' cannot have named parameters.", | |
| 1604 }, | |
| 1605 | |
| 1606 'CONSTRUCTOR_WITH_RETURN_TYPE': { | |
| 1607 'id': 'OPMBHF', | |
| 1608 'template': "Cannot have return type for constructor.", | |
| 1609 }, | |
| 1610 | |
| 1611 'CANNOT_RETURN_FROM_CONSTRUCTOR': { | |
| 1612 'id': 'NFUGNH', | |
| 1613 'template': "Constructors can't return values.", | |
| 1614 'howToFix': "Remove the return statement or use a factory constructor.", | |
| 1615 'examples': [ | |
| 1616 """ | |
| 1617 class C { | |
| 1618 C() { | |
| 1619 return 1; | |
| 1620 } | |
| 1621 } | |
| 1622 | |
| 1623 main() => new C();""" | |
| 1624 ], | |
| 1625 }, | |
| 1626 | |
| 1627 'ILLEGAL_FINAL_METHOD_MODIFIER': { | |
| 1628 'id': 'YUKCVU', | |
| 1629 'template': "Cannot have final modifier on method.", | |
| 1630 }, | |
| 1631 | |
| 1632 'ILLEGAL_CONST_FIELD_MODIFIER': { | |
| 1633 'id': 'JGFAGV', | |
| 1634 'template': "Cannot have const modifier on non-static field.", | |
| 1635 'howToFix': "Try adding a static modifier, or removing the const modifier.", | |
| 1636 'examples': [ | |
| 1637 """ | |
| 1638 class C { | |
| 1639 const int a = 1; | |
| 1640 } | |
| 1641 | |
| 1642 main() => new C();""" | |
| 1643 ], | |
| 1644 }, | |
| 1645 | |
| 1646 'ILLEGAL_CONSTRUCTOR_MODIFIERS': { | |
| 1647 'id': 'WODRHN', | |
| 1648 'template': "Illegal constructor modifiers: '#{modifiers}'.", | |
| 1649 }, | |
| 1650 | |
| 1651 'ILLEGAL_MIXIN_APPLICATION_MODIFIERS': { | |
| 1652 'id': 'OFLFHN', | |
| 1653 'template': "Illegal mixin application modifiers: '#{modifiers}'.", | |
| 1654 }, | |
| 1655 | |
| 1656 'ILLEGAL_MIXIN_SUPERCLASS': { | |
| 1657 'id': 'TPVVYN', | |
| 1658 'template': "Class used as mixin must have Object as superclass.", | |
| 1659 }, | |
| 1660 | |
| 1661 'ILLEGAL_MIXIN_OBJECT': { | |
| 1662 'id': 'CMVTLF', | |
| 1663 'template': "Cannot use Object as mixin.", | |
| 1664 }, | |
| 1665 | |
| 1666 'ILLEGAL_MIXIN_CONSTRUCTOR': { | |
| 1667 'id': 'HXBUIB', | |
| 1668 'template': "Class used as mixin cannot have non-factory constructor.", | |
| 1669 }, | |
| 1670 | |
| 1671 'ILLEGAL_MIXIN_CYCLE': { | |
| 1672 'id': 'ANXAMU', | |
| 1673 'template': "Class used as mixin introduces mixin cycle: " | |
| 1674 "'#{mixinName1}' <-> '#{mixinName2}'.", | |
| 1675 }, | |
| 1676 | |
| 1677 'ILLEGAL_MIXIN_WITH_SUPER': { | |
| 1678 'id': 'KIEUGK', | |
| 1679 'template': "Cannot use class '#{className}' as a mixin because it uses " | |
| 1680 "'super'.", | |
| 1681 }, | |
| 1682 | |
| 1683 'ILLEGAL_MIXIN_SUPER_USE': { | |
| 1684 'id': 'QKUPLH', | |
| 1685 'template': "Use of 'super' in class used as mixin.", | |
| 1686 }, | |
| 1687 | |
| 1688 'PARAMETER_NAME_EXPECTED': { | |
| 1689 'id': 'JOUOBT', | |
| 1690 'template': "parameter name expected.", | |
| 1691 }, | |
| 1692 | |
| 1693 'CANNOT_RESOLVE_GETTER': { | |
| 1694 'id': 'TDHKSW', | |
| 1695 'template': "Cannot resolve getter.", | |
| 1696 }, | |
| 1697 | |
| 1698 'CANNOT_RESOLVE_SETTER': { | |
| 1699 'id': 'QQFANP', | |
| 1700 'template': "Cannot resolve setter.", | |
| 1701 }, | |
| 1702 | |
| 1703 'ASSIGNING_FINAL_FIELD_IN_SUPER': { | |
| 1704 'id': 'LXUPCC', | |
| 1705 'template': "Cannot assign a value to final field '#{name}' " | |
| 1706 "in superclass '#{superclassName}'.", | |
| 1707 }, | |
| 1708 | |
| 1709 'ASSIGNING_METHOD': { | |
| 1710 'id': 'JUVMYC', | |
| 1711 'template': "Cannot assign a value to a method.", | |
| 1712 }, | |
| 1713 | |
| 1714 'ASSIGNING_METHOD_IN_SUPER': { | |
| 1715 'id': 'AGMAXN', | |
| 1716 'template': "Cannot assign a value to method '#{name}' " | |
| 1717 "in superclass '#{superclassName}'.", | |
| 1718 }, | |
| 1719 | |
| 1720 'ASSIGNING_TYPE': { | |
| 1721 'id': 'VXTPWE', | |
| 1722 'template': "Cannot assign a value to a type.", | |
| 1723 }, | |
| 1724 | |
| 1725 'IF_NULL_ASSIGNING_TYPE': { | |
| 1726 'id': 'XBRHGK', | |
| 1727 'template': | |
| 1728 "Cannot assign a value to a type. Note that types are never null, " | |
| 1729 "so this ??= assignment has no effect.", | |
| 1730 'howToFix': "Try removing the '??=' assignment.", | |
| 1731 'examples': ["class A {} main() { print(A ??= 3);}",], | |
| 1732 }, | |
| 1733 | |
| 1734 'VOID_NOT_ALLOWED': { | |
| 1735 'id': 'DMMDXT', | |
| 1736 'template': | |
| 1737 "Type 'void' can't be used here because it isn't a return type.", | |
| 1738 'howToFix': | |
| 1739 "Try removing 'void' keyword or replace it with 'var', 'final', " | |
| 1740 "or a type.", | |
| 1741 'examples': ["void x; main() {}", "foo(void x) {} main() { foo(null); }",], | |
| 1742 }, | |
| 1743 | |
| 1744 'NULL_NOT_ALLOWED': { | |
| 1745 'id': 'STYNSK', | |
| 1746 'template': "`null` can't be used here.", | |
| 1747 }, | |
| 1748 | |
| 1749 'BEFORE_TOP_LEVEL': { | |
| 1750 'id': 'GRCXQF', | |
| 1751 'template': "Part header must come before top-level definitions.", | |
| 1752 }, | |
| 1753 | |
| 1754 'IMPORT_PART_OF': { | |
| 1755 'id': 'VANCWE', | |
| 1756 'template': "The imported library must not have a 'part-of' directive.", | |
| 1757 'howToFix': "Try removing the 'part-of' directive or replacing the " | |
| 1758 "import of the library with a 'part' directive.", | |
| 1759 'examples': [ | |
| 1760 { | |
| 1761 'main.dart': """ | |
| 1762 library library; | |
| 1763 | |
| 1764 import 'part.dart'; | |
| 1765 | |
| 1766 main() {} | |
| 1767 """, | |
| 1768 'part.dart': """ | |
| 1769 part of library; | |
| 1770 """ | |
| 1771 } | |
| 1772 ], | |
| 1773 }, | |
| 1774 | |
| 1775 'IMPORT_PART_OF_HERE': { | |
| 1776 'id': 'TRSZOJ', | |
| 1777 'template': 'The library is imported here.', | |
| 1778 }, | |
| 1779 | |
| 1780 'MAIN_HAS_PART_OF': { | |
| 1781 'id': 'MFMRRL', | |
| 1782 'template': "The main application file must not have a 'part-of' " | |
| 1783 "directive.", | |
| 1784 'howToFix': "Try removing the 'part-of' directive or starting compilation " | |
| 1785 "from another file.", | |
| 1786 'examples': [ | |
| 1787 { | |
| 1788 'main.dart': """ | |
| 1789 part of library; | |
| 1790 | |
| 1791 main() {} | |
| 1792 """ | |
| 1793 } | |
| 1794 ], | |
| 1795 }, | |
| 1796 | |
| 1797 'LIBRARY_NAME_MISMATCH': { | |
| 1798 'id': 'AXGYPQ', | |
| 1799 'template': "Expected part of library name '#{libraryName}'.", | |
| 1800 'howToFix': "Try changing the directive to 'part of #{libraryName};'.", | |
| 1801 'examples': [ | |
| 1802 { | |
| 1803 'main.dart': """ | |
| 1804 library lib.foo; | |
| 1805 | |
| 1806 part 'part.dart'; | |
| 1807 | |
| 1808 main() {} | |
| 1809 """, | |
| 1810 'part.dart': """ | |
| 1811 part of lib.bar; | |
| 1812 """ | |
| 1813 } | |
| 1814 ], | |
| 1815 }, | |
| 1816 | |
| 1817 'MISSING_LIBRARY_NAME': { | |
| 1818 'id': 'NYQNCA', | |
| 1819 'template': "Library has no name. Part directive expected library name " | |
| 1820 "to be '#{libraryName}'.", | |
| 1821 'howToFix': "Try adding 'library #{libraryName};' to the library.", | |
| 1822 'examples': [ | |
| 1823 { | |
| 1824 'main.dart': """ | |
| 1825 part 'part.dart'; | |
| 1826 | |
| 1827 main() {} | |
| 1828 """, | |
| 1829 'part.dart': """ | |
| 1830 part of lib.foo; | |
| 1831 """ | |
| 1832 } | |
| 1833 ], | |
| 1834 }, | |
| 1835 | |
| 1836 'THIS_IS_THE_PART_OF_TAG': { | |
| 1837 'id': 'RPSJRS', | |
| 1838 'template': "This is the part of directive.", | |
| 1839 }, | |
| 1840 | |
| 1841 'MISSING_PART_OF_TAG': { | |
| 1842 'id': 'QNYCMV', | |
| 1843 'template': "This file has no part-of tag, but it is being used as a part.", | |
| 1844 }, | |
| 1845 | |
| 1846 'DUPLICATED_PART_OF': { | |
| 1847 'id': 'UJDYHF', | |
| 1848 'template': "Duplicated part-of directive.", | |
| 1849 }, | |
| 1850 | |
| 1851 'DUPLICATED_LIBRARY_NAME': { | |
| 1852 'id': 'OSEHXI', | |
| 1853 'template': "Duplicated library name '#{libraryName}'.", | |
| 1854 }, | |
| 1855 | |
| 1856 'DUPLICATED_RESOURCE': { | |
| 1857 'id': 'UFWKBY', | |
| 1858 'template': "The resource '#{resourceUri}' is loaded through both " | |
| 1859 "'#{canonicalUri1}' and '#{canonicalUri2}'.", | |
| 1860 }, | |
| 1861 | |
| 1862 'DUPLICATED_LIBRARY_RESOURCE': { | |
| 1863 'id': 'KYGYTT', | |
| 1864 'template': | |
| 1865 "The library '#{libraryName}' in '#{resourceUri}' is loaded through " | |
| 1866 "both '#{canonicalUri1}' and '#{canonicalUri2}'.", | |
| 1867 }, | |
| 1868 | |
| 1869 // This is used as an exception. | |
| 1870 'INVALID_SOURCE_FILE_LOCATION': { | |
| 1871 'id': 'WIGJFG', | |
| 1872 'template': """ | |
| 1873 Invalid offset (#{offset}) in source map. | |
| 1874 File: #{fileName} | |
| 1875 Length: #{length}""", | |
| 1876 }, | |
| 1877 | |
| 1878 'TOP_LEVEL_VARIABLE_DECLARED_STATIC': { | |
| 1879 'id': 'IVNDML', | |
| 1880 'template': "Top-level variable cannot be declared static.", | |
| 1881 }, | |
| 1882 | |
| 1883 'REFERENCE_IN_INITIALIZATION': { | |
| 1884 'id': 'OVWTEU', | |
| 1885 'template': "Variable '#{variableName}' is referenced during its " | |
| 1886 "initialization.", | |
| 1887 'howToFix': "If you are trying to reference a shadowed variable, rename " | |
| 1888 "one of the variables.", | |
| 1889 'examples': [ | |
| 1890 """ | |
| 1891 foo(t) { | |
| 1892 var t = t; | |
| 1893 return t; | |
| 1894 } | |
| 1895 | |
| 1896 main() => foo(1); | |
| 1897 """ | |
| 1898 ], | |
| 1899 }, | |
| 1900 | |
| 1901 'CONST_WITHOUT_INITIALIZER': { | |
| 1902 'id': 'UDWCNH', | |
| 1903 'template': "A constant variable must be initialized.", | |
| 1904 'howToFix': "Try adding an initializer or " | |
| 1905 "removing the 'const' modifier.", | |
| 1906 'examples': [ | |
| 1907 """ | |
| 1908 void main() { | |
| 1909 const c; // This constant variable must be initialized. | |
| 1910 }""" | |
| 1911 ], | |
| 1912 }, | |
| 1913 | |
| 1914 'FINAL_WITHOUT_INITIALIZER': { | |
| 1915 'id': 'YMESFI', | |
| 1916 'template': "A final variable must be initialized.", | |
| 1917 'howToFix': "Try adding an initializer or " | |
| 1918 "removing the 'final' modifier.", | |
| 1919 'examples': ["class C { static final field; } main() => C.field;"], | |
| 1920 }, | |
| 1921 | |
| 1922 'CONST_LOOP_VARIABLE': { | |
| 1923 'id': 'WUSKMG', | |
| 1924 'template': "A loop variable cannot be constant.", | |
| 1925 'howToFix': "Try remove the 'const' modifier or " | |
| 1926 "replacing it with a 'final' modifier.", | |
| 1927 'examples': [ | |
| 1928 """ | |
| 1929 void main() { | |
| 1930 for (const c in []) {} | |
| 1931 }""" | |
| 1932 ], | |
| 1933 }, | |
| 1934 | |
| 1935 'MEMBER_USES_CLASS_NAME': { | |
| 1936 'id': 'TVFYRK', | |
| 1937 'template': "Member variable can't have the same name as the class it is " | |
| 1938 "declared in.", | |
| 1939 'howToFix': "Try renaming the variable.", | |
| 1940 'examples': [ | |
| 1941 """ | |
| 1942 class A { var A; } | |
| 1943 main() { | |
| 1944 var a = new A(); | |
| 1945 a.A = 1; | |
| 1946 } | |
| 1947 """, | |
| 1948 """ | |
| 1949 class A { static var A; } | |
| 1950 main() => A.A = 1; | |
| 1951 """ | |
| 1952 ], | |
| 1953 }, | |
| 1954 | |
| 1955 'WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT': { | |
| 1956 'id': 'IXYNUF', | |
| 1957 'template': "Wrong number of arguments to assert. Should be 1, but given " | |
| 1958 "#{argumentCount}.", | |
| 1959 }, | |
| 1960 | |
| 1961 'ASSERT_IS_GIVEN_NAMED_ARGUMENTS': { | |
| 1962 'id': 'EJFDTO', | |
| 1963 'template': | |
| 1964 "'assert' takes no named arguments, but given #{argumentCount}.", | |
| 1965 }, | |
| 1966 | |
| 1967 'FACTORY_REDIRECTION_IN_NON_FACTORY': { | |
| 1968 'id': 'DTBWEX', | |
| 1969 'template': "Factory redirection only allowed in factories.", | |
| 1970 }, | |
| 1971 | |
| 1972 'MISSING_FACTORY_KEYWORD': { | |
| 1973 'id': 'HOQYYA', | |
| 1974 'template': "Did you forget a factory keyword here?", | |
| 1975 }, | |
| 1976 | |
| 1977 'NO_SUCH_METHOD_IN_NATIVE': { | |
| 1978 'id': 'MSDDBX', | |
| 1979 'template': | |
| 1980 "'NoSuchMethod' is not supported for classes that extend native " | |
| 1981 "classes.", | |
| 1982 }, | |
| 1983 | |
| 1984 'DEFERRED_LIBRARY_DART_2_DART': { | |
| 1985 'id': 'RIRQAH', | |
| 1986 'template': "Deferred loading is not supported by the dart backend yet. " | |
| 1987 "The output will not be split.", | |
| 1988 }, | |
| 1989 | |
| 1990 'DEFERRED_LIBRARY_WITHOUT_PREFIX': { | |
| 1991 'id': 'CARRII', | |
| 1992 'template': "This import is deferred but there is no prefix keyword.", | |
| 1993 'howToFix': "Try adding a prefix to the import." | |
| 1994 }, | |
| 1995 | |
| 1996 'DEFERRED_OLD_SYNTAX': { | |
| 1997 'id': 'QCBRAE', | |
| 1998 'template': "The DeferredLibrary annotation is obsolete.", | |
| 1999 'howToFix': | |
| 2000 "Use the \"import 'lib.dart' deferred as prefix\" syntax instead.", | |
| 2001 }, | |
| 2002 | |
| 2003 'DEFERRED_LIBRARY_DUPLICATE_PREFIX': { | |
| 2004 'id': 'BBMJTD', | |
| 2005 'template': "The prefix of this deferred import is not unique.", | |
| 2006 'howToFix': "Try changing the import prefix." | |
| 2007 }, | |
| 2008 | |
| 2009 'DEFERRED_TYPE_ANNOTATION': { | |
| 2010 'id': 'JOUEFD', | |
| 2011 'template': "The type #{node} is deferred. " | |
| 2012 "Deferred types are not valid as type annotations.", | |
| 2013 'howToFix': "Try using a non-deferred abstract class as an interface.", | |
| 2014 }, | |
| 2015 | |
| 2016 'ILLEGAL_STATIC': { | |
| 2017 'id': 'HFBHVE', | |
| 2018 'template': "Modifier static is only allowed on functions declared in " | |
| 2019 "a class.", | |
| 2020 }, | |
| 2021 | |
| 2022 'STATIC_FUNCTION_BLOAT': { | |
| 2023 'id': 'SJHTKF', | |
| 2024 'template': "Using '#{class}.#{name}' may lead to unnecessarily large " | |
| 2025 "generated code.", | |
| 2026 'howToFix': "Try adding '@MirrorsUsed(...)' as described at " | |
| 2027 "https://goo.gl/Akrrog.", | |
| 2028 }, | |
| 2029 | |
| 2030 'NON_CONST_BLOAT': { | |
| 2031 'id': 'RDRSHO', | |
| 2032 'template': "Using 'new #{name}' may lead to unnecessarily large generated " | |
| 2033 "code.", | |
| 2034 'howToFix': "Try using 'const #{name}' or adding '@MirrorsUsed(...)' as " | |
| 2035 "described at https://goo.gl/Akrrog.", | |
| 2036 }, | |
| 2037 | |
| 2038 'STRING_EXPECTED': { | |
| 2039 'id': 'OEJOOI', | |
| 2040 'template': "Expected a 'String', but got an instance of '#{type}'.", | |
| 2041 }, | |
| 2042 | |
| 2043 'PRIVATE_IDENTIFIER': { | |
| 2044 'id': 'XAHVWI', | |
| 2045 'template': "'#{value}' is not a valid Symbol name because it starts with " | |
| 2046 "'_'.", | |
| 2047 }, | |
| 2048 | |
| 2049 'PRIVATE_NAMED_PARAMETER': { | |
| 2050 'id': 'VFGCLK', | |
| 2051 'template': "Named optional parameter can't have a library private name.", | |
| 2052 'howToFix': "Try removing the '_' or making the parameter positional or " | |
| 2053 "required.", | |
| 2054 'examples': ["""foo({int _p}) {} main() => foo();"""], | |
| 2055 }, | |
| 2056 | |
| 2057 'UNSUPPORTED_LITERAL_SYMBOL': { | |
| 2058 'id': 'OYCDII', | |
| 2059 'template': | |
| 2060 "Symbol literal '##{value}' is currently unsupported by dart2js.", | |
| 2061 }, | |
| 2062 | |
| 2063 'INVALID_SYMBOL': { | |
| 2064 'id': 'RUXMBL', | |
| 2065 'template': ''' | |
| 2066 '#{value}' is not a valid Symbol name because is not: | |
| 2067 * an empty String, | |
| 2068 * a user defined operator, | |
| 2069 * a qualified non-private identifier optionally followed by '=', or | |
| 2070 * a qualified non-private identifier followed by '.' and a user-defined ''' | |
| 2071 "operator.", | |
| 2072 }, | |
| 2073 | |
| 2074 'AMBIGUOUS_REEXPORT': { | |
| 2075 'id': 'YNTOND', | |
| 2076 'template': "'#{name}' is (re)exported by multiple libraries.", | |
| 2077 }, | |
| 2078 | |
| 2079 'AMBIGUOUS_LOCATION': { | |
| 2080 'id': 'SKLTYA', | |
| 2081 'template': "'#{name}' is defined here.", | |
| 2082 }, | |
| 2083 | |
| 2084 'IMPORTED_HERE': {'id': 'IMUXAE', 'template': "'#{name}' is imported here.",}, | |
| 2085 | |
| 2086 'OVERRIDE_EQUALS_NOT_HASH_CODE': { | |
| 2087 'id': 'MUHYXI', | |
| 2088 'template': "The class '#{class}' overrides 'operator==', " | |
| 2089 "but not 'get hashCode'.", | |
| 2090 }, | |
| 2091 | |
| 2092 'INTERNAL_LIBRARY_FROM': { | |
| 2093 'id': 'RXOCLX', | |
| 2094 'template': "Internal library '#{resolvedUri}' is not accessible from " | |
| 2095 "'#{importingUri}'.", | |
| 2096 }, | |
| 2097 | |
| 2098 'INTERNAL_LIBRARY': { | |
| 2099 'id': 'SYLJAV', | |
| 2100 'template': "Internal library '#{resolvedUri}' is not accessible.", | |
| 2101 }, | |
| 2102 | |
| 2103 'JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS': { | |
| 2104 'id': 'LSHKJK', | |
| 2105 'template': | |
| 2106 "Js-interop class '#{cls}' cannot extend from the non js-interop " | |
| 2107 "class '#{superclass}'.", | |
| 2108 'howToFix': "Annotate the superclass with @JS.", | |
| 2109 'examples': [ | |
| 2110 """ | |
| 2111 import 'package:js/js.dart'; | |
| 2112 | |
| 2113 class Foo { } | |
| 2114 | |
| 2115 @JS() | |
| 2116 class Bar extends Foo { } | |
| 2117 | |
| 2118 main() { | |
| 2119 new Bar(); | |
| 2120 } | |
| 2121 """ | |
| 2122 ], | |
| 2123 }, | |
| 2124 | |
| 2125 'JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER': { | |
| 2126 'id': 'QLLLEE', | |
| 2127 'template': | |
| 2128 "Member '#{member}' in js-interop class '#{cls}' is not external.", | |
| 2129 'howToFix': "Mark all interop methods external", | |
| 2130 'examples': [ | |
| 2131 """ | |
| 2132 import 'package:js/js.dart'; | |
| 2133 | |
| 2134 @JS() | |
| 2135 class Foo { | |
| 2136 bar() {} | |
| 2137 } | |
| 2138 | |
| 2139 main() { | |
| 2140 new Foo().bar(); | |
| 2141 } | |
| 2142 """ | |
| 2143 ], | |
| 2144 }, | |
| 2145 | |
| 2146 'JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS': { | |
| 2147 'id': 'TDQHRY', | |
| 2148 'template': "Js-interop method '#{method}' has named arguments but is not " | |
| 2149 "a factory constructor of an @anonymous @JS class.", | |
| 2150 'howToFix': "Remove all named arguments from js-interop method or " | |
| 2151 "in the case of a factory constructor annotate the class " | |
| 2152 "as @anonymous.", | |
| 2153 'examples': [ | |
| 2154 """ | |
| 2155 import 'package:js/js.dart'; | |
| 2156 | |
| 2157 @JS() | |
| 2158 class Foo { | |
| 2159 external bar(foo, {baz}); | |
| 2160 } | |
| 2161 | |
| 2162 main() { | |
| 2163 new Foo().bar(4, baz: 5); | |
| 2164 } | |
| 2165 """ | |
| 2166 ], | |
| 2167 }, | |
| 2168 | |
| 2169 'JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS': { | |
| 2170 'id': 'EHEKUY', | |
| 2171 'template': | |
| 2172 "Parameter '#{parameter}' in anonymous js-interop class '#{cls}' " | |
| 2173 "object literal constructor is positional instead of named." | |
| 2174 ".", | |
| 2175 'howToFix': "Make all arguments in external factory object literal " | |
| 2176 "constructors named.", | |
| 2177 'examples': [ | |
| 2178 """ | |
| 2179 import 'package:js/js.dart'; | |
| 2180 | |
| 2181 @anonymous | |
| 2182 @JS() | |
| 2183 class Foo { | |
| 2184 external factory Foo(foo, {baz}); | |
| 2185 } | |
| 2186 | |
| 2187 main() { | |
| 2188 new Foo(5, baz: 5); | |
| 2189 } | |
| 2190 """ | |
| 2191 ], | |
| 2192 }, | |
| 2193 | |
| 2194 'LIBRARY_NOT_FOUND': { | |
| 2195 'id': 'BARPSL', | |
| 2196 'template': "Library not found '#{resolvedUri}'.", | |
| 2197 }, | |
| 2198 | |
| 2199 'LIBRARY_NOT_SUPPORTED': { | |
| 2200 'id': 'GDXUNS', | |
| 2201 'template': "Library not supported '#{resolvedUri}'.", | |
| 2202 'howToFix': "Try removing the dependency or enabling support using " | |
| 2203 "the '--categories' option.", | |
| 2204 'examples': [ | |
| 2205 // """ | |
| 2206 // import 'dart:io'; | |
| 2207 // main() {} | |
| 2208 // """ | |
| 2209 ], | |
| 2210 // TODO(johnniwinther): Enable example when message_kind_test.dart | |
| 2211 // supports library loader callbacks. | |
| 2212 }, | |
| 2213 | |
| 2214 'UNSUPPORTED_EQ_EQ_EQ': { | |
| 2215 'id': 'GPOVNO', | |
| 2216 'template': "'===' is not an operator. " | |
| 2217 "Did you mean '#{lhs} == #{rhs}' or 'identical(#{lhs}, #{rhs})'?", | |
| 2218 }, | |
| 2219 | |
| 2220 'UNSUPPORTED_BANG_EQ_EQ': { | |
| 2221 'id': 'HDYKMV', | |
| 2222 'template': "'!==' is not an operator. " | |
| 2223 "Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?", | |
| 2224 }, | |
| 2225 | |
| 2226 'UNSUPPORTED_PREFIX_PLUS': { | |
| 2227 'id': 'LSQTHP', | |
| 2228 'template': "'+' is not a prefix operator. ", | |
| 2229 'howToFix': "Try removing '+'.", | |
| 2230 'examples': ["main() => +2; // No longer a valid way to write '2'"], | |
| 2231 }, | |
| 2232 | |
| 2233 'UNSUPPORTED_THROW_WITHOUT_EXP': { | |
| 2234 'id': 'QOAKGE', | |
| 2235 'template': "No expression after 'throw'. " | |
| 2236 "Did you mean 'rethrow'?", | |
| 2237 }, | |
| 2238 | |
| 2239 'DEPRECATED_TYPEDEF_MIXIN_SYNTAX': { | |
| 2240 'id': 'BBGGFE', | |
| 2241 'template': "'typedef' not allowed here. ", | |
| 2242 'howToFix': "Try replacing 'typedef' with 'class'.", | |
| 2243 'examples': [ | |
| 2244 """ | |
| 2245 class B { } | |
| 2246 class M1 { } | |
| 2247 typedef C = B with M1; // Need to replace 'typedef' with 'class'. | |
| 2248 main() { new C(); } | |
| 2249 """ | |
| 2250 ], | |
| 2251 }, | |
| 2252 | |
| 2253 'MIRRORS_EXPECTED_STRING': { | |
| 2254 'id': 'XSKTIB', | |
| 2255 'template': | |
| 2256 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 2257 "and a 'String' value is expected.", | |
| 2258 'howToFix': "Did you forget to add quotes?", | |
| 2259 'examples': [ | |
| 2260 """ | |
| 2261 // 'Foo' is a type literal, not a string. | |
| 2262 @MirrorsUsed(symbols: const [Foo]) | |
| 2263 import 'dart:mirrors'; | |
| 2264 | |
| 2265 class Foo {} | |
| 2266 | |
| 2267 main() {} | |
| 2268 """ | |
| 2269 ], | |
| 2270 }, | |
| 2271 | |
| 2272 'MIRRORS_EXPECTED_STRING_OR_TYPE': { | |
| 2273 'id': 'JQDJPL', | |
| 2274 'template': | |
| 2275 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 2276 "and a 'String' or 'Type' value is expected.", | |
| 2277 'howToFix': "Did you forget to add quotes?", | |
| 2278 'examples': [ | |
| 2279 """ | |
| 2280 // 'main' is a method, not a class. | |
| 2281 @MirrorsUsed(targets: const [main]) | |
| 2282 import 'dart:mirrors'; | |
| 2283 | |
| 2284 main() {} | |
| 2285 """ | |
| 2286 ], | |
| 2287 }, | |
| 2288 | |
| 2289 'MIRRORS_EXPECTED_STRING_OR_LIST': { | |
| 2290 'id': 'UVYCOE', | |
| 2291 'template': | |
| 2292 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 2293 "and a 'String' or 'List' value is expected.", | |
| 2294 'howToFix': "Did you forget to add quotes?", | |
| 2295 'examples': [ | |
| 2296 """ | |
| 2297 // 'Foo' is not a string. | |
| 2298 @MirrorsUsed(symbols: Foo) | |
| 2299 import 'dart:mirrors'; | |
| 2300 | |
| 2301 class Foo {} | |
| 2302 | |
| 2303 main() {} | |
| 2304 """ | |
| 2305 ], | |
| 2306 }, | |
| 2307 | |
| 2308 'MIRRORS_EXPECTED_STRING_TYPE_OR_LIST': { | |
| 2309 'id': 'WSYDFL', | |
| 2310 'template': | |
| 2311 "Can't use '#{name}' here because it's an instance of '#{type}' " | |
| 2312 "but a 'String', 'Type', or 'List' value is expected.", | |
| 2313 'howToFix': "Did you forget to add quotes?", | |
| 2314 'examples': [ | |
| 2315 """ | |
| 2316 // '1' is not a string. | |
| 2317 @MirrorsUsed(targets: 1) | |
| 2318 import 'dart:mirrors'; | |
| 2319 | |
| 2320 main() {} | |
| 2321 """ | |
| 2322 ], | |
| 2323 }, | |
| 2324 | |
| 2325 'MIRRORS_CANNOT_RESOLVE_IN_CURRENT_LIBRARY': { | |
| 2326 'id': 'VDBBNE', | |
| 2327 'template': "Can't find '#{name}' in the current library.", | |
| 2328 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 2329 'howToFix': "Did you forget to add an import?", | |
| 2330 'examples': [ | |
| 2331 """ | |
| 2332 // 'window' is not in scope because dart:html isn't imported. | |
| 2333 @MirrorsUsed(targets: 'window') | |
| 2334 import 'dart:mirrors'; | |
| 2335 | |
| 2336 main() {} | |
| 2337 """ | |
| 2338 ], | |
| 2339 }, | |
| 2340 | |
| 2341 'MIRRORS_CANNOT_RESOLVE_IN_LIBRARY': { | |
| 2342 'id': 'RUEKXE', | |
| 2343 'template': "Can't find '#{name}' in the library '#{library}'.", | |
| 2344 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 2345 'howToFix': "Is '#{name}' spelled right?", | |
| 2346 'examples': [ | |
| 2347 """ | |
| 2348 // 'List' is misspelled. | |
| 2349 @MirrorsUsed(targets: 'dart.core.Lsit') | |
| 2350 import 'dart:mirrors'; | |
| 2351 | |
| 2352 main() {} | |
| 2353 """ | |
| 2354 ], | |
| 2355 }, | |
| 2356 | |
| 2357 'MIRRORS_CANNOT_FIND_IN_ELEMENT': { | |
| 2358 'id': 'ACPDCS', | |
| 2359 'template': "Can't find '#{name}' in '#{element}'.", | |
| 2360 // TODO(ahe): The closest identifiers in edit distance would be nice. | |
| 2361 'howToFix': "Is '#{name}' spelled right?", | |
| 2362 'examples': [ | |
| 2363 """ | |
| 2364 // 'addAll' is misspelled. | |
| 2365 @MirrorsUsed(targets: 'dart.core.List.addAl') | |
| 2366 import 'dart:mirrors'; | |
| 2367 | |
| 2368 main() {} | |
| 2369 """ | |
| 2370 ], | |
| 2371 }, | |
| 2372 | |
| 2373 'INVALID_URI': { | |
| 2374 'id': 'QQEQMK', | |
| 2375 'template': "'#{uri}' is not a valid URI.", | |
| 2376 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2377 'examples': [ | |
| 2378 """ | |
| 2379 // can't have a '[' in a URI | |
| 2380 import '../../Udyn[mic ils/expect.dart'; | |
| 2381 | |
| 2382 main() {} | |
| 2383 """ | |
| 2384 ], | |
| 2385 }, | |
| 2386 | |
| 2387 'INVALID_PACKAGE_CONFIG': { | |
| 2388 'id': 'XKFAJO', | |
| 2389 'template': """Package config file '#{uri}' is invalid. | |
| 2390 #{exception}""", | |
| 2391 'howToFix': DONT_KNOW_HOW_TO_FIX | |
| 2392 }, | |
| 2393 | |
| 2394 'INVALID_PACKAGE_URI': { | |
| 2395 'id': 'MFVNNJ', | |
| 2396 'template': "'#{uri}' is not a valid package URI (#{exception}).", | |
| 2397 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2398 'examples': [ | |
| 2399 """ | |
| 2400 // can't have a 'top level' package URI | |
| 2401 import 'package:foo.dart'; | |
| 2402 | |
| 2403 main() {} | |
| 2404 """, | |
| 2405 """ | |
| 2406 // can't have 2 slashes | |
| 2407 import 'package://foo/foo.dart'; | |
| 2408 | |
| 2409 main() {} | |
| 2410 """, | |
| 2411 """ | |
| 2412 // package name must be valid | |
| 2413 import 'package:not\valid/foo.dart'; | |
| 2414 | |
| 2415 main() {} | |
| 2416 """ | |
| 2417 ], | |
| 2418 }, | |
| 2419 | |
| 2420 'READ_SCRIPT_ERROR': { | |
| 2421 'id': 'JDDYLH', | |
| 2422 'template': "Can't read '#{uri}' (#{exception}).", | |
| 2423 // Don't know how to fix since the underlying error is unknown. | |
| 2424 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2425 'examples': [ | |
| 2426 """ | |
| 2427 // 'foo.dart' does not exist. | |
| 2428 import 'foo.dart'; | |
| 2429 | |
| 2430 main() {} | |
| 2431 """ | |
| 2432 ], | |
| 2433 }, | |
| 2434 | |
| 2435 'READ_SELF_ERROR': { | |
| 2436 'id': 'CRJUAV', | |
| 2437 'template': "#{exception}", | |
| 2438 // Don't know how to fix since the underlying error is unknown. | |
| 2439 'howToFix': DONT_KNOW_HOW_TO_FIX | |
| 2440 }, | |
| 2441 | |
| 2442 'EXTRANEOUS_MODIFIER': { | |
| 2443 'id': 'DPLVJG', | |
| 2444 'template': "Can't have modifier '#{modifier}' here.", | |
| 2445 'howToFix': "Try removing '#{modifier}'.", | |
| 2446 'examples': [ | |
| 2447 "var String foo; main(){}", | |
| 2448 // "var get foo; main(){}", | |
| 2449 "var set foo; main(){}", | |
| 2450 "var final foo; main(){}", | |
| 2451 "var var foo; main(){}", | |
| 2452 "var const foo; main(){}", | |
| 2453 "var abstract foo; main(){}", | |
| 2454 "var static foo; main(){}", | |
| 2455 "var external foo; main(){}", | |
| 2456 "get var foo; main(){}", | |
| 2457 "set var foo; main(){}", | |
| 2458 "final var foo; main(){}", | |
| 2459 "var var foo; main(){}", | |
| 2460 "const var foo; main(){}", | |
| 2461 "abstract var foo; main(){}", | |
| 2462 "static var foo; main(){}", | |
| 2463 "external var foo; main(){}" | |
| 2464 ], | |
| 2465 }, | |
| 2466 | |
| 2467 'EXTRANEOUS_MODIFIER_REPLACE': { | |
| 2468 'id': 'SSXDLN', | |
| 2469 'template': "Can't have modifier '#{modifier}' here.", | |
| 2470 'howToFix': "Try replacing modifier '#{modifier}' with 'var', 'final', " | |
| 2471 "or a type.", | |
| 2472 'examples': [ | |
| 2473 // "get foo; main(){}", | |
| 2474 "set foo; main(){}", | |
| 2475 "abstract foo; main(){}", | |
| 2476 "static foo; main(){}", | |
| 2477 "external foo; main(){}" | |
| 2478 ], | |
| 2479 }, | |
| 2480 | |
| 2481 'ABSTRACT_CLASS_INSTANTIATION': { | |
| 2482 'id': 'KOBCRO', | |
| 2483 'template': "Can't instantiate abstract class.", | |
| 2484 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2485 'examples': ["abstract class A {} main() { new A(); }"], | |
| 2486 }, | |
| 2487 | |
| 2488 'BODY_EXPECTED': { | |
| 2489 'id': 'YXCAHO', | |
| 2490 'template': "Expected a function body or '=>'.", | |
| 2491 // TODO(ahe): In some scenarios, we can suggest removing the 'static' | |
| 2492 // keyword. | |
| 2493 'howToFix': "Try adding {}.", | |
| 2494 'examples': ["main();"], | |
| 2495 }, | |
| 2496 | |
| 2497 'MIRROR_BLOAT': { | |
| 2498 'id': 'BSEAIT', | |
| 2499 'template': | |
| 2500 "#{count} methods retained for use by dart:mirrors out of #{total}" | |
| 2501 " total methods (#{percentage}%).", | |
| 2502 }, | |
| 2503 | |
| 2504 'MIRROR_IMPORT': {'id': 'BDAETE', 'template': "Import of 'dart:mirrors'.",}, | |
| 2505 | |
| 2506 'MIRROR_IMPORT_NO_USAGE': { | |
| 2507 'id': 'OJOHTR', | |
| 2508 'template': | |
| 2509 "This import is not annotated with @MirrorsUsed, which may lead to " | |
| 2510 "unnecessarily large generated code.", | |
| 2511 'howToFix': "Try adding '@MirrorsUsed(...)' as described at " | |
| 2512 "https://goo.gl/Akrrog.", | |
| 2513 }, | |
| 2514 | |
| 2515 'JS_PLACEHOLDER_CAPTURE': { | |
| 2516 'id': 'EJXEGQ', | |
| 2517 'template': "JS code must not use '#' placeholders inside functions.", | |
| 2518 'howToFix': "Use an immediately called JavaScript function to capture the" | |
| 2519 " the placeholder values as JavaScript function parameters.", | |
| 2520 }, | |
| 2521 | |
| 2522 'WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT': { | |
| 2523 'id': 'JHRISO', | |
| 2524 'template': | |
| 2525 "Argument for 'JS_INTERCEPTOR_CONSTANT' must be a type constant.", | |
| 2526 }, | |
| 2527 | |
| 2528 'EXPECTED_IDENTIFIER_NOT_RESERVED_WORD': { | |
| 2529 'id': 'FEJXJF', | |
| 2530 'template': "'#{keyword}' is a reserved word and can't be used here.", | |
| 2531 'howToFix': "Try using a different name.", | |
| 2532 'examples': ["do() {} main() {}"], | |
| 2533 }, | |
| 2534 | |
| 2535 'NAMED_FUNCTION_EXPRESSION': { | |
| 2536 'id': 'CTHFPI', | |
| 2537 'template': "Function expression '#{name}' cannot be named.", | |
| 2538 'howToFix': "Try removing the name.", | |
| 2539 'examples': ["main() { var f = func() {}; }"], | |
| 2540 }, | |
| 2541 | |
| 2542 'UNUSED_METHOD': { | |
| 2543 'id': 'PKLRQL', | |
| 2544 'template': "The method '#{name}' is never called.", | |
| 2545 'howToFix': "Consider deleting it.", | |
| 2546 'examples': ["deadCode() {} main() {}"], | |
| 2547 }, | |
| 2548 | |
| 2549 'UNUSED_CLASS': { | |
| 2550 'id': 'TBIECC', | |
| 2551 'template': "The class '#{name}' is never used.", | |
| 2552 'howToFix': "Consider deleting it.", | |
| 2553 'examples': ["class DeadCode {} main() {}"], | |
| 2554 }, | |
| 2555 | |
| 2556 'UNUSED_TYPEDEF': { | |
| 2557 'id': 'JBIPCN', | |
| 2558 'template': "The typedef '#{name}' is never used.", | |
| 2559 'howToFix': "Consider deleting it.", | |
| 2560 'examples': ["typedef DeadCode(); main() {}"], | |
| 2561 }, | |
| 2562 | |
| 2563 'ABSTRACT_METHOD': { | |
| 2564 'id': 'HOKOBG', | |
| 2565 'template': "The method '#{name}' has no implementation in " | |
| 2566 "class '#{class}'.", | |
| 2567 'howToFix': "Try adding a body to '#{name}' or declaring " | |
| 2568 "'#{class}' to be 'abstract'.", | |
| 2569 'examples': [ | |
| 2570 """ | |
| 2571 class Class { | |
| 2572 method(); | |
| 2573 } | |
| 2574 main() => new Class().method(); | |
| 2575 """ | |
| 2576 ], | |
| 2577 }, | |
| 2578 | |
| 2579 'ABSTRACT_GETTER': { | |
| 2580 'id': 'VKTRNK', | |
| 2581 'template': "The getter '#{name}' has no implementation in " | |
| 2582 "class '#{class}'.", | |
| 2583 'howToFix': "Try adding a body to '#{name}' or declaring " | |
| 2584 "'#{class}' to be 'abstract'.", | |
| 2585 'examples': [ | |
| 2586 """ | |
| 2587 class Class { | |
| 2588 get getter; | |
| 2589 } | |
| 2590 main() => new Class(); | |
| 2591 """ | |
| 2592 ], | |
| 2593 }, | |
| 2594 | |
| 2595 'ABSTRACT_SETTER': { | |
| 2596 'id': 'XGDGKK', | |
| 2597 'template': "The setter '#{name}' has no implementation in " | |
| 2598 "class '#{class}'.", | |
| 2599 'howToFix': "Try adding a body to '#{name}' or declaring " | |
| 2600 "'#{class}' to be 'abstract'.", | |
| 2601 'examples': [ | |
| 2602 """ | |
| 2603 class Class { | |
| 2604 set setter(_); | |
| 2605 } | |
| 2606 main() => new Class(); | |
| 2607 """ | |
| 2608 ], | |
| 2609 }, | |
| 2610 | |
| 2611 'INHERIT_GETTER_AND_METHOD': { | |
| 2612 'id': 'UMEUEG', | |
| 2613 'template': "The class '#{class}' can't inherit both getters and methods " | |
| 2614 "by the named '#{name}'.", | |
| 2615 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2616 'examples': [ | |
| 2617 """ | |
| 2618 class A { | |
| 2619 get member => null; | |
| 2620 } | |
| 2621 class B { | |
| 2622 member() {} | |
| 2623 } | |
| 2624 class Class implements A, B { | |
| 2625 } | |
| 2626 main() => new Class(); | |
| 2627 """ | |
| 2628 ], | |
| 2629 }, | |
| 2630 | |
| 2631 'INHERITED_METHOD': { | |
| 2632 'id': 'GMSVBM', | |
| 2633 'template': "The inherited method '#{name}' is declared here in class " | |
| 2634 "'#{class}'.", | |
| 2635 }, | |
| 2636 | |
| 2637 'INHERITED_EXPLICIT_GETTER': { | |
| 2638 'id': 'KKAVRS', | |
| 2639 'template': "The inherited getter '#{name}' is declared here in class " | |
| 2640 "'#{class}'.", | |
| 2641 }, | |
| 2642 | |
| 2643 'INHERITED_IMPLICIT_GETTER': { | |
| 2644 'id': 'JBAMEJ', | |
| 2645 'template': "The inherited getter '#{name}' is implicitly declared by this " | |
| 2646 "field in class '#{class}'.", | |
| 2647 }, | |
| 2648 | |
| 2649 'UNIMPLEMENTED_METHOD_ONE': { | |
| 2650 'id': 'CMCLWO', | |
| 2651 'template': "'#{class}' doesn't implement '#{method}' " | |
| 2652 "declared in '#{declarer}'.", | |
| 2653 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2654 "'#{class}' to be 'abstract'.", | |
| 2655 'examples': [ | |
| 2656 """ | |
| 2657 abstract class I { | |
| 2658 m(); | |
| 2659 } | |
| 2660 class C implements I {} | |
| 2661 main() => new C(); | |
| 2662 """, | |
| 2663 """ | |
| 2664 abstract class I { | |
| 2665 m(); | |
| 2666 } | |
| 2667 class C extends I {} | |
| 2668 main() => new C(); | |
| 2669 """ | |
| 2670 ], | |
| 2671 }, | |
| 2672 | |
| 2673 'UNIMPLEMENTED_METHOD': { | |
| 2674 'id': 'IJSNQB', | |
| 2675 'template': "'#{class}' doesn't implement '#{method}'.", | |
| 2676 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2677 "'#{class}' to be 'abstract'.", | |
| 2678 'examples': [ | |
| 2679 """ | |
| 2680 abstract class I { | |
| 2681 m(); | |
| 2682 } | |
| 2683 | |
| 2684 abstract class J { | |
| 2685 m(); | |
| 2686 } | |
| 2687 | |
| 2688 class C implements I, J {} | |
| 2689 | |
| 2690 main() { | |
| 2691 new C(); | |
| 2692 } | |
| 2693 """, | |
| 2694 """ | |
| 2695 abstract class I { | |
| 2696 m(); | |
| 2697 } | |
| 2698 | |
| 2699 abstract class J { | |
| 2700 m(); | |
| 2701 } | |
| 2702 | |
| 2703 class C extends I implements J {} | |
| 2704 | |
| 2705 main() { | |
| 2706 new C(); | |
| 2707 } | |
| 2708 """ | |
| 2709 ], | |
| 2710 }, | |
| 2711 | |
| 2712 'UNIMPLEMENTED_METHOD_CONT': { | |
| 2713 'id': 'KFBKPO', | |
| 2714 'template': "The method '#{name}' is declared here in class '#{class}'.", | |
| 2715 }, | |
| 2716 | |
| 2717 'UNIMPLEMENTED_SETTER_ONE': { | |
| 2718 'id': 'QGKTEA', | |
| 2719 'template': "'#{class}' doesn't implement the setter '#{name}' " | |
| 2720 "declared in '#{declarer}'.", | |
| 2721 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2722 "'#{class}' to be 'abstract'.", | |
| 2723 'examples': [ | |
| 2724 """ | |
| 2725 abstract class I { | |
| 2726 set m(_); | |
| 2727 } | |
| 2728 class C implements I {} | |
| 2729 class D implements I { | |
| 2730 set m(_) {} | |
| 2731 } | |
| 2732 main() { | |
| 2733 new D().m = 0; | |
| 2734 new C(); | |
| 2735 } | |
| 2736 """ | |
| 2737 ], | |
| 2738 }, | |
| 2739 | |
| 2740 'UNIMPLEMENTED_SETTER': { | |
| 2741 'id': 'VEEGJQ', | |
| 2742 'template': "'#{class}' doesn't implement the setter '#{name}'.", | |
| 2743 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2744 "'#{class}' to be 'abstract'.", | |
| 2745 'examples': [ | |
| 2746 """ | |
| 2747 abstract class I { | |
| 2748 set m(_); | |
| 2749 } | |
| 2750 abstract class J { | |
| 2751 set m(_); | |
| 2752 } | |
| 2753 class C implements I, J {} | |
| 2754 main() => new C(); | |
| 2755 """, | |
| 2756 """ | |
| 2757 abstract class I { | |
| 2758 set m(_); | |
| 2759 } | |
| 2760 abstract class J { | |
| 2761 set m(_); | |
| 2762 } | |
| 2763 class C extends I implements J {} | |
| 2764 main() => new C(); | |
| 2765 """ | |
| 2766 ], | |
| 2767 }, | |
| 2768 | |
| 2769 'UNIMPLEMENTED_EXPLICIT_SETTER': { | |
| 2770 'id': 'SABABA', | |
| 2771 'template': "The setter '#{name}' is declared here in class '#{class}'.", | |
| 2772 }, | |
| 2773 | |
| 2774 'UNIMPLEMENTED_IMPLICIT_SETTER': { | |
| 2775 'id': 'SWESAQ', | |
| 2776 'template': "The setter '#{name}' is implicitly declared by this field " | |
| 2777 "in class '#{class}'.", | |
| 2778 }, | |
| 2779 | |
| 2780 'UNIMPLEMENTED_GETTER_ONE': { | |
| 2781 'id': 'ODEPFW', | |
| 2782 'template': "'#{class}' doesn't implement the getter '#{name}' " | |
| 2783 "declared in '#{declarer}'.", | |
| 2784 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2785 "'#{class}' to be 'abstract'.", | |
| 2786 'examples': [ | |
| 2787 """ | |
| 2788 abstract class I { | |
| 2789 get m; | |
| 2790 } | |
| 2791 class C implements I {} | |
| 2792 main() => new C(); | |
| 2793 """, | |
| 2794 """ | |
| 2795 abstract class I { | |
| 2796 get m; | |
| 2797 } | |
| 2798 class C extends I {} | |
| 2799 main() => new C(); | |
| 2800 """ | |
| 2801 ], | |
| 2802 }, | |
| 2803 | |
| 2804 'UNIMPLEMENTED_GETTER': { | |
| 2805 'id': 'VHSECG', | |
| 2806 'template': "'#{class}' doesn't implement the getter '#{name}'.", | |
| 2807 'howToFix': "Try adding an implementation of '#{name}' or declaring " | |
| 2808 "'#{class}' to be 'abstract'.", | |
| 2809 'examples': [ | |
| 2810 """ | |
| 2811 abstract class I { | |
| 2812 get m; | |
| 2813 } | |
| 2814 abstract class J { | |
| 2815 get m; | |
| 2816 } | |
| 2817 class C implements I, J {} | |
| 2818 main() => new C(); | |
| 2819 """, | |
| 2820 """ | |
| 2821 abstract class I { | |
| 2822 get m; | |
| 2823 } | |
| 2824 abstract class J { | |
| 2825 get m; | |
| 2826 } | |
| 2827 class C extends I implements J {} | |
| 2828 main() => new C(); | |
| 2829 """ | |
| 2830 ], | |
| 2831 }, | |
| 2832 | |
| 2833 'UNIMPLEMENTED_EXPLICIT_GETTER': { | |
| 2834 'id': 'HFDJPP', | |
| 2835 'template': "The getter '#{name}' is declared here in class '#{class}'.", | |
| 2836 }, | |
| 2837 | |
| 2838 'UNIMPLEMENTED_IMPLICIT_GETTER': { | |
| 2839 'id': 'BSCQNO', | |
| 2840 'template': "The getter '#{name}' is implicitly declared by this field " | |
| 2841 "in class '#{class}'.", | |
| 2842 }, | |
| 2843 | |
| 2844 'INVALID_METADATA': { | |
| 2845 'id': 'RKJGDE', | |
| 2846 'template': | |
| 2847 "A metadata annotation must be either a reference to a compile-time " | |
| 2848 "constant variable or a call to a constant constructor.", | |
| 2849 'howToFix': | |
| 2850 "Try using a different constant value or referencing it through a " | |
| 2851 "constant variable.", | |
| 2852 'examples': [ | |
| 2853 '@Object main() {}', | |
| 2854 '@print main() {}'] | |
| 2855 }, | |
| 2856 | |
| 2857 'INVALID_METADATA_GENERIC': { | |
| 2858 'id': 'WEEDQD', | |
| 2859 'template': | |
| 2860 "A metadata annotation using a constant constructor cannot use type " | |
| 2861 "arguments.", | |
| 2862 'howToFix': | |
| 2863 "Try removing the type arguments or referencing the constant " | |
| 2864 "through a constant variable.", | |
| 2865 'examples': [ | |
| 2866 ''' | |
| 2867 class C<T> { | |
| 2868 const C(); | |
| 2869 } | |
| 2870 @C<int>() main() {} | |
| 2871 '''], | |
| 2872 }, | |
| 2873 | |
| 2874 'EQUAL_MAP_ENTRY_KEY': { | |
| 2875 'id': 'KIDLPM', | |
| 2876 'template': "An entry with the same key already exists in the map.", | |
| 2877 'howToFix': "Try removing the previous entry or changing the key in one " | |
| 2878 "of the entries.", | |
| 2879 'examples': [ | |
| 2880 """ | |
| 2881 main() { | |
| 2882 var m = const {'foo': 1, 'foo': 2}; | |
| 2883 }""" | |
| 2884 ], | |
| 2885 }, | |
| 2886 | |
| 2887 'BAD_INPUT_CHARACTER': { | |
| 2888 'id': 'SHQWJY', | |
| 2889 'template': "Character U+#{characterHex} isn't allowed here.", | |
| 2890 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2891 'examples': [ | |
| 2892 """ | |
| 2893 main() { | |
| 2894 String x = ç; | |
| 2895 } | |
| 2896 """ | |
| 2897 ], | |
| 2898 }, | |
| 2899 | |
| 2900 'UNTERMINATED_STRING': { | |
| 2901 'id': 'TRLTHK', | |
| 2902 'template': "String must end with #{quote}.", | |
| 2903 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2904 'examples': [ | |
| 2905 """ | |
| 2906 main() { | |
| 2907 return ' | |
| 2908 ; | |
| 2909 } | |
| 2910 """, | |
| 2911 """ | |
| 2912 main() { | |
| 2913 return \" | |
| 2914 ; | |
| 2915 } | |
| 2916 """, | |
| 2917 """ | |
| 2918 main() { | |
| 2919 return r' | |
| 2920 ; | |
| 2921 } | |
| 2922 """, | |
| 2923 """ | |
| 2924 main() { | |
| 2925 return r\" | |
| 2926 ; | |
| 2927 } | |
| 2928 """, | |
| 2929 """ | |
| 2930 main() => ''' | |
| 2931 """, | |
| 2932 """ | |
| 2933 main() => \"\"\" | |
| 2934 """, | |
| 2935 """ | |
| 2936 main() => r''' | |
| 2937 """, | |
| 2938 """ | |
| 2939 main() => r\"\"\" | |
| 2940 """ | |
| 2941 ], | |
| 2942 }, | |
| 2943 | |
| 2944 'UNMATCHED_TOKEN': { | |
| 2945 'id': 'AGJKMQ', | |
| 2946 'template': "Can't find '#{end}' to match '#{begin}'.", | |
| 2947 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 2948 'examples': ["main(", "main(){", "main(){]}",], | |
| 2949 }, | |
| 2950 | |
| 2951 'UNTERMINATED_TOKEN': { | |
| 2952 'id': 'VIIXHQ', | |
| 2953 'template': | |
| 2954 // This is a fall-back message that shouldn't happen. | |
| 2955 "Incomplete token.", | |
| 2956 }, | |
| 2957 | |
| 2958 'EXPONENT_MISSING': { | |
| 2959 'id': 'CXPLCR', | |
| 2960 'template': | |
| 2961 "Numbers in exponential notation should always contain an exponent" | |
| 2962 " (an integer number with an optional sign).", | |
| 2963 'howToFix': "Make sure there is an exponent, and remove any whitespace " | |
| 2964 "before it.", | |
| 2965 'examples': [ | |
| 2966 """ | |
| 2967 main() { | |
| 2968 var i = 1e; | |
| 2969 } | |
| 2970 """ | |
| 2971 ], | |
| 2972 }, | |
| 2973 | |
| 2974 'HEX_DIGIT_EXPECTED': { | |
| 2975 'id': 'GKCAGV', | |
| 2976 'template': "A hex digit (0-9 or A-F) must follow '0x'.", | |
| 2977 'howToFix': DONT_KNOW_HOW_TO_FIX, // Seems obvious from the error message. | |
| 2978 'examples': [ | |
| 2979 """ | |
| 2980 main() { | |
| 2981 var i = 0x; | |
| 2982 } | |
| 2983 """ | |
| 2984 ], | |
| 2985 }, | |
| 2986 | |
| 2987 'MALFORMED_STRING_LITERAL': { | |
| 2988 'id': 'DULNSD', | |
| 2989 'template': | |
| 2990 r"A '$' has special meaning inside a string, and must be followed by " | |
| 2991 "an identifier or an expression in curly braces ({}).", | |
| 2992 'howToFix': r"Try adding a backslash (\) to escape the '$'.", | |
| 2993 'examples': [ | |
| 2994 r""" | |
| 2995 main() { | |
| 2996 return '$'; | |
| 2997 } | |
| 2998 """, | |
| 2999 r''' | |
| 3000 main() { | |
| 3001 return "$"; | |
| 3002 } | |
| 3003 ''', | |
| 3004 r""" | |
| 3005 main() { | |
| 3006 return '''$'''; | |
| 3007 } | |
| 3008 """, | |
| 3009 r''' | |
| 3010 main() { | |
| 3011 return """$"""; | |
| 3012 } | |
| 3013 ''' | |
| 3014 ], | |
| 3015 }, | |
| 3016 | |
| 3017 'UNTERMINATED_COMMENT': { | |
| 3018 'id': 'NECJNM', | |
| 3019 'template': "Comment starting with '/*' must end with '*/'.", | |
| 3020 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 3021 'examples': [ | |
| 3022 r""" | |
| 3023 main() { | |
| 3024 } | |
| 3025 /*""" | |
| 3026 ], | |
| 3027 }, | |
| 3028 | |
| 3029 'MISSING_TOKEN_BEFORE_THIS': { | |
| 3030 'id': 'AFKXGU', | |
| 3031 'template': "Expected '#{token}' before this.", | |
| 3032 // Consider the second example below: the parser expects a ')' before | |
| 3033 // 'y', but a ',' would also have worked. We don't have enough | |
| 3034 // information to give a good suggestion. | |
| 3035 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 3036 'examples': ["main() => true ? 1;", "main() => foo(x: 1 y: 2);",], | |
| 3037 }, | |
| 3038 | |
| 3039 'MISSING_TOKEN_AFTER_THIS': { | |
| 3040 'id': 'FMUFJL', | |
| 3041 'template': "Expected '#{token}' after this.", | |
| 3042 // See [MISSING_TOKEN_BEFORE_THIS], we don't have enough information | |
| 3043 // to give a good suggestion. | |
| 3044 'howToFix': DONT_KNOW_HOW_TO_FIX, | |
| 3045 'examples': [ | |
| 3046 "main(x) {x}", | |
| 3047 """ | |
| 3048 class S1 {} | |
| 3049 class S2 {} | |
| 3050 class S3 {} | |
| 3051 class A = S1 with S2, S3 | |
| 3052 main() => new A(); | |
| 3053 """ | |
| 3054 ], | |
| 3055 }, | |
| 3056 | |
| 3057 'CONSIDER_ANALYZE_ALL': { | |
| 3058 'id': 'HHILSH', | |
| 3059 'template': "Could not find '#{main}'. Nothing will be analyzed.", | |
| 3060 'howToFix': "Try using '--analyze-all' to analyze everything.", | |
| 3061 'examples': [''], | |
| 3062 }, | |
| 3063 | |
| 3064 'MISSING_MAIN': { | |
| 3065 'id': 'HNAOPV', | |
| 3066 'template': "Could not find '#{main}'.", | |
| 3067 // No example, test uses '--analyze-only' which will produce the above | |
| 3068 // message [CONSIDER_ANALYZE_ALL]. An example for a human operator | |
| 3069 // would be an empty file. | |
| 3070 'howToFix': "Try adding a method named '#{main}' to your program." | |
| 3071 }, | |
| 3072 | |
| 3073 'MAIN_NOT_A_FUNCTION': { | |
| 3074 'id': 'PIURPA', | |
| 3075 'template': "'#{main}' is not a function.", | |
| 3076 'howToFix': DONT_KNOW_HOW_TO_FIX, // Don't state the obvious. | |
| 3077 'examples': ['var main;'], | |
| 3078 }, | |
| 3079 | |
| 3080 'MAIN_WITH_EXTRA_PARAMETER': { | |
| 3081 'id': 'ONOGQB', | |
| 3082 'template': "'#{main}' cannot have more than two parameters.", | |
| 3083 'howToFix': DONT_KNOW_HOW_TO_FIX, // Don't state the obvious. | |
| 3084 'examples': ['main(a, b, c) {}'], | |
| 3085 }, | |
| 3086 | |
| 3087 'COMPILER_CRASHED': { | |
| 3088 'id': 'MHDWAV', | |
| 3089 'template': "The compiler crashed when compiling this element.", | |
| 3090 }, | |
| 3091 | |
| 3092 'PLEASE_REPORT_THE_CRASH': { | |
| 3093 'id': 'UUTHXX', | |
| 3094 'template': ''' | |
| 3095 The compiler is broken. | |
| 3096 | |
| 3097 When compiling the above element, the compiler crashed. It is not | |
| 3098 possible to tell if this is caused by a problem in your program or | |
| 3099 not. Regardless, the compiler should not crash. | |
| 3100 | |
| 3101 The Dart team would greatly appreciate if you would take a moment to | |
| 3102 report this problem at http://dartbug.com/new. | |
| 3103 | |
| 3104 Please include the following information: | |
| 3105 | |
| 3106 * the name and version of your operating system, | |
| 3107 | |
| 3108 * the Dart SDK build number (#{buildId}), and | |
| 3109 | |
| 3110 * the entire message you see here (including the full stack trace | |
| 3111 below as well as the source location above). | |
| 3112 ''', | |
| 3113 }, | |
| 3114 | |
| 3115 'POTENTIAL_MUTATION': { | |
| 3116 'id': 'YGNLLB', | |
| 3117 'template': "Variable '#{variableName}' is not known to be of type " | |
| 3118 "'#{shownType}' because it is potentially mutated in the scope for " | |
| 3119 "promotion.", | |
| 3120 }, | |
| 3121 | |
| 3122 'POTENTIAL_MUTATION_HERE': { | |
| 3123 'id': 'ATMSVX', | |
| 3124 'template': "Variable '#{variableName}' is potentially mutated here.", | |
| 3125 }, | |
| 3126 | |
| 3127 'POTENTIAL_MUTATION_IN_CLOSURE': { | |
| 3128 'id': 'XUAHTW', | |
| 3129 'template': "Variable '#{variableName}' is not known to be of type " | |
| 3130 "'#{shownType}' because it is potentially mutated within a closure.", | |
| 3131 }, | |
| 3132 | |
| 3133 'POTENTIAL_MUTATION_IN_CLOSURE_HERE': { | |
| 3134 'id': 'UHFXLG', | |
| 3135 'template': "Variable '#{variableName}' is potentially mutated in a " | |
| 3136 "closure here.", | |
| 3137 }, | |
| 3138 | |
| 3139 'ACCESSED_IN_CLOSURE': { | |
| 3140 'id': 'JJHKSF', | |
| 3141 'template': "Variable '#{variableName}' is not known to be of type " | |
| 3142 "'#{shownType}' because it is accessed by a closure in the scope for " | |
| 3143 "promotion and potentially mutated in the scope of " | |
| 3144 "'#{variableName}'.", | |
| 3145 }, | |
| 3146 | |
| 3147 'ACCESSED_IN_CLOSURE_HERE': { | |
| 3148 'id': 'KMJVEA', | |
| 3149 'template': "Variable '#{variableName}' is accessed in a closure here.", | |
| 3150 }, | |
| 3151 | |
| 3152 'NOT_MORE_SPECIFIC': { | |
| 3153 'id': 'EJHQAG', | |
| 3154 'template': "Variable '#{variableName}' is not shown to have type " | |
| 3155 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
| 3156 "known type '#{knownType}' of '#{variableName}'.", | |
| 3157 }, | |
| 3158 | |
| 3159 'NOT_MORE_SPECIFIC_SUBTYPE': { | |
| 3160 'id': 'APICDL', | |
| 3161 'template': "Variable '#{variableName}' is not shown to have type " | |
| 3162 "'#{shownType}' because '#{shownType}' is not a subtype of the " | |
| 3163 "known type '#{knownType}' of '#{variableName}'.", | |
| 3164 }, | |
| 3165 | |
| 3166 'NOT_MORE_SPECIFIC_SUGGESTION': { | |
| 3167 'id': 'FFNCJX', | |
| 3168 'template': "Variable '#{variableName}' is not shown to have type " | |
| 3169 "'#{shownType}' because '#{shownType}' is not more specific than the " | |
| 3170 "known type '#{knownType}' of '#{variableName}'.", | |
| 3171 'howToFix': "Try replacing '#{shownType}' with '#{shownTypeSuggestion}'.", | |
| 3172 }, | |
| 3173 | |
| 3174 'NO_COMMON_SUBTYPES': { | |
| 3175 'id': 'XKJOEC', | |
| 3176 'template': "Types '#{left}' and '#{right}' have no common subtypes.", | |
| 3177 }, | |
| 3178 | |
| 3179 'HIDDEN_WARNINGS_HINTS': { | |
| 3180 'id': 'JBAWEK', | |
| 3181 'template': | |
| 3182 "#{warnings} warning(s) and #{hints} hint(s) suppressed in #{uri}.", | |
| 3183 }, | |
| 3184 | |
| 3185 'HIDDEN_WARNINGS': { | |
| 3186 'id': 'JIYWDC', | |
| 3187 'template': "#{warnings} warning(s) suppressed in #{uri}.", | |
| 3188 }, | |
| 3189 | |
| 3190 'HIDDEN_HINTS': { | |
| 3191 'id': 'RHNXQT', | |
| 3192 'template': "#{hints} hint(s) suppressed in #{uri}.", | |
| 3193 }, | |
| 3194 | |
| 3195 'PREAMBLE': { | |
| 3196 'id': 'GXGWIF', | |
| 3197 'template': "When run on the command-line, the compiled output might" | |
| 3198 " require a preamble file located in:\n" | |
| 3199 " <sdk>/lib/_internal/js_runtime/lib/preambles.", | |
| 3200 }, | |
| 3201 | |
| 3202 'INVALID_SYNC_MODIFIER': { | |
| 3203 'id': 'FNYUYU', | |
| 3204 'template': "Invalid modifier 'sync'.", | |
| 3205 'howToFix': "Try replacing 'sync' with 'sync*'.", | |
| 3206 'examples': ["main() sync {}"], | |
| 3207 }, | |
| 3208 | |
| 3209 'INVALID_AWAIT_FOR': { | |
| 3210 'id': 'IEYGCY', | |
| 3211 'template': "'await' is only supported on for-in loops.", | |
| 3212 'howToFix': "Try rewriting the loop as a for-in loop or removing the " | |
| 3213 "'await' keyword.", | |
| 3214 'examples': [ | |
| 3215 """ | |
| 3216 main() async* { | |
| 3217 await for (int i = 0; i < 10; i++) {} | |
| 3218 } | |
| 3219 """ | |
| 3220 ], | |
| 3221 }, | |
| 3222 | |
| 3223 'INVALID_AWAIT_FOR_IN': { | |
| 3224 'id': 'FIEYGC', | |
| 3225 'template': "'await' is only supported in methods with an 'async' or " | |
| 3226 "'async*' body modifier.", | |
| 3227 'howToFix': "Try adding 'async' or 'async*' to the method body or " | |
| 3228 "removing the 'await' keyword.", | |
| 3229 'examples': [ | |
| 3230 """ | |
| 3231 main(o) sync* { | |
| 3232 await for (var e in o) {} | |
| 3233 } | |
| 3234 """ | |
| 3235 ], | |
| 3236 }, | |
| 3237 | |
| 3238 'INVALID_AWAIT': { | |
| 3239 'id': 'IEYHYD', | |
| 3240 'template': "'await' is only supported in methods with an 'async' or " | |
| 3241 "'async*' body modifier.", | |
| 3242 'howToFix': "Try adding 'async' or 'async*' to the method body.", | |
| 3243 'examples': [ | |
| 3244 """ | |
| 3245 main() sync* { | |
| 3246 await null; | |
| 3247 } | |
| 3248 """ | |
| 3249 ], | |
| 3250 }, | |
| 3251 | |
| 3252 'INVALID_YIELD': { | |
| 3253 'id': 'IPGGCY', | |
| 3254 'template': "'yield' is only supported in methods with a 'sync*' or " | |
| 3255 "'async*' body modifier.", | |
| 3256 'howToFix': "Try adding 'sync*' or 'async*' to the method body.", | |
| 3257 'examples': [ | |
| 3258 """ | |
| 3259 main() async { | |
| 3260 yield 0; | |
| 3261 } | |
| 3262 """ | |
| 3263 ], | |
| 3264 }, | |
| 3265 | |
| 3266 'ASYNC_MODIFIER_ON_ABSTRACT_METHOD': { | |
| 3267 'id': 'VRISLY', | |
| 3268 'template': | |
| 3269 "The modifier '#{modifier}' is not allowed on an abstract method.", | |
| 3270 'options': ['--enable-async'], | |
| 3271 'howToFix': "Try removing the '#{modifier}' modifier or adding a " | |
| 3272 "body to the method.", | |
| 3273 'examples': [ | |
| 3274 """ | |
| 3275 abstract class A { | |
| 3276 method() async; | |
| 3277 } | |
| 3278 class B extends A { | |
| 3279 method() {} | |
| 3280 } | |
| 3281 main() { | |
| 3282 A a = new B(); | |
| 3283 a.method(); | |
| 3284 } | |
| 3285 """ | |
| 3286 ], | |
| 3287 }, | |
| 3288 | |
| 3289 'ASYNC_MODIFIER_ON_CONSTRUCTOR': { | |
| 3290 'id': 'DHCFON', | |
| 3291 'template': "The modifier '#{modifier}' is not allowed on constructors.", | |
| 3292 'options': ['--enable-async'], | |
| 3293 'howToFix': "Try removing the '#{modifier}' modifier.", | |
| 3294 'examples': [ | |
| 3295 """ | |
| 3296 class A { | |
| 3297 A() async; | |
| 3298 } | |
| 3299 main() => new A();""", | |
| 3300 """ | |
| 3301 class A { | |
| 3302 A(); | |
| 3303 factory A.a() async* {} | |
| 3304 } | |
| 3305 main() => new A.a();""" | |
| 3306 ], | |
| 3307 }, | |
| 3308 | |
| 3309 'ASYNC_MODIFIER_ON_SETTER': { | |
| 3310 'id': 'NMJLJE', | |
| 3311 'template': "The modifier '#{modifier}' is not allowed on setters.", | |
| 3312 'options': ['--enable-async'], | |
| 3313 'howToFix': "Try removing the '#{modifier}' modifier.", | |
| 3314 'examples': [ | |
| 3315 """ | |
| 3316 class A { | |
| 3317 set foo(v) async {} | |
| 3318 } | |
| 3319 main() => new A().foo = 0;""" | |
| 3320 ], | |
| 3321 }, | |
| 3322 | |
| 3323 'YIELDING_MODIFIER_ON_ARROW_BODY': { | |
| 3324 'id': 'UOGLUX', | |
| 3325 'template': | |
| 3326 "The modifier '#{modifier}' is not allowed on methods implemented " | |
| 3327 "using '=>'.", | |
| 3328 'options': ['--enable-async'], | |
| 3329 'howToFix': "Try removing the '#{modifier}' modifier or implementing " | |
| 3330 "the method body using a block: '{ ... }'.", | |
| 3331 'examples': ["main() sync* => null;", "main() async* => null;"], | |
| 3332 }, | |
| 3333 | |
| 3334 // TODO(johnniwinther): Check for 'async' as identifier. | |
| 3335 'ASYNC_KEYWORD_AS_IDENTIFIER': { | |
| 3336 'id': 'VTWSMA', | |
| 3337 'template': | |
| 3338 "'#{keyword}' cannot be used as an identifier in a function body " | |
| 3339 "marked with '#{modifier}'.", | |
| 3340 'options': ['--enable-async'], | |
| 3341 'howToFix': "Try removing the '#{modifier}' modifier or renaming the " | |
| 3342 "identifier.", | |
| 3343 'examples': [ | |
| 3344 """ | |
| 3345 main() async { | |
| 3346 var await; | |
| 3347 }""", | |
| 3348 """ | |
| 3349 main() async* { | |
| 3350 var yield; | |
| 3351 }""", | |
| 3352 """ | |
| 3353 main() sync* { | |
| 3354 var yield; | |
| 3355 }""" | |
| 3356 ], | |
| 3357 }, | |
| 3358 | |
| 3359 'RETURN_IN_GENERATOR': { | |
| 3360 'id': 'AWGUVF', | |
| 3361 'template': | |
| 3362 "'return' with a value is not allowed in a method body using the " | |
| 3363 "'#{modifier}' modifier.", | |
| 3364 'howToFix': "Try removing the value, replacing 'return' with 'yield' " | |
| 3365 "or changing the method body modifier.", | |
| 3366 'examples': [ | |
| 3367 """ | |
| 3368 foo() async* { return 0; } | |
| 3369 main() => foo(); | |
| 3370 """, | |
| 3371 """ | |
| 3372 foo() sync* { return 0; } | |
| 3373 main() => foo(); | |
| 3374 """ | |
| 3375 ], | |
| 3376 }, | |
| 3377 | |
| 3378 'NATIVE_NOT_SUPPORTED': { | |
| 3379 'id': 'QMMLUT', | |
| 3380 'template': "'native' modifier is not supported.", | |
| 3381 'howToFix': "Try removing the 'native' implementation or analyzing the " | |
| 3382 "code with the --allow-native-extensions option.", | |
| 3383 'examples': [ | |
| 3384 """ | |
| 3385 main() native "Main"; | |
| 3386 """ | |
| 3387 ], | |
| 3388 }, | |
| 3389 | |
| 3390 'DART_EXT_NOT_SUPPORTED': { | |
| 3391 'id': 'JLPQFJ', | |
| 3392 'template': "The 'dart-ext' scheme is not supported.", | |
| 3393 'howToFix': "Try analyzing the code with the --allow-native-extensions " | |
| 3394 "option.", | |
| 3395 'examples': [ | |
| 3396 """ | |
| 3397 import 'dart-ext:main'; | |
| 3398 | |
| 3399 main() {} | |
| 3400 """ | |
| 3401 ], | |
| 3402 }, | |
| 3403 | |
| 3404 'LIBRARY_TAG_MUST_BE_FIRST': { | |
| 3405 'id': 'JFUSRX', | |
| 3406 'template': | |
| 3407 "The library declaration should come before other declarations.", | |
| 3408 'howToFix': "Try moving the declaration to the top of the file.", | |
| 3409 'examples': [ | |
| 3410 """ | |
| 3411 import 'dart:core'; | |
| 3412 library foo; | |
| 3413 main() {} | |
| 3414 """, | |
| 3415 ], | |
| 3416 }, | |
| 3417 | |
| 3418 'ONLY_ONE_LIBRARY_TAG': { | |
| 3419 'id': 'CCXFMY', | |
| 3420 'template': "There can only be one library declaration.", | |
| 3421 'howToFix': "Try removing all other library declarations.", | |
| 3422 'examples': [ | |
| 3423 """ | |
| 3424 library foo; | |
| 3425 library bar; | |
| 3426 main() {} | |
| 3427 """, | |
| 3428 """ | |
| 3429 library foo; | |
| 3430 import 'dart:core'; | |
| 3431 library bar; | |
| 3432 main() {} | |
| 3433 """, | |
| 3434 ], | |
| 3435 }, | |
| 3436 | |
| 3437 'IMPORT_BEFORE_PARTS': { | |
| 3438 'id': 'NSMOQI', | |
| 3439 'template': "Import declarations should come before parts.", | |
| 3440 'howToFix': "Try moving this import further up in the file.", | |
| 3441 'examples': [ | |
| 3442 { | |
| 3443 'main.dart': """ | |
| 3444 library test.main; | |
| 3445 part 'part.dart'; | |
| 3446 import 'dart:core'; | |
| 3447 main() {} | |
| 3448 """, | |
| 3449 'part.dart': """ | |
| 3450 part of test.main; | |
| 3451 """, | |
| 3452 } | |
| 3453 ], | |
| 3454 }, | |
| 3455 | |
| 3456 'EXPORT_BEFORE_PARTS': { | |
| 3457 'id': 'KYJTTC', | |
| 3458 'template': "Export declarations should come before parts.", | |
| 3459 'howToFix': "Try moving this export further up in the file.", | |
| 3460 'examples': [ | |
| 3461 { | |
| 3462 'main.dart': """ | |
| 3463 library test.main; | |
| 3464 part 'part.dart'; | |
| 3465 export 'dart:core'; | |
| 3466 main() {} | |
| 3467 """, | |
| 3468 'part.dart': """ | |
| 3469 part of test.main; | |
| 3470 """, | |
| 3471 } | |
| 3472 ], | |
| 3473 | |
| 3474 ////////////////////////////////////////////////////////////////////////////// | |
| 3475 // Patch errors start. | |
| 3476 ////////////////////////////////////////////////////////////////////////////// | |
| 3477 }, | |
| 3478 | |
| 3479 'PATCH_RETURN_TYPE_MISMATCH': { | |
| 3480 'id': 'DTOQDU', | |
| 3481 'template': "Patch return type '#{patchReturnType}' does not match " | |
| 3482 "'#{originReturnType}' on origin method '#{methodName}'.", | |
| 3483 }, | |
| 3484 | |
| 3485 'PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH': { | |
| 3486 'id': 'KJUUYC', | |
| 3487 'template': "Required parameter count of patch method " | |
| 3488 "(#{patchParameterCount}) does not match parameter count on origin " | |
| 3489 "method '#{methodName}' (#{originParameterCount}).", | |
| 3490 }, | |
| 3491 | |
| 3492 'PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH': { | |
| 3493 'id': 'GUTGTE', | |
| 3494 'template': "Optional parameter count of patch method " | |
| 3495 "(#{patchParameterCount}) does not match parameter count on origin " | |
| 3496 "method '#{methodName}' (#{originParameterCount}).", | |
| 3497 }, | |
| 3498 | |
| 3499 'PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH': { | |
| 3500 'id': 'MCHEIC', | |
| 3501 'template': "Optional parameters of origin and patch method " | |
| 3502 "'#{methodName}' must both be either named or positional.", | |
| 3503 }, | |
| 3504 | |
| 3505 'PATCH_PARAMETER_MISMATCH': { | |
| 3506 'id': 'XISHPB', | |
| 3507 'template': "Patch method parameter '#{patchParameter}' does not match " | |
| 3508 "'#{originParameter}' on origin method '#{methodName}'.", | |
| 3509 }, | |
| 3510 | |
| 3511 'PATCH_PARAMETER_TYPE_MISMATCH': { | |
| 3512 'id': 'UGRBYD', | |
| 3513 'template': "Patch method parameter '#{parameterName}' type " | |
| 3514 "'#{patchParameterType}' does not match '#{originParameterType}' on " | |
| 3515 "origin method '#{methodName}'.", | |
| 3516 }, | |
| 3517 | |
| 3518 'PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION': { | |
| 3519 'id': 'WSNMKD', | |
| 3520 'template': "External method without an implementation.", | |
| 3521 }, | |
| 3522 | |
| 3523 'PATCH_POINT_TO_FUNCTION': { | |
| 3524 'id': 'CAVBPN', | |
| 3525 'template': "This is the function patch '#{functionName}'.", | |
| 3526 }, | |
| 3527 | |
| 3528 'PATCH_POINT_TO_CLASS': { | |
| 3529 'id': 'TWDLDX', | |
| 3530 'template': "This is the class patch '#{className}'.", | |
| 3531 }, | |
| 3532 | |
| 3533 'PATCH_POINT_TO_GETTER': { | |
| 3534 'id': 'TRBBNY', | |
| 3535 'template': "This is the getter patch '#{getterName}'.", | |
| 3536 }, | |
| 3537 | |
| 3538 'PATCH_POINT_TO_SETTER': { | |
| 3539 'id': 'DAXDLW', | |
| 3540 'template': "This is the setter patch '#{setterName}'.", | |
| 3541 }, | |
| 3542 | |
| 3543 'PATCH_POINT_TO_CONSTRUCTOR': { | |
| 3544 'id': 'VYQISY', | |
| 3545 'template': "This is the constructor patch '#{constructorName}'.", | |
| 3546 }, | |
| 3547 | |
| 3548 'PATCH_POINT_TO_PARAMETER': { | |
| 3549 'id': 'TFPAGO', | |
| 3550 'template': "This is the patch parameter '#{parameterName}'.", | |
| 3551 }, | |
| 3552 | |
| 3553 'PATCH_NON_EXISTING': { | |
| 3554 'id': 'AWOACF', | |
| 3555 'template': "Origin does not exist for patch '#{name}'.", | |
| 3556 }, | |
| 3557 | |
| 3558 // TODO(ahe): Eventually, this error should be removed as it will be | |
| 3559 // handled by the regular parser. | |
| 3560 'PATCH_NONPATCHABLE': { | |
| 3561 'id': 'WQEPJI', | |
| 3562 'template': "Only classes and functions can be patched.", | |
| 3563 }, | |
| 3564 | |
| 3565 'PATCH_NON_EXTERNAL': { | |
| 3566 'id': 'MHLXNK', | |
| 3567 'template': "Only external functions can be patched.", | |
| 3568 }, | |
| 3569 | |
| 3570 'PATCH_NON_CLASS': { | |
| 3571 'id': 'UIALAB', | |
| 3572 'template': "Patching non-class with class patch '#{className}'.", | |
| 3573 }, | |
| 3574 | |
| 3575 'PATCH_NON_GETTER': { | |
| 3576 'id': 'VTNQCJ', | |
| 3577 'template': "Cannot patch non-getter '#{name}' with getter patch.", | |
| 3578 }, | |
| 3579 | |
| 3580 'PATCH_NO_GETTER': { | |
| 3581 'id': 'XOPDHD', | |
| 3582 'template': "No getter found for getter patch '#{getterName}'.", | |
| 3583 }, | |
| 3584 | |
| 3585 'PATCH_NON_SETTER': { | |
| 3586 'id': 'XBOMMN', | |
| 3587 'template': "Cannot patch non-setter '#{name}' with setter patch.", | |
| 3588 }, | |
| 3589 | |
| 3590 'PATCH_NO_SETTER': { | |
| 3591 'id': 'YITARQ', | |
| 3592 'template': "No setter found for setter patch '#{setterName}'.", | |
| 3593 }, | |
| 3594 | |
| 3595 'PATCH_NON_CONSTRUCTOR': { | |
| 3596 'id': 'TWAEQV', | |
| 3597 'template': "Cannot patch non-constructor with constructor patch " | |
| 3598 "'#{constructorName}'.", | |
| 3599 }, | |
| 3600 | |
| 3601 'PATCH_NON_FUNCTION': { | |
| 3602 'id': 'EDXBPI', | |
| 3603 'template': "Cannot patch non-function with function patch " | |
| 3604 "'#{functionName}'.", | |
| 3605 }, | |
| 3606 | |
| 3607 'INJECTED_PUBLIC_MEMBER': { | |
| 3608 'id': 'JGMXMI', | |
| 3609 'template': "Non-patch members in patch libraries must be private.", | |
| 3610 }, | |
| 3611 | |
| 3612 'EXTERNAL_WITH_BODY': { | |
| 3613 'id': 'GAVMSQ', | |
| 3614 'template': | |
| 3615 "External function '#{functionName}' cannot have a function body.", | |
| 3616 'options': ["--output-type=dart"], | |
| 3617 'howToFix': "Try removing the 'external' modifier or the function body.", | |
| 3618 'examples': [ | |
| 3619 """ | |
| 3620 external foo() => 0; | |
| 3621 main() => foo(); | |
| 3622 """, | |
| 3623 """ | |
| 3624 external foo() {} | |
| 3625 main() => foo(); | |
| 3626 """ | |
| 3627 ], | |
| 3628 | |
| 3629 ////////////////////////////////////////////////////////////////////////////// | |
| 3630 // Patch errors end. | |
| 3631 ////////////////////////////////////////////////////////////////////////////// | |
| 3632 }, | |
| 3633 | |
| 3634 'EXPERIMENTAL_ASSERT_MESSAGE': { | |
| 3635 'id': 'NENGIS', | |
| 3636 'template': "Experimental language feature 'assertion with message'" | |
| 3637 " is not supported.", | |
| 3638 'howToFix': | |
| 3639 "Use option '--assert-message' to use assertions with messages.", | |
| 3640 'examples': [ | |
| 3641 r''' | |
| 3642 main() { | |
| 3643 int n = -7; | |
| 3644 assert(n > 0, 'must be positive: $n'); | |
| 3645 } | |
| 3646 ''' | |
| 3647 ], | |
| 3648 }, | |
| 3649 | |
| 3650 'IMPORT_EXPERIMENTAL_MIRRORS': { | |
| 3651 'id': 'SCJYPH', | |
| 3652 'template': ''' | |
| 3653 | |
| 3654 **************************************************************** | |
| 3655 * WARNING: dart:mirrors support in dart2js is experimental, | |
| 3656 * and not recommended. | |
| 3657 * This implementation of mirrors is incomplete, | |
| 3658 * and often greatly increases the size of the generated | |
| 3659 * JavaScript code. | |
| 3660 * | |
| 3661 * Your app imports dart:mirrors via:''' | |
| 3662 ''' | |
| 3663 $IMPORT_EXPERIMENTAL_MIRRORS_PADDING#{importChain} | |
| 3664 * | |
| 3665 * You can disable this message by using the --enable-experimental-mirrors | |
| 3666 * command-line flag. | |
| 3667 * | |
| 3668 * To learn what to do next, please visit: | |
| 3669 * http://dartlang.org/dart2js-reflection | |
| 3670 **************************************************************** | |
| 3671 ''', | |
| 3672 }, | |
| 3673 | |
| 3674 'DISALLOWED_LIBRARY_IMPORT': { | |
| 3675 'id': 'OCSFJU', | |
| 3676 'template': ''' | |
| 3677 Your app imports the unsupported library '#{uri}' via: | |
| 3678 ''' | |
| 3679 ''' | |
| 3680 $DISALLOWED_LIBRARY_IMPORT_PADDING#{importChain} | |
| 3681 | |
| 3682 Use the --categories option to support import of '#{uri}'. | |
| 3683 ''', | |
| 3684 }, | |
| 3685 | |
| 3686 'MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND': { | |
| 3687 'id': 'JBTRRM', | |
| 3688 'template': """ | |
| 3689 dart:mirrors library is not supported when using this backend. | |
| 3690 | |
| 3691 Your app imports dart:mirrors via:""" | |
| 3692 """ | |
| 3693 $MIRRORS_NOT_SUPPORTED_BY_BACKEND_PADDING#{importChain}""", | |
| 3694 }, | |
| 3695 | |
| 3696 'CALL_NOT_SUPPORTED_ON_NATIVE_CLASS': { | |
| 3697 'id': 'HAULDW', | |
| 3698 'template': "Non-supported 'call' member on a native class, or a " | |
| 3699 "subclass of a native class.", | |
| 3700 }, | |
| 3701 | |
| 3702 'DIRECTLY_THROWING_NSM': { | |
| 3703 'id': 'XLTPCS', | |
| 3704 'template': "This 'noSuchMethod' implementation is guaranteed to throw an " | |
| 3705 "exception. The generated code will be smaller if it is " | |
| 3706 "rewritten.", | |
| 3707 'howToFix': "Rewrite to " | |
| 3708 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'.", | |
| 3709 }, | |
| 3710 | |
| 3711 'COMPLEX_THROWING_NSM': { | |
| 3712 'id': 'PLCXVX', | |
| 3713 'template': "This 'noSuchMethod' implementation is guaranteed to throw an " | |
| 3714 "exception. The generated code will be smaller and the compiler " | |
| 3715 "will be able to perform more optimizations if it is rewritten.", | |
| 3716 'howToFix': "Rewrite to " | |
| 3717 "'noSuchMethod(Invocation i) => super.noSuchMethod(i);'.", | |
| 3718 }, | |
| 3719 | |
| 3720 'COMPLEX_RETURNING_NSM': { | |
| 3721 'id': 'HUTCTQ', | |
| 3722 'template': "Overriding 'noSuchMethod' causes the compiler to generate " | |
| 3723 "more code and prevents the compiler from doing some optimizations.", | |
| 3724 'howToFix': "Consider removing this 'noSuchMethod' implementation." | |
| 3725 }, | |
| 3726 | |
| 3727 'UNRECOGNIZED_VERSION_OF_LOOKUP_MAP': { | |
| 3728 'id': 'OVAFEW', | |
| 3729 'template': "Unsupported version of package:lookup_map.", | |
| 3730 'howToFix': DONT_KNOW_HOW_TO_FIX | |
| 3731 }, | |
| 3732 }; | |
| OLD | NEW |