| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * Check that [annotations] contains a single entry which is a reference to | 211 * Check that [annotations] contains a single entry which is a reference to |
| 212 * a top level variable called `a` in the current library. | 212 * a top level variable called `a` in the current library. |
| 213 */ | 213 */ |
| 214 void checkAnnotationA(List<UnlinkedExpr> annotations) { | 214 void checkAnnotationA(List<UnlinkedExpr> annotations) { |
| 215 expect(annotations, hasLength(1)); | 215 expect(annotations, hasLength(1)); |
| 216 assertUnlinkedConst(annotations[0], operators: [ | 216 assertUnlinkedConst(annotations[0], operators: [ |
| 217 UnlinkedExprOperation.pushReference | 217 UnlinkedExprOperation.pushReference |
| 218 ], referenceValidators: [ | 218 ], referenceValidators: [ |
| 219 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 219 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 220 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 220 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 221 ]); | 221 ]); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void checkConstCycle(String className, | 224 void checkConstCycle(String className, |
| 225 {String name: '', bool hasCycle: true}) { | 225 {String name: '', bool hasCycle: true}) { |
| 226 UnlinkedClass cls = findClass(className); | 226 UnlinkedClass cls = findClass(className); |
| 227 int constCycleSlot = | 227 int constCycleSlot = |
| 228 findExecutable(name, executables: cls.executables).constCycleSlot; | 228 findExecutable(name, executables: cls.executables).constCycleSlot; |
| 229 expect(constCycleSlot, isNot(0)); | 229 expect(constCycleSlot, isNot(0)); |
| 230 if (!skipFullyLinkedData) { | 230 if (!skipFullyLinkedData) { |
| 231 expect( | 231 expect( |
| 232 definingUnit.constCycles, | 232 definingUnit.constCycles, |
| 233 hasCycle | 233 hasCycle |
| 234 ? contains(constCycleSlot) | 234 ? contains(constCycleSlot) |
| 235 : isNot(contains(constCycleSlot))); | 235 : isNot(contains(constCycleSlot))); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * Verify that the [dependency]th element of the dependency table represents | 240 * Verify that the [dependency]th element of the dependency table represents |
| 241 * a file reachable via the given [absoluteUri] and [relativeUri]. | 241 * a file reachable via the given [absoluteUri]. |
| 242 */ | 242 */ |
| 243 void checkDependency(int dependency, String absoluteUri, String relativeUri) { | 243 void checkDependency(int dependency, String absoluteUri) { |
| 244 expect(dependency, new isInstanceOf<int>()); | 244 expect(dependency, new isInstanceOf<int>()); |
| 245 if (dependency >= linked.numPrelinkedDependencies) { | 245 expect(linked.dependencies[dependency].uri, absoluteUri); |
| 246 // Fully-linked dependencies are always absolute URIs. | |
| 247 expect(linked.dependencies[dependency].uri, absoluteUri); | |
| 248 } else { | |
| 249 expect(linked.dependencies[dependency].uri, relativeUri); | |
| 250 } | |
| 251 } | 246 } |
| 252 | 247 |
| 253 /** | 248 /** |
| 254 * Verify that the given [dependency] lists the given | 249 * Verify that the given [dependency] lists the given |
| 255 * [relativeUris] as its parts. | 250 * [relativeUris] as its parts. |
| 256 */ | 251 */ |
| 257 void checkDependencyParts( | 252 void checkDependencyParts( |
| 258 LinkedDependency dependency, List<String> relativeUris) { | 253 LinkedDependency dependency, List<String> relativeUris) { |
| 259 expect(dependency.parts, relativeUris); | 254 expect(dependency.parts, relativeUris); |
| 260 } | 255 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 277 commentEnd += 2; | 272 commentEnd += 2; |
| 278 String expectedCommentText = | 273 String expectedCommentText = |
| 279 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); | 274 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); |
| 280 expect(documentationComment.text, expectedCommentText); | 275 expect(documentationComment.text, expectedCommentText); |
| 281 } | 276 } |
| 282 | 277 |
| 283 /** | 278 /** |
| 284 * Verify that the given [typeRef] represents the type `dynamic`. | 279 * Verify that the given [typeRef] represents the type `dynamic`. |
| 285 */ | 280 */ |
| 286 void checkDynamicTypeRef(EntityRef typeRef) { | 281 void checkDynamicTypeRef(EntityRef typeRef) { |
| 287 checkTypeRef(typeRef, null, null, 'dynamic'); | 282 checkTypeRef(typeRef, null, 'dynamic'); |
| 288 } | 283 } |
| 289 | 284 |
| 290 /** | 285 /** |
| 291 * Verify that the given [exportName] represents a reference to an entity | 286 * Verify that the given [exportName] represents a reference to an entity |
| 292 * declared in a file reachable via [absoluteUri] and [relativeUri], having | 287 * declared in a file reachable via [absoluteUri], having name [expectedName]. |
| 293 * name [expectedName]. [expectedKind] is the kind of object referenced. | 288 * [expectedKind] is the kind of object referenced. [expectedTargetUnit] is |
| 294 * [expectedTargetUnit] is the index of the compilation unit in which the | 289 * the index of the compilation unit in which the target of the [exportName] |
| 295 * target of the [exportName] is expected to appear; if not specified it is | 290 * is expected to appear; if not specified it is assumed to be the defining |
| 296 * assumed to be the defining compilation unit. | 291 * compilation unit. |
| 297 */ | 292 */ |
| 298 void checkExportName(LinkedExportName exportName, String absoluteUri, | 293 void checkExportName(LinkedExportName exportName, String absoluteUri, |
| 299 String relativeUri, String expectedName, ReferenceKind expectedKind, | 294 String expectedName, ReferenceKind expectedKind, |
| 300 {int expectedTargetUnit: 0}) { | 295 {int expectedTargetUnit: 0}) { |
| 301 expect(exportName, new isInstanceOf<LinkedExportName>()); | 296 expect(exportName, new isInstanceOf<LinkedExportName>()); |
| 302 // Exported names must come from other libraries. | 297 // Exported names must come from other libraries. |
| 303 expect(exportName.dependency, isNot(0)); | 298 expect(exportName.dependency, isNot(0)); |
| 304 checkDependency(exportName.dependency, absoluteUri, relativeUri); | 299 checkDependency(exportName.dependency, absoluteUri); |
| 305 expect(exportName.name, expectedName); | 300 expect(exportName.name, expectedName); |
| 306 expect(exportName.kind, expectedKind); | 301 expect(exportName.kind, expectedKind); |
| 307 expect(exportName.unit, expectedTargetUnit); | 302 expect(exportName.unit, expectedTargetUnit); |
| 308 } | 303 } |
| 309 | 304 |
| 310 /** | 305 /** |
| 311 * Verify that the dependency table contains an entry for a file reachable | 306 * Verify that the dependency table contains an entry for a file reachable |
| 312 * via the given [relativeUri]. If [fullyLinked] is | 307 * via the given [relativeUri]. If [fullyLinked] is |
| 313 * `true`, then the dependency should be a fully-linked dependency; otherwise | 308 * `true`, then the dependency should be a fully-linked dependency; otherwise |
| 314 * it should be a prelinked dependency. | 309 * it should be a prelinked dependency. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 332 fail('Did not find dependency $relativeUri. Found: $found'); | 327 fail('Did not find dependency $relativeUri. Found: $found'); |
| 333 return null; | 328 return null; |
| 334 } | 329 } |
| 335 | 330 |
| 336 /** | 331 /** |
| 337 * Test an inferred type. If [onlyInStrongMode] is `true` (the default) and | 332 * Test an inferred type. If [onlyInStrongMode] is `true` (the default) and |
| 338 * strong mode is disabled, verify that the given [slotId] exists and has no | 333 * strong mode is disabled, verify that the given [slotId] exists and has no |
| 339 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. | 334 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. |
| 340 */ | 335 */ |
| 341 void checkInferredTypeSlot( | 336 void checkInferredTypeSlot( |
| 342 int slotId, String absoluteUri, String relativeUri, String expectedName, | 337 int slotId, String absoluteUri, String expectedName, |
| 343 {int numTypeArguments: 0, | 338 {int numTypeArguments: 0, |
| 344 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 339 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 345 int expectedTargetUnit: 0, | 340 int expectedTargetUnit: 0, |
| 346 LinkedUnit linkedSourceUnit, | 341 LinkedUnit linkedSourceUnit, |
| 347 UnlinkedUnit unlinkedSourceUnit, | 342 UnlinkedUnit unlinkedSourceUnit, |
| 348 int numTypeParameters: 0, | 343 int numTypeParameters: 0, |
| 349 bool onlyInStrongMode: true}) { | 344 bool onlyInStrongMode: true}) { |
| 350 if (strongMode || !onlyInStrongMode) { | 345 if (strongMode || !onlyInStrongMode) { |
| 351 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName, | 346 checkLinkedTypeSlot(slotId, absoluteUri, expectedName, |
| 352 numTypeArguments: numTypeArguments, | 347 numTypeArguments: numTypeArguments, |
| 353 expectedKind: expectedKind, | 348 expectedKind: expectedKind, |
| 354 expectedTargetUnit: expectedTargetUnit, | 349 expectedTargetUnit: expectedTargetUnit, |
| 355 linkedSourceUnit: linkedSourceUnit, | 350 linkedSourceUnit: linkedSourceUnit, |
| 356 unlinkedSourceUnit: unlinkedSourceUnit, | 351 unlinkedSourceUnit: unlinkedSourceUnit, |
| 357 numTypeParameters: numTypeParameters); | 352 numTypeParameters: numTypeParameters); |
| 358 } else { | 353 } else { |
| 359 // A slot id should have been assigned but it should not be associated | 354 // A slot id should have been assigned but it should not be associated |
| 360 // with any type. | 355 // with any type. |
| 361 expect(slotId, isNot(0)); | 356 expect(slotId, isNot(0)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 373 if (dep.uri == relativeUri) { | 368 if (dep.uri == relativeUri) { |
| 374 fail('Unexpected dependency found: $relativeUri'); | 369 fail('Unexpected dependency found: $relativeUri'); |
| 375 } | 370 } |
| 376 } | 371 } |
| 377 } | 372 } |
| 378 | 373 |
| 379 /** | 374 /** |
| 380 * Verify that the given [typeRef] represents the type `dynamic`. | 375 * Verify that the given [typeRef] represents the type `dynamic`. |
| 381 */ | 376 */ |
| 382 void checkLinkedDynamicTypeRef(EntityRef typeRef) { | 377 void checkLinkedDynamicTypeRef(EntityRef typeRef) { |
| 383 checkLinkedTypeRef(typeRef, null, null, 'dynamic'); | 378 checkLinkedTypeRef(typeRef, null, 'dynamic'); |
| 384 } | 379 } |
| 385 | 380 |
| 386 /** | 381 /** |
| 387 * Verify that the given [typeRef] represents a reference to a type declared | 382 * Verify that the given [typeRef] represents a reference to a type declared |
| 388 * in a file reachable via [absoluteUri] and [relativeUri], having name | 383 * in a file reachable via [absoluteUri], having name [expectedName]. Verify |
| 389 * [expectedName]. Verify that the number of type arguments | 384 * that the number of type arguments is equal to [numTypeArguments]. |
| 390 * is equal to [numTypeArguments]. [expectedKind] is the kind of object | 385 * [expectedKind] is the kind of object referenced. [linkedSourceUnit] and |
| 391 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 386 * [unlinkedSourceUnit] refer to the compilation unit within which the |
| 392 * compilation unit within which the [typeRef] appears; if not specified they | 387 * [typeRef] appears; if not specified they are assumed to refer to the |
| 393 * are assumed to refer to the defining compilation unit. | 388 * defining compilation unit. [expectedTargetUnit] is the index of the |
| 394 * [expectedTargetUnit] is the index of the compilation unit in which the | 389 * compilation unit in which the target of the [typeRef] is expected to |
| 395 * target of the [typeRef] is expected to appear; if not specified it is | 390 * appear; if not specified it is assumed to be the defining compilation unit. |
| 396 * assumed to be the defining compilation unit. [numTypeParameters] is the | 391 * [numTypeParameters] is the number of type parameters of the thing being |
| 397 * number of type parameters of the thing being referred to. | 392 * referred to. |
| 398 */ | 393 */ |
| 399 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri, | 394 void checkLinkedTypeRef( |
| 400 String relativeUri, String expectedName, | 395 EntityRef typeRef, String absoluteUri, String expectedName, |
| 401 {int numTypeArguments: 0, | 396 {int numTypeArguments: 0, |
| 402 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 397 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 403 int expectedTargetUnit: 0, | 398 int expectedTargetUnit: 0, |
| 404 LinkedUnit linkedSourceUnit, | 399 LinkedUnit linkedSourceUnit, |
| 405 UnlinkedUnit unlinkedSourceUnit, | 400 UnlinkedUnit unlinkedSourceUnit, |
| 406 int numTypeParameters: 0}) { | 401 int numTypeParameters: 0}) { |
| 407 linkedSourceUnit ??= definingUnit; | 402 linkedSourceUnit ??= definingUnit; |
| 408 expect(typeRef, isNotNull, | 403 expect(typeRef, isNotNull, |
| 409 reason: 'No entry in linkedSourceUnit.types matching slotId'); | 404 reason: 'No entry in linkedSourceUnit.types matching slotId'); |
| 410 expect(typeRef.paramReference, 0); | 405 expect(typeRef.paramReference, 0); |
| 411 int index = typeRef.reference; | 406 int index = typeRef.reference; |
| 412 expect(typeRef.typeArguments, hasLength(numTypeArguments)); | 407 expect(typeRef.typeArguments, hasLength(numTypeArguments)); |
| 413 checkReferenceIndex(index, absoluteUri, relativeUri, expectedName, | 408 checkReferenceIndex(index, absoluteUri, expectedName, |
| 414 expectedKind: expectedKind, | 409 expectedKind: expectedKind, |
| 415 expectedTargetUnit: expectedTargetUnit, | 410 expectedTargetUnit: expectedTargetUnit, |
| 416 linkedSourceUnit: linkedSourceUnit, | 411 linkedSourceUnit: linkedSourceUnit, |
| 417 unlinkedSourceUnit: unlinkedSourceUnit, | 412 unlinkedSourceUnit: unlinkedSourceUnit, |
| 418 numTypeParameters: numTypeParameters); | 413 numTypeParameters: numTypeParameters); |
| 419 } | 414 } |
| 420 | 415 |
| 421 /** | 416 /** |
| 422 * Verify that the given [slotId] represents a reference to a type declared | 417 * Verify that the given [slotId] represents a reference to a type declared |
| 423 * in a file reachable via [absoluteUri] and [relativeUri], having name | 418 * in a file reachable via [absoluteUri], having name [expectedName]. Verify |
| 424 * [expectedName]. Verify that the number of type arguments | 419 * that the number of type arguments is equal to [numTypeArguments]. |
| 425 * is equal to [numTypeArguments]. [expectedKind] is the kind of object | 420 * [expectedKind] is the kind of object referenced. [linkedSourceUnit] and |
| 426 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 421 * [unlinkedSourceUnit] refer to the compilation unit within which the |
| 427 * compilation unit within which the [typeRef] appears; if not specified they | 422 * [typeRef] appears; if not specified they are assumed to refer to the |
| 428 * are assumed to refer to the defining compilation unit. | 423 * defining compilation unit. [expectedTargetUnit] is the index of the |
| 429 * [expectedTargetUnit] is the index of the compilation unit in which the | 424 * compilation unit in which the target of the [typeRef] is expected to |
| 430 * target of the [typeRef] is expected to appear; if not specified it is | 425 * appear; if not specified it is assumed to be the defining compilation unit. |
| 431 * assumed to be the defining compilation unit. [numTypeParameters] is the | 426 * [numTypeParameters] is the number of type parameters of the thing being |
| 432 * number of type parameters of the thing being referred to. | 427 * referred to. |
| 433 */ | 428 */ |
| 434 void checkLinkedTypeSlot( | 429 void checkLinkedTypeSlot(int slotId, String absoluteUri, String expectedName, |
| 435 int slotId, String absoluteUri, String relativeUri, String expectedName, | |
| 436 {int numTypeArguments: 0, | 430 {int numTypeArguments: 0, |
| 437 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 431 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 438 int expectedTargetUnit: 0, | 432 int expectedTargetUnit: 0, |
| 439 LinkedUnit linkedSourceUnit, | 433 LinkedUnit linkedSourceUnit, |
| 440 UnlinkedUnit unlinkedSourceUnit, | 434 UnlinkedUnit unlinkedSourceUnit, |
| 441 int numTypeParameters: 0}) { | 435 int numTypeParameters: 0}) { |
| 442 // Slot ids should be nonzero, since zero means "no associated slot". | 436 // Slot ids should be nonzero, since zero means "no associated slot". |
| 443 expect(slotId, isNot(0)); | 437 expect(slotId, isNot(0)); |
| 444 if (skipFullyLinkedData) { | 438 if (skipFullyLinkedData) { |
| 445 return; | 439 return; |
| 446 } | 440 } |
| 447 linkedSourceUnit ??= definingUnit; | 441 linkedSourceUnit ??= definingUnit; |
| 448 checkLinkedTypeRef( | 442 checkLinkedTypeRef( |
| 449 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), | 443 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), |
| 450 absoluteUri, | 444 absoluteUri, |
| 451 relativeUri, | |
| 452 expectedName, | 445 expectedName, |
| 453 numTypeArguments: numTypeArguments, | 446 numTypeArguments: numTypeArguments, |
| 454 expectedKind: expectedKind, | 447 expectedKind: expectedKind, |
| 455 expectedTargetUnit: expectedTargetUnit, | 448 expectedTargetUnit: expectedTargetUnit, |
| 456 linkedSourceUnit: linkedSourceUnit, | 449 linkedSourceUnit: linkedSourceUnit, |
| 457 unlinkedSourceUnit: unlinkedSourceUnit, | 450 unlinkedSourceUnit: unlinkedSourceUnit, |
| 458 numTypeParameters: numTypeParameters); | 451 numTypeParameters: numTypeParameters); |
| 459 } | 452 } |
| 460 | 453 |
| 461 /** | 454 /** |
| (...skipping 15 matching lines...) Expand all Loading... |
| 477 expect(prefixReference, isNot(0)); | 470 expect(prefixReference, isNot(0)); |
| 478 expect(unlinkedUnits[0].references[prefixReference].prefixReference, 0); | 471 expect(unlinkedUnits[0].references[prefixReference].prefixReference, 0); |
| 479 expect(unlinkedUnits[0].references[prefixReference].name, name); | 472 expect(unlinkedUnits[0].references[prefixReference].name, name); |
| 480 expect(definingUnit.references[prefixReference].dependency, 0); | 473 expect(definingUnit.references[prefixReference].dependency, 0); |
| 481 expect(definingUnit.references[prefixReference].kind, ReferenceKind.prefix); | 474 expect(definingUnit.references[prefixReference].kind, ReferenceKind.prefix); |
| 482 expect(definingUnit.references[prefixReference].unit, 0); | 475 expect(definingUnit.references[prefixReference].unit, 0); |
| 483 } | 476 } |
| 484 | 477 |
| 485 /** | 478 /** |
| 486 * Check the data structures that are reachable from an index in the | 479 * Check the data structures that are reachable from an index in the |
| 487 * references table.. If the reference in question is an explicit | 480 * references table. If the reference in question is an explicit |
| 488 * reference, return the [UnlinkedReference] that is used to make the | 481 * reference, return the [UnlinkedReference] that is used to make the |
| 489 * explicit reference. If the type reference in question is an implicit | 482 * explicit reference. If the type reference in question is an implicit |
| 490 * reference, return `null`. | 483 * reference, return `null`. |
| 491 */ | 484 */ |
| 492 UnlinkedReference checkReferenceIndex(int referenceIndex, String absoluteUri, | 485 UnlinkedReference checkReferenceIndex( |
| 493 String relativeUri, String expectedName, | 486 int referenceIndex, String absoluteUri, String expectedName, |
| 494 {ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 487 {ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 495 int expectedTargetUnit: 0, | 488 int expectedTargetUnit: 0, |
| 496 LinkedUnit linkedSourceUnit, | 489 LinkedUnit linkedSourceUnit, |
| 497 UnlinkedUnit unlinkedSourceUnit, | 490 UnlinkedUnit unlinkedSourceUnit, |
| 498 int numTypeParameters: 0, | 491 int numTypeParameters: 0, |
| 499 int localIndex: 0, | 492 int localIndex: 0, |
| 500 bool unresolvedHasName: false}) { | 493 bool unresolvedHasName: false}) { |
| 501 linkedSourceUnit ??= definingUnit; | 494 linkedSourceUnit ??= definingUnit; |
| 502 unlinkedSourceUnit ??= unlinkedUnits[0]; | 495 unlinkedSourceUnit ??= unlinkedUnits[0]; |
| 503 LinkedReference referenceResolution = | 496 LinkedReference referenceResolution = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 518 } else { | 511 } else { |
| 519 // This is an implicit reference, so its name should be in | 512 // This is an implicit reference, so its name should be in |
| 520 // [LinkedUnit.references]. | 513 // [LinkedUnit.references]. |
| 521 name = referenceResolution.name; | 514 name = referenceResolution.name; |
| 522 } | 515 } |
| 523 // Index 0 is reserved. | 516 // Index 0 is reserved. |
| 524 expect(referenceIndex, isNot(0)); | 517 expect(referenceIndex, isNot(0)); |
| 525 if (absoluteUri == null) { | 518 if (absoluteUri == null) { |
| 526 expect(referenceResolution.dependency, 0); | 519 expect(referenceResolution.dependency, 0); |
| 527 } else { | 520 } else { |
| 528 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); | 521 checkDependency(referenceResolution.dependency, absoluteUri); |
| 529 } | 522 } |
| 530 if (expectedName == null) { | 523 if (expectedName == null) { |
| 531 expect(name, isEmpty); | 524 expect(name, isEmpty); |
| 532 } else { | 525 } else { |
| 533 expect(name, expectedName); | 526 expect(name, expectedName); |
| 534 } | 527 } |
| 535 expect(referenceResolution.kind, expectedKind); | 528 expect(referenceResolution.kind, expectedKind); |
| 536 expect(referenceResolution.unit, expectedTargetUnit); | 529 expect(referenceResolution.unit, expectedTargetUnit); |
| 537 expect(referenceResolution.numTypeParameters, numTypeParameters); | 530 expect(referenceResolution.numTypeParameters, numTypeParameters); |
| 538 expect(referenceResolution.localIndex, localIndex); | 531 expect(referenceResolution.localIndex, localIndex); |
| 539 return reference; | 532 return reference; |
| 540 } | 533 } |
| 541 | 534 |
| 542 /** | 535 /** |
| 543 * Verify that the given [typeRef] represents a reference to a type declared | 536 * Verify that the given [typeRef] represents a reference to a type declared |
| 544 * in a file reachable via [absoluteUri] and [relativeUri], having name | 537 * in a file reachable via [absoluteUri], having name [expectedName]. |
| 545 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is | 538 * If [expectedPrefix] is supplied, verify that the type is reached via the |
| 546 * reached via the given prefix. Verify that the number of type arguments | 539 * given prefix. Verify that the number of type arguments is equal to |
| 547 * is equal to [numTypeArguments]. [expectedKind] is the kind of | 540 * [numTypeArguments]. [expectedKind] is the kind of object referenced. |
| 548 * object referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer | 541 * [linkedSourceUnit] and [unlinkedSourceUnit] refer to the compilation unit |
| 549 * to the compilation unit within which the [typeRef] appears; if not | 542 * within which the [typeRef] appears; if not specified they are assumed to |
| 550 * specified they are assumed to refer to the defining compilation unit. | 543 * refer to the defining compilation unit. [expectedTargetUnit] is the index |
| 551 * [expectedTargetUnit] is the index of the compilation unit in which the | 544 * of the compilation unit in which the target of the [typeRef] is expected |
| 552 * target of the [typeRef] is expected to appear; if not specified it is | 545 * to appear; if not specified it is assumed to be the defining compilation |
| 553 * assumed to be the defining compilation unit. [numTypeParameters] is the | 546 * unit. [numTypeParameters] is the number of type parameters of the thing |
| 554 * number of type parameters of the thing being referred to. | 547 * being referred to. |
| 555 */ | 548 */ |
| 556 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri, | 549 void checkTypeRef(EntityRef typeRef, String absoluteUri, String expectedName, |
| 557 String expectedName, | |
| 558 {String expectedPrefix, | 550 {String expectedPrefix, |
| 559 List<_PrefixExpectation> prefixExpectations, | 551 List<_PrefixExpectation> prefixExpectations, |
| 560 int numTypeArguments: 0, | 552 int numTypeArguments: 0, |
| 561 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 553 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 562 int expectedTargetUnit: 0, | 554 int expectedTargetUnit: 0, |
| 563 LinkedUnit linkedSourceUnit, | 555 LinkedUnit linkedSourceUnit, |
| 564 UnlinkedUnit unlinkedSourceUnit, | 556 UnlinkedUnit unlinkedSourceUnit, |
| 565 int numTypeParameters: 0, | 557 int numTypeParameters: 0, |
| 566 bool unresolvedHasName: false}) { | 558 bool unresolvedHasName: false}) { |
| 567 linkedSourceUnit ??= definingUnit; | 559 linkedSourceUnit ??= definingUnit; |
| 568 expect(typeRef, new isInstanceOf<EntityRef>()); | 560 expect(typeRef, new isInstanceOf<EntityRef>()); |
| 569 expect(typeRef.paramReference, 0); | 561 expect(typeRef.paramReference, 0); |
| 570 int index = typeRef.reference; | 562 int index = typeRef.reference; |
| 571 expect(typeRef.typeArguments, hasLength(numTypeArguments)); | 563 expect(typeRef.typeArguments, hasLength(numTypeArguments)); |
| 572 UnlinkedReference reference = checkReferenceIndex( | 564 UnlinkedReference reference = checkReferenceIndex( |
| 573 index, absoluteUri, relativeUri, expectedName, | 565 index, absoluteUri, expectedName, |
| 574 expectedKind: expectedKind, | 566 expectedKind: expectedKind, |
| 575 expectedTargetUnit: expectedTargetUnit, | 567 expectedTargetUnit: expectedTargetUnit, |
| 576 linkedSourceUnit: linkedSourceUnit, | 568 linkedSourceUnit: linkedSourceUnit, |
| 577 unlinkedSourceUnit: unlinkedSourceUnit, | 569 unlinkedSourceUnit: unlinkedSourceUnit, |
| 578 numTypeParameters: numTypeParameters, | 570 numTypeParameters: numTypeParameters, |
| 579 unresolvedHasName: unresolvedHasName); | 571 unresolvedHasName: unresolvedHasName); |
| 580 expect(reference, isNotNull, | 572 expect(reference, isNotNull, |
| 581 reason: 'Unlinked type refs must refer to an explicit reference'); | 573 reason: 'Unlinked type refs must refer to an explicit reference'); |
| 582 if (expectedPrefix != null) { | 574 if (expectedPrefix != null) { |
| 583 checkPrefix(reference.prefixReference, expectedPrefix); | 575 checkPrefix(reference.prefixReference, expectedPrefix); |
| 584 } else if (prefixExpectations != null) { | 576 } else if (prefixExpectations != null) { |
| 585 for (_PrefixExpectation expectation in prefixExpectations) { | 577 for (_PrefixExpectation expectation in prefixExpectations) { |
| 586 expect(reference.prefixReference, isNot(0)); | 578 expect(reference.prefixReference, isNot(0)); |
| 587 reference = checkReferenceIndex(reference.prefixReference, | 579 reference = checkReferenceIndex(reference.prefixReference, |
| 588 expectation.absoluteUri, expectation.relativeUri, expectation.name, | 580 expectation.absoluteUri, expectation.name, |
| 589 expectedKind: expectation.kind, | 581 expectedKind: expectation.kind, |
| 590 expectedTargetUnit: expectedTargetUnit, | 582 expectedTargetUnit: expectedTargetUnit, |
| 591 linkedSourceUnit: linkedSourceUnit, | 583 linkedSourceUnit: linkedSourceUnit, |
| 592 unlinkedSourceUnit: unlinkedSourceUnit, | 584 unlinkedSourceUnit: unlinkedSourceUnit, |
| 593 numTypeParameters: expectation.numTypeParameters); | 585 numTypeParameters: expectation.numTypeParameters); |
| 594 } | 586 } |
| 595 expect(reference.prefixReference, 0); | 587 expect(reference.prefixReference, 0); |
| 596 } else { | 588 } else { |
| 597 expect(reference.prefixReference, 0); | 589 expect(reference.prefixReference, 0); |
| 598 } | 590 } |
| 599 } | 591 } |
| 600 | 592 |
| 601 /** | 593 /** |
| 602 * Verify that the given [typeRef] represents a reference to an unresolved | 594 * Verify that the given [typeRef] represents a reference to an unresolved |
| 603 * type. | 595 * type. |
| 604 */ | 596 */ |
| 605 void checkUnresolvedTypeRef( | 597 void checkUnresolvedTypeRef( |
| 606 EntityRef typeRef, String expectedPrefix, String expectedName, | 598 EntityRef typeRef, String expectedPrefix, String expectedName, |
| 607 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { | 599 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { |
| 608 // When serializing from the element model, unresolved type refs lose their | 600 // When serializing from the element model, unresolved type refs lose their |
| 609 // name. | 601 // name. |
| 610 checkTypeRef(typeRef, null, null, expectedName, | 602 checkTypeRef(typeRef, null, expectedName, |
| 611 expectedPrefix: expectedPrefix, | 603 expectedPrefix: expectedPrefix, |
| 612 expectedKind: ReferenceKind.unresolved, | 604 expectedKind: ReferenceKind.unresolved, |
| 613 linkedSourceUnit: linkedSourceUnit, | 605 linkedSourceUnit: linkedSourceUnit, |
| 614 unlinkedSourceUnit: unlinkedSourceUnit); | 606 unlinkedSourceUnit: unlinkedSourceUnit); |
| 615 } | 607 } |
| 616 | 608 |
| 617 /** | 609 /** |
| 618 * Verify that the given [typeRef] represents the type `void`. | 610 * Verify that the given [typeRef] represents the type `void`. |
| 619 */ | 611 */ |
| 620 void checkVoidTypeRef(EntityRef typeRef) { | 612 void checkVoidTypeRef(EntityRef typeRef) { |
| 621 checkTypeRef(typeRef, null, null, 'void'); | 613 checkTypeRef(typeRef, null, 'void'); |
| 622 } | 614 } |
| 623 | 615 |
| 624 fail_invalid_prefix_dynamic() { | 616 fail_invalid_prefix_dynamic() { |
| 625 // if (checkAstDerivedData) { | 617 // if (checkAstDerivedData) { |
| 626 // // TODO(paulberry): get this to work properly. | 618 // // TODO(paulberry): get this to work properly. |
| 627 // return; | 619 // return; |
| 628 // } | 620 // } |
| 629 var t = serializeTypeText('dynamic.T', allowErrors: true); | 621 var t = serializeTypeText('dynamic.T', allowErrors: true); |
| 630 checkUnresolvedTypeRef(t, 'dynamic', 'T'); | 622 checkUnresolvedTypeRef(t, 'dynamic', 'T'); |
| 631 } | 623 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C hide B, C;'); | 994 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C hide B, C;'); |
| 1003 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); | 995 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); |
| 1004 serializeLibraryText( | 996 serializeLibraryText( |
| 1005 ''' | 997 ''' |
| 1006 import 'lib1.dart'; | 998 import 'lib1.dart'; |
| 1007 A a; | 999 A a; |
| 1008 B b; | 1000 B b; |
| 1009 C c; | 1001 C c; |
| 1010 ''', | 1002 ''', |
| 1011 allowErrors: true); | 1003 allowErrors: true); |
| 1012 checkTypeRef( | 1004 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); |
| 1013 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A'); | |
| 1014 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1005 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1015 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1006 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1016 } | 1007 } |
| 1017 | 1008 |
| 1018 test_cascaded_export_hide_show() { | 1009 test_cascaded_export_hide_show() { |
| 1019 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C show A, C;'); | 1010 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C show A, C;'); |
| 1020 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); | 1011 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); |
| 1021 serializeLibraryText( | 1012 serializeLibraryText( |
| 1022 ''' | 1013 ''' |
| 1023 import 'lib1.dart'; | 1014 import 'lib1.dart'; |
| 1024 A a; | 1015 A a; |
| 1025 B b; | 1016 B b; |
| 1026 C c; | 1017 C c; |
| 1027 ''', | 1018 ''', |
| 1028 allowErrors: true); | 1019 allowErrors: true); |
| 1029 checkTypeRef( | 1020 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); |
| 1030 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A'); | |
| 1031 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1021 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1032 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1022 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1033 } | 1023 } |
| 1034 | 1024 |
| 1035 test_cascaded_export_show_hide() { | 1025 test_cascaded_export_show_hide() { |
| 1036 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B hide B, C;'); | 1026 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B hide B, C;'); |
| 1037 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); | 1027 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); |
| 1038 serializeLibraryText( | 1028 serializeLibraryText( |
| 1039 ''' | 1029 ''' |
| 1040 import 'lib1.dart'; | 1030 import 'lib1.dart'; |
| 1041 A a; | 1031 A a; |
| 1042 B b; | 1032 B b; |
| 1043 C c; | 1033 C c; |
| 1044 ''', | 1034 ''', |
| 1045 allowErrors: true); | 1035 allowErrors: true); |
| 1046 checkTypeRef( | 1036 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); |
| 1047 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A'); | |
| 1048 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1037 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1049 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1038 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1050 } | 1039 } |
| 1051 | 1040 |
| 1052 test_cascaded_export_show_show() { | 1041 test_cascaded_export_show_show() { |
| 1053 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B show A, C;'); | 1042 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B show A, C;'); |
| 1054 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); | 1043 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}'); |
| 1055 serializeLibraryText( | 1044 serializeLibraryText( |
| 1056 ''' | 1045 ''' |
| 1057 import 'lib1.dart'; | 1046 import 'lib1.dart'; |
| 1058 A a; | 1047 A a; |
| 1059 B b; | 1048 B b; |
| 1060 C c; | 1049 C c; |
| 1061 ''', | 1050 ''', |
| 1062 allowErrors: true); | 1051 allowErrors: true); |
| 1063 checkTypeRef( | 1052 checkTypeRef(findVariable('a').type, absUri('/lib2.dart'), 'A'); |
| 1064 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A'); | |
| 1065 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1053 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1066 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1054 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1067 } | 1055 } |
| 1068 | 1056 |
| 1069 test_cascaded_import_hide_hide() { | 1057 test_cascaded_import_hide_hide() { |
| 1070 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); | 1058 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); |
| 1071 serializeLibraryText( | 1059 serializeLibraryText( |
| 1072 ''' | 1060 ''' |
| 1073 import 'lib.dart' hide C hide B, C; | 1061 import 'lib.dart' hide C hide B, C; |
| 1074 A a; | 1062 A a; |
| 1075 B b; | 1063 B b; |
| 1076 C c; | 1064 C c; |
| 1077 ''', | 1065 ''', |
| 1078 allowErrors: true); | 1066 allowErrors: true); |
| 1079 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A'); | 1067 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); |
| 1080 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1068 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1081 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1069 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1082 } | 1070 } |
| 1083 | 1071 |
| 1084 test_cascaded_import_hide_show() { | 1072 test_cascaded_import_hide_show() { |
| 1085 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); | 1073 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); |
| 1086 serializeLibraryText( | 1074 serializeLibraryText( |
| 1087 ''' | 1075 ''' |
| 1088 import 'lib.dart' hide C show A, C; | 1076 import 'lib.dart' hide C show A, C; |
| 1089 A a; | 1077 A a; |
| 1090 B b; | 1078 B b; |
| 1091 C c; | 1079 C c; |
| 1092 ''', | 1080 ''', |
| 1093 allowErrors: true); | 1081 allowErrors: true); |
| 1094 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A'); | 1082 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); |
| 1095 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1083 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1096 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1084 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1097 } | 1085 } |
| 1098 | 1086 |
| 1099 test_cascaded_import_show_hide() { | 1087 test_cascaded_import_show_hide() { |
| 1100 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); | 1088 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); |
| 1101 serializeLibraryText( | 1089 serializeLibraryText( |
| 1102 ''' | 1090 ''' |
| 1103 import 'lib.dart' show A, B hide B, C; | 1091 import 'lib.dart' show A, B hide B, C; |
| 1104 A a; | 1092 A a; |
| 1105 B b; | 1093 B b; |
| 1106 C c; | 1094 C c; |
| 1107 ''', | 1095 ''', |
| 1108 allowErrors: true); | 1096 allowErrors: true); |
| 1109 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A'); | 1097 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); |
| 1110 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1098 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1111 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1099 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1112 } | 1100 } |
| 1113 | 1101 |
| 1114 test_cascaded_import_show_show() { | 1102 test_cascaded_import_show_show() { |
| 1115 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); | 1103 addNamedSource('/lib.dart', 'class A {} class B {} class C {}'); |
| 1116 serializeLibraryText( | 1104 serializeLibraryText( |
| 1117 ''' | 1105 ''' |
| 1118 import 'lib.dart' show A, B show A, C; | 1106 import 'lib.dart' show A, B show A, C; |
| 1119 A a; | 1107 A a; |
| 1120 B b; | 1108 B b; |
| 1121 C c; | 1109 C c; |
| 1122 ''', | 1110 ''', |
| 1123 allowErrors: true); | 1111 allowErrors: true); |
| 1124 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A'); | 1112 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'A'); |
| 1125 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); | 1113 checkUnresolvedTypeRef(findVariable('b').type, null, 'B'); |
| 1126 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); | 1114 checkUnresolvedTypeRef(findVariable('c').type, null, 'C'); |
| 1127 } | 1115 } |
| 1128 | 1116 |
| 1129 test_class_abstract() { | 1117 test_class_abstract() { |
| 1130 UnlinkedClass cls = serializeClassText('abstract class C {}'); | 1118 UnlinkedClass cls = serializeClassText('abstract class C {}'); |
| 1131 expect(cls.isAbstract, true); | 1119 expect(cls.isAbstract, true); |
| 1132 } | 1120 } |
| 1133 | 1121 |
| 1134 test_class_alias_abstract() { | 1122 test_class_alias_abstract() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 } | 1164 } |
| 1177 | 1165 |
| 1178 test_class_alias_mixin_order() { | 1166 test_class_alias_mixin_order() { |
| 1179 UnlinkedClass cls = serializeClassText(''' | 1167 UnlinkedClass cls = serializeClassText(''' |
| 1180 class C = D with E, F; | 1168 class C = D with E, F; |
| 1181 class D {} | 1169 class D {} |
| 1182 class E {} | 1170 class E {} |
| 1183 class F {} | 1171 class F {} |
| 1184 '''); | 1172 '''); |
| 1185 expect(cls.mixins, hasLength(2)); | 1173 expect(cls.mixins, hasLength(2)); |
| 1186 checkTypeRef(cls.mixins[0], null, null, 'E'); | 1174 checkTypeRef(cls.mixins[0], null, 'E'); |
| 1187 checkTypeRef(cls.mixins[1], null, null, 'F'); | 1175 checkTypeRef(cls.mixins[1], null, 'F'); |
| 1188 } | 1176 } |
| 1189 | 1177 |
| 1190 test_class_alias_no_implicit_constructors() { | 1178 test_class_alias_no_implicit_constructors() { |
| 1191 UnlinkedClass cls = serializeClassText(''' | 1179 UnlinkedClass cls = serializeClassText(''' |
| 1192 class C = D with E; | 1180 class C = D with E; |
| 1193 class D { | 1181 class D { |
| 1194 D.foo(); | 1182 D.foo(); |
| 1195 D.bar(); | 1183 D.bar(); |
| 1196 } | 1184 } |
| 1197 class E {} | 1185 class E {} |
| 1198 '''); | 1186 '''); |
| 1199 expect(cls.executables, isEmpty); | 1187 expect(cls.executables, isEmpty); |
| 1200 } | 1188 } |
| 1201 | 1189 |
| 1202 test_class_alias_private() { | 1190 test_class_alias_private() { |
| 1203 serializeClassText('class _C = _D with _E; class _D {} class _E {}', | 1191 serializeClassText('class _C = _D with _E; class _D {} class _E {}', |
| 1204 className: '_C'); | 1192 className: '_C'); |
| 1205 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1193 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1206 } | 1194 } |
| 1207 | 1195 |
| 1208 test_class_alias_reference_generic() { | 1196 test_class_alias_reference_generic() { |
| 1209 EntityRef typeRef = serializeTypeText('C', | 1197 EntityRef typeRef = serializeTypeText('C', |
| 1210 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); | 1198 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); |
| 1211 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1199 checkTypeRef(typeRef, null, 'C', numTypeParameters: 2); |
| 1212 } | 1200 } |
| 1213 | 1201 |
| 1214 test_class_alias_reference_generic_imported() { | 1202 test_class_alias_reference_generic_imported() { |
| 1215 addNamedSource( | 1203 addNamedSource( |
| 1216 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); | 1204 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); |
| 1217 EntityRef typeRef = | 1205 EntityRef typeRef = |
| 1218 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1206 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1219 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1207 checkTypeRef(typeRef, absUri('/lib.dart'), 'C', numTypeParameters: 2); |
| 1220 numTypeParameters: 2); | |
| 1221 } | 1208 } |
| 1222 | 1209 |
| 1223 test_class_alias_supertype() { | 1210 test_class_alias_supertype() { |
| 1224 UnlinkedClass cls = | 1211 UnlinkedClass cls = |
| 1225 serializeClassText('class C = D with E; class D {} class E {}'); | 1212 serializeClassText('class C = D with E; class D {} class E {}'); |
| 1226 checkTypeRef(cls.supertype, null, null, 'D'); | 1213 checkTypeRef(cls.supertype, null, 'D'); |
| 1227 expect(cls.hasNoSupertype, isFalse); | 1214 expect(cls.hasNoSupertype, isFalse); |
| 1228 } | 1215 } |
| 1229 | 1216 |
| 1230 test_class_codeRange() { | 1217 test_class_codeRange() { |
| 1231 if (!includeInformative) return; | 1218 if (!includeInformative) return; |
| 1232 UnlinkedClass cls = serializeClassText(' class C {}'); | 1219 UnlinkedClass cls = serializeClassText(' class C {}'); |
| 1233 _assertCodeRange(cls.codeRange, 1, 10); | 1220 _assertCodeRange(cls.codeRange, 1, 10); |
| 1234 } | 1221 } |
| 1235 | 1222 |
| 1236 test_class_concrete() { | 1223 test_class_concrete() { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 expect(cls.documentationComment, isNotNull); | 1352 expect(cls.documentationComment, isNotNull); |
| 1366 checkDocumentationComment(cls.documentationComment, text); | 1353 checkDocumentationComment(cls.documentationComment, text); |
| 1367 } | 1354 } |
| 1368 | 1355 |
| 1369 test_class_interface() { | 1356 test_class_interface() { |
| 1370 UnlinkedClass cls = serializeClassText(''' | 1357 UnlinkedClass cls = serializeClassText(''' |
| 1371 class C implements D {} | 1358 class C implements D {} |
| 1372 class D {} | 1359 class D {} |
| 1373 '''); | 1360 '''); |
| 1374 expect(cls.interfaces, hasLength(1)); | 1361 expect(cls.interfaces, hasLength(1)); |
| 1375 checkTypeRef(cls.interfaces[0], null, null, 'D'); | 1362 checkTypeRef(cls.interfaces[0], null, 'D'); |
| 1376 } | 1363 } |
| 1377 | 1364 |
| 1378 test_class_interface_order() { | 1365 test_class_interface_order() { |
| 1379 UnlinkedClass cls = serializeClassText(''' | 1366 UnlinkedClass cls = serializeClassText(''' |
| 1380 class C implements D, E {} | 1367 class C implements D, E {} |
| 1381 class D {} | 1368 class D {} |
| 1382 class E {} | 1369 class E {} |
| 1383 '''); | 1370 '''); |
| 1384 expect(cls.interfaces, hasLength(2)); | 1371 expect(cls.interfaces, hasLength(2)); |
| 1385 checkTypeRef(cls.interfaces[0], null, null, 'D'); | 1372 checkTypeRef(cls.interfaces[0], null, 'D'); |
| 1386 checkTypeRef(cls.interfaces[1], null, null, 'E'); | 1373 checkTypeRef(cls.interfaces[1], null, 'E'); |
| 1387 } | 1374 } |
| 1388 | 1375 |
| 1389 test_class_mixin() { | 1376 test_class_mixin() { |
| 1390 UnlinkedClass cls = serializeClassText(''' | 1377 UnlinkedClass cls = serializeClassText(''' |
| 1391 class C extends Object with D {} | 1378 class C extends Object with D {} |
| 1392 class D {} | 1379 class D {} |
| 1393 '''); | 1380 '''); |
| 1394 expect(cls.mixins, hasLength(1)); | 1381 expect(cls.mixins, hasLength(1)); |
| 1395 checkTypeRef(cls.mixins[0], null, null, 'D'); | 1382 checkTypeRef(cls.mixins[0], null, 'D'); |
| 1396 } | 1383 } |
| 1397 | 1384 |
| 1398 test_class_mixin_order() { | 1385 test_class_mixin_order() { |
| 1399 UnlinkedClass cls = serializeClassText(''' | 1386 UnlinkedClass cls = serializeClassText(''' |
| 1400 class C extends Object with D, E {} | 1387 class C extends Object with D, E {} |
| 1401 class D {} | 1388 class D {} |
| 1402 class E {} | 1389 class E {} |
| 1403 '''); | 1390 '''); |
| 1404 expect(cls.mixins, hasLength(2)); | 1391 expect(cls.mixins, hasLength(2)); |
| 1405 checkTypeRef(cls.mixins[0], null, null, 'D'); | 1392 checkTypeRef(cls.mixins[0], null, 'D'); |
| 1406 checkTypeRef(cls.mixins[1], null, null, 'E'); | 1393 checkTypeRef(cls.mixins[1], null, 'E'); |
| 1407 } | 1394 } |
| 1408 | 1395 |
| 1409 test_class_name() { | 1396 test_class_name() { |
| 1410 var classText = 'class C {}'; | 1397 var classText = 'class C {}'; |
| 1411 UnlinkedClass cls = serializeClassText(classText); | 1398 UnlinkedClass cls = serializeClassText(classText); |
| 1412 expect(cls.name, 'C'); | 1399 expect(cls.name, 'C'); |
| 1413 if (includeInformative) { | 1400 if (includeInformative) { |
| 1414 expect(cls.nameOffset, classText.indexOf('C')); | 1401 expect(cls.nameOffset, classText.indexOf('C')); |
| 1415 } | 1402 } |
| 1416 } | 1403 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1442 } | 1429 } |
| 1443 | 1430 |
| 1444 test_class_private() { | 1431 test_class_private() { |
| 1445 serializeClassText('class _C {}', className: '_C'); | 1432 serializeClassText('class _C {}', className: '_C'); |
| 1446 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1433 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1447 } | 1434 } |
| 1448 | 1435 |
| 1449 test_class_reference_generic() { | 1436 test_class_reference_generic() { |
| 1450 EntityRef typeRef = | 1437 EntityRef typeRef = |
| 1451 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); | 1438 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); |
| 1452 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1439 checkTypeRef(typeRef, null, 'C', numTypeParameters: 2); |
| 1453 } | 1440 } |
| 1454 | 1441 |
| 1455 test_class_reference_generic_imported() { | 1442 test_class_reference_generic_imported() { |
| 1456 addNamedSource('/lib.dart', 'class C<D, E> {}'); | 1443 addNamedSource('/lib.dart', 'class C<D, E> {}'); |
| 1457 EntityRef typeRef = | 1444 EntityRef typeRef = |
| 1458 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1445 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1459 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1446 checkTypeRef(typeRef, absUri('/lib.dart'), 'C', numTypeParameters: 2); |
| 1460 numTypeParameters: 2); | |
| 1461 } | 1447 } |
| 1462 | 1448 |
| 1463 test_class_superclass() { | 1449 test_class_superclass() { |
| 1464 UnlinkedClass cls = serializeClassText('class C {}'); | 1450 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1465 expect(cls.supertype, isNull); | 1451 expect(cls.supertype, isNull); |
| 1466 expect(cls.hasNoSupertype, isFalse); | 1452 expect(cls.hasNoSupertype, isFalse); |
| 1467 } | 1453 } |
| 1468 | 1454 |
| 1469 test_class_superclass_explicit() { | 1455 test_class_superclass_explicit() { |
| 1470 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); | 1456 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); |
| 1471 expect(cls.supertype, isNotNull); | 1457 expect(cls.supertype, isNotNull); |
| 1472 checkTypeRef(cls.supertype, null, null, 'D'); | 1458 checkTypeRef(cls.supertype, null, 'D'); |
| 1473 expect(cls.hasNoSupertype, isFalse); | 1459 expect(cls.hasNoSupertype, isFalse); |
| 1474 } | 1460 } |
| 1475 | 1461 |
| 1476 test_class_type_param_bound() { | 1462 test_class_type_param_bound() { |
| 1477 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); | 1463 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); |
| 1478 expect(cls.typeParameters, hasLength(1)); | 1464 expect(cls.typeParameters, hasLength(1)); |
| 1479 { | 1465 { |
| 1480 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; | 1466 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; |
| 1481 expect(typeParameter.name, 'T'); | 1467 expect(typeParameter.name, 'T'); |
| 1482 expect(typeParameter.bound, isNotNull); | 1468 expect(typeParameter.bound, isNotNull); |
| 1483 checkTypeRef(typeParameter.bound, 'dart:core', 'dart:core', 'List', | 1469 checkTypeRef(typeParameter.bound, 'dart:core', 'List', |
| 1484 numTypeParameters: 1); | 1470 numTypeParameters: 1); |
| 1485 } | 1471 } |
| 1486 } | 1472 } |
| 1487 | 1473 |
| 1488 test_class_type_param_f_bound() { | 1474 test_class_type_param_f_bound() { |
| 1489 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); | 1475 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); |
| 1490 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; | 1476 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; |
| 1491 checkParamTypeRef(typeArgument, 2); | 1477 checkParamTypeRef(typeArgument, 2); |
| 1492 } | 1478 } |
| 1493 | 1479 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1517 expect(executable.localFunctions, hasLength(1)); | 1503 expect(executable.localFunctions, hasLength(1)); |
| 1518 expect(executable.localFunctions[0].returnType, isNull); | 1504 expect(executable.localFunctions[0].returnType, isNull); |
| 1519 closure = executable.localFunctions[0]; | 1505 closure = executable.localFunctions[0]; |
| 1520 } | 1506 } |
| 1521 if (strongMode) { | 1507 if (strongMode) { |
| 1522 // Strong mode infers a type for the closure of `() => dynamic`, so the | 1508 // Strong mode infers a type for the closure of `() => dynamic`, so the |
| 1523 // inferred return type slot should be empty. | 1509 // inferred return type slot should be empty. |
| 1524 expect(getTypeRefForSlot(closure.inferredReturnTypeSlot), isNull); | 1510 expect(getTypeRefForSlot(closure.inferredReturnTypeSlot), isNull); |
| 1525 } else { | 1511 } else { |
| 1526 // Spec mode infers a type for the closure of `() => Bottom`. | 1512 // Spec mode infers a type for the closure of `() => Bottom`. |
| 1527 checkInferredTypeSlot( | 1513 checkInferredTypeSlot(closure.inferredReturnTypeSlot, null, '*bottom*', |
| 1528 closure.inferredReturnTypeSlot, null, null, '*bottom*', | |
| 1529 onlyInStrongMode: false); | 1514 onlyInStrongMode: false); |
| 1530 } | 1515 } |
| 1531 } | 1516 } |
| 1532 | 1517 |
| 1533 test_closure_executable_with_imported_return_type() { | 1518 test_closure_executable_with_imported_return_type() { |
| 1534 addNamedSource('/a.dart', 'class C { D d; } class D {}'); | 1519 addNamedSource('/a.dart', 'class C { D d; } class D {}'); |
| 1535 // The closure has type `() => D`; `D` is defined in a library that is | 1520 // The closure has type `() => D`; `D` is defined in a library that is |
| 1536 // imported. | 1521 // imported. |
| 1537 UnlinkedExecutable executable = serializeVariableText(r''' | 1522 UnlinkedExecutable executable = serializeVariableText(r''' |
| 1538 import "a.dart"; | 1523 import "a.dart"; |
| 1539 var v = (() { | 1524 var v = (() { |
| 1540 print((() => new C().d)()); | 1525 print((() => new C().d)()); |
| 1541 }); | 1526 }); |
| 1542 ''').initializer.localFunctions[0]; | 1527 ''').initializer.localFunctions[0]; |
| 1543 expect(executable.localFunctions, hasLength(1)); | 1528 expect(executable.localFunctions, hasLength(1)); |
| 1544 expect(executable.localFunctions[0].returnType, isNull); | 1529 expect(executable.localFunctions[0].returnType, isNull); |
| 1545 checkInferredTypeSlot(executable.localFunctions[0].inferredReturnTypeSlot, | 1530 checkInferredTypeSlot(executable.localFunctions[0].inferredReturnTypeSlot, |
| 1546 absUri('/a.dart'), 'a.dart', 'D', | 1531 absUri('/a.dart'), 'D', |
| 1547 onlyInStrongMode: false); | 1532 onlyInStrongMode: false); |
| 1548 checkHasDependency('a.dart', fullyLinked: false); | 1533 checkHasDependency(absUri('/a.dart'), fullyLinked: false); |
| 1549 } | 1534 } |
| 1550 | 1535 |
| 1551 test_closure_executable_with_return_type_from_closure() { | 1536 test_closure_executable_with_return_type_from_closure() { |
| 1552 if (skipFullyLinkedData) { | 1537 if (skipFullyLinkedData) { |
| 1553 return; | 1538 return; |
| 1554 } | 1539 } |
| 1555 // The closure has type `() => () => int`, where the `() => int` part refers | 1540 // The closure has type `() => () => int`, where the `() => int` part refers |
| 1556 // to the nested closure. | 1541 // to the nested closure. |
| 1557 UnlinkedExecutable executable = serializeExecutableText(''' | 1542 UnlinkedExecutable executable = serializeExecutableText(''' |
| 1558 f() { | 1543 f() { |
| 1559 print(() {}); // force the closure below to have index 1 | 1544 print(() {}); // force the closure below to have index 1 |
| 1560 print(() => () => 0); | 1545 print(() => () => 0); |
| 1561 } | 1546 } |
| 1562 '''); | 1547 '''); |
| 1563 expect(executable.localFunctions, hasLength(2)); | 1548 expect(executable.localFunctions, hasLength(2)); |
| 1564 EntityRef closureType = | 1549 EntityRef closureType = |
| 1565 getTypeRefForSlot(executable.localFunctions[1].inferredReturnTypeSlot); | 1550 getTypeRefForSlot(executable.localFunctions[1].inferredReturnTypeSlot); |
| 1566 checkLinkedTypeRef(closureType, null, null, '', | 1551 checkLinkedTypeRef(closureType, null, '', |
| 1567 expectedKind: ReferenceKind.function); | 1552 expectedKind: ReferenceKind.function); |
| 1568 int outerClosureIndex = | 1553 int outerClosureIndex = |
| 1569 definingUnit.references[closureType.reference].containingReference; | 1554 definingUnit.references[closureType.reference].containingReference; |
| 1570 checkReferenceIndex(outerClosureIndex, null, null, '', | 1555 checkReferenceIndex(outerClosureIndex, null, '', |
| 1571 expectedKind: ReferenceKind.function, localIndex: 1); | 1556 expectedKind: ReferenceKind.function, localIndex: 1); |
| 1572 int topLevelFunctionIndex = | 1557 int topLevelFunctionIndex = |
| 1573 definingUnit.references[outerClosureIndex].containingReference; | 1558 definingUnit.references[outerClosureIndex].containingReference; |
| 1574 checkReferenceIndex(topLevelFunctionIndex, null, null, 'f', | 1559 checkReferenceIndex(topLevelFunctionIndex, null, 'f', |
| 1575 expectedKind: ReferenceKind.topLevelFunction); | 1560 expectedKind: ReferenceKind.topLevelFunction); |
| 1576 expect( | 1561 expect( |
| 1577 definingUnit.references[topLevelFunctionIndex].containingReference, 0); | 1562 definingUnit.references[topLevelFunctionIndex].containingReference, 0); |
| 1578 } | 1563 } |
| 1579 | 1564 |
| 1580 test_closure_executable_with_unimported_return_type() { | 1565 test_closure_executable_with_unimported_return_type() { |
| 1581 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); | 1566 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); |
| 1582 addNamedSource('/b.dart', 'class D {}'); | 1567 addNamedSource('/b.dart', 'class D {}'); |
| 1583 // The closure has type `() => D`; `D` is defined in a library that is not | 1568 // The closure has type `() => D`; `D` is defined in a library that is not |
| 1584 // imported. | 1569 // imported. |
| 1585 UnlinkedExecutable executable = serializeVariableText(r''' | 1570 UnlinkedExecutable executable = serializeVariableText(r''' |
| 1586 import "a.dart"; | 1571 import "a.dart"; |
| 1587 var v = (() { | 1572 var v = (() { |
| 1588 print((() => new C().d)()); | 1573 print((() => new C().d)()); |
| 1589 }); | 1574 }); |
| 1590 ''').initializer.localFunctions[0]; | 1575 ''').initializer.localFunctions[0]; |
| 1591 expect(executable.localFunctions, hasLength(1)); | 1576 expect(executable.localFunctions, hasLength(1)); |
| 1592 expect(executable.localFunctions[0].returnType, isNull); | 1577 expect(executable.localFunctions[0].returnType, isNull); |
| 1593 checkInferredTypeSlot(executable.localFunctions[0].inferredReturnTypeSlot, | 1578 checkInferredTypeSlot(executable.localFunctions[0].inferredReturnTypeSlot, |
| 1594 absUri('/b.dart'), 'b.dart', 'D', | 1579 absUri('/b.dart'), 'D', |
| 1595 onlyInStrongMode: false); | 1580 onlyInStrongMode: false); |
| 1596 if (!skipFullyLinkedData) { | 1581 if (!skipFullyLinkedData) { |
| 1597 checkHasDependency('b.dart', fullyLinked: true); | 1582 checkHasDependency('b.dart', fullyLinked: true); |
| 1598 } | 1583 } |
| 1599 } | 1584 } |
| 1600 | 1585 |
| 1601 test_constExpr_binary_add() { | 1586 test_constExpr_binary_add() { |
| 1602 UnlinkedVariable variable = serializeVariableText('const v = 1 + 2;'); | 1587 UnlinkedVariable variable = serializeVariableText('const v = 1 + 2;'); |
| 1603 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1588 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 1604 UnlinkedExprOperation.pushInt, | 1589 UnlinkedExprOperation.pushInt, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 final x; | 1830 final x; |
| 1846 const C() : x = T; | 1831 const C() : x = T; |
| 1847 } | 1832 } |
| 1848 '''; | 1833 '''; |
| 1849 UnlinkedClass cls = serializeClassText(text, allowErrors: true); | 1834 UnlinkedClass cls = serializeClassText(text, allowErrors: true); |
| 1850 assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, | 1835 assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, |
| 1851 operators: [ | 1836 operators: [ |
| 1852 UnlinkedExprOperation.pushReference | 1837 UnlinkedExprOperation.pushReference |
| 1853 ], | 1838 ], |
| 1854 referenceValidators: [ | 1839 referenceValidators: [ |
| 1855 (EntityRef r) => checkTypeRef(r, null, null, 'T', | 1840 (EntityRef r) => checkTypeRef(r, null, 'T', |
| 1856 expectedKind: ReferenceKind.propertyAccessor, | 1841 expectedKind: ReferenceKind.propertyAccessor, |
| 1857 prefixExpectations: [ | 1842 prefixExpectations: [ |
| 1858 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 1843 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 1859 numTypeParameters: 1) | 1844 numTypeParameters: 1) |
| 1860 ]) | 1845 ]) |
| 1861 ]); | 1846 ]); |
| 1862 } | 1847 } |
| 1863 | 1848 |
| 1864 test_constExpr_conditional() { | 1849 test_constExpr_conditional() { |
| 1865 UnlinkedVariable variable = | 1850 UnlinkedVariable variable = |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 ], | 1920 ], |
| 1936 ints: [ | 1921 ints: [ |
| 1937 5, | 1922 5, |
| 1938 0, | 1923 0, |
| 1939 0, | 1924 0, |
| 1940 0, | 1925 0, |
| 1941 2, | 1926 2, |
| 1942 0 | 1927 0 |
| 1943 ], | 1928 ], |
| 1944 referenceValidators: [ | 1929 referenceValidators: [ |
| 1945 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 1930 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 1946 expectedKind: ReferenceKind.topLevelFunction) | 1931 expectedKind: ReferenceKind.topLevelFunction) |
| 1947 ]); | 1932 ]); |
| 1948 } | 1933 } |
| 1949 | 1934 |
| 1950 test_constExpr_functionExpression_asArgument_multiple() { | 1935 test_constExpr_functionExpression_asArgument_multiple() { |
| 1951 // Even though function expressions are not allowed in constant | 1936 // Even though function expressions are not allowed in constant |
| 1952 // declarations, they might occur due to erroneous code, so make sure they | 1937 // declarations, they might occur due to erroneous code, so make sure they |
| 1953 // function correctly. | 1938 // function correctly. |
| 1954 UnlinkedVariable variable = serializeVariableText(''' | 1939 UnlinkedVariable variable = serializeVariableText(''' |
| 1955 const v = foo(5, () => 42, () => 43); | 1940 const v = foo(5, () => 42, () => 43); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1967 5, | 1952 5, |
| 1968 0, | 1953 0, |
| 1969 0, | 1954 0, |
| 1970 0, | 1955 0, |
| 1971 1, | 1956 1, |
| 1972 0, | 1957 0, |
| 1973 3, | 1958 3, |
| 1974 0 | 1959 0 |
| 1975 ], | 1960 ], |
| 1976 referenceValidators: [ | 1961 referenceValidators: [ |
| 1977 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 1962 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 1978 expectedKind: ReferenceKind.topLevelFunction) | 1963 expectedKind: ReferenceKind.topLevelFunction) |
| 1979 ]); | 1964 ]); |
| 1980 } | 1965 } |
| 1981 | 1966 |
| 1982 test_constExpr_functionExpression_inConstructorInitializers() { | 1967 test_constExpr_functionExpression_inConstructorInitializers() { |
| 1983 // Even though function expressions are not allowed in constant | 1968 // Even though function expressions are not allowed in constant |
| 1984 // declarations, they might occur due to erroneous code, so make sure they | 1969 // declarations, they might occur due to erroneous code, so make sure they |
| 1985 // function correctly. | 1970 // function correctly. |
| 1986 UnlinkedExecutable executable = serializeClassText(''' | 1971 UnlinkedExecutable executable = serializeClassText(''' |
| 1987 class C { | 1972 class C { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2007 } | 1992 } |
| 2008 const v = const C<int, String>.named(); | 1993 const v = const C<int, String>.named(); |
| 2009 '''); | 1994 '''); |
| 2010 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 1995 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2011 UnlinkedExprOperation.invokeConstructor, | 1996 UnlinkedExprOperation.invokeConstructor, |
| 2012 ], ints: [ | 1997 ], ints: [ |
| 2013 0, | 1998 0, |
| 2014 0 | 1999 0 |
| 2015 ], referenceValidators: [ | 2000 ], referenceValidators: [ |
| 2016 (EntityRef r) { | 2001 (EntityRef r) { |
| 2017 checkTypeRef(r, null, null, 'named', | 2002 checkTypeRef(r, null, 'named', |
| 2018 expectedKind: ReferenceKind.constructor, | 2003 expectedKind: ReferenceKind.constructor, |
| 2019 prefixExpectations: [ | 2004 prefixExpectations: [ |
| 2020 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2005 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2021 numTypeParameters: 2) | 2006 numTypeParameters: 2) |
| 2022 ], | 2007 ], |
| 2023 numTypeArguments: 2); | 2008 numTypeArguments: 2); |
| 2024 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2009 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2025 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2010 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2026 } | 2011 } |
| 2027 ]); | 2012 ]); |
| 2028 } | 2013 } |
| 2029 | 2014 |
| 2030 test_constExpr_invokeConstructor_generic_named_imported() { | 2015 test_constExpr_invokeConstructor_generic_named_imported() { |
| 2031 addNamedSource( | 2016 addNamedSource( |
| 2032 '/a.dart', | 2017 '/a.dart', |
| 2033 ''' | 2018 ''' |
| 2034 class C<K, V> { | 2019 class C<K, V> { |
| 2035 const C.named(); | 2020 const C.named(); |
| 2036 } | 2021 } |
| 2037 '''); | 2022 '''); |
| 2038 UnlinkedVariable variable = serializeVariableText(''' | 2023 UnlinkedVariable variable = serializeVariableText(''' |
| 2039 import 'a.dart'; | 2024 import 'a.dart'; |
| 2040 const v = const C<int, String>.named(); | 2025 const v = const C<int, String>.named(); |
| 2041 '''); | 2026 '''); |
| 2042 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2027 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2043 UnlinkedExprOperation.invokeConstructor, | 2028 UnlinkedExprOperation.invokeConstructor, |
| 2044 ], ints: [ | 2029 ], ints: [ |
| 2045 0, | 2030 0, |
| 2046 0 | 2031 0 |
| 2047 ], referenceValidators: [ | 2032 ], referenceValidators: [ |
| 2048 (EntityRef r) { | 2033 (EntityRef r) { |
| 2049 checkTypeRef(r, null, null, 'named', | 2034 checkTypeRef(r, null, 'named', |
| 2050 expectedKind: ReferenceKind.constructor, | 2035 expectedKind: ReferenceKind.constructor, |
| 2051 prefixExpectations: [ | 2036 prefixExpectations: [ |
| 2052 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2037 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2053 absoluteUri: absUri('/a.dart'), | 2038 absoluteUri: absUri('/a.dart'), numTypeParameters: 2) |
| 2054 relativeUri: 'a.dart', | |
| 2055 numTypeParameters: 2) | |
| 2056 ], | 2039 ], |
| 2057 numTypeArguments: 2); | 2040 numTypeArguments: 2); |
| 2058 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2041 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2059 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2042 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2060 } | 2043 } |
| 2061 ]); | 2044 ]); |
| 2062 } | 2045 } |
| 2063 | 2046 |
| 2064 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { | 2047 test_constExpr_invokeConstructor_generic_named_imported_withPrefix() { |
| 2065 addNamedSource( | 2048 addNamedSource( |
| 2066 '/a.dart', | 2049 '/a.dart', |
| 2067 ''' | 2050 ''' |
| 2068 class C<K, V> { | 2051 class C<K, V> { |
| 2069 const C.named(); | 2052 const C.named(); |
| 2070 } | 2053 } |
| 2071 '''); | 2054 '''); |
| 2072 UnlinkedVariable variable = serializeVariableText(''' | 2055 UnlinkedVariable variable = serializeVariableText(''' |
| 2073 import 'a.dart' as p; | 2056 import 'a.dart' as p; |
| 2074 const v = const p.C<int, String>.named(); | 2057 const v = const p.C<int, String>.named(); |
| 2075 '''); | 2058 '''); |
| 2076 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2059 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2077 UnlinkedExprOperation.invokeConstructor, | 2060 UnlinkedExprOperation.invokeConstructor, |
| 2078 ], ints: [ | 2061 ], ints: [ |
| 2079 0, | 2062 0, |
| 2080 0 | 2063 0 |
| 2081 ], referenceValidators: [ | 2064 ], referenceValidators: [ |
| 2082 (EntityRef r) { | 2065 (EntityRef r) { |
| 2083 checkTypeRef(r, null, null, 'named', | 2066 checkTypeRef(r, null, 'named', |
| 2084 expectedKind: ReferenceKind.constructor, | 2067 expectedKind: ReferenceKind.constructor, |
| 2085 prefixExpectations: [ | 2068 prefixExpectations: [ |
| 2086 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2069 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2087 absoluteUri: absUri('/a.dart'), | 2070 absoluteUri: absUri('/a.dart'), numTypeParameters: 2), |
| 2088 relativeUri: 'a.dart', | |
| 2089 numTypeParameters: 2), | |
| 2090 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2071 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2091 ], | 2072 ], |
| 2092 numTypeArguments: 2); | 2073 numTypeArguments: 2); |
| 2093 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2074 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2094 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2075 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2095 } | 2076 } |
| 2096 ]); | 2077 ]); |
| 2097 } | 2078 } |
| 2098 | 2079 |
| 2099 test_constExpr_invokeConstructor_generic_unnamed() { | 2080 test_constExpr_invokeConstructor_generic_unnamed() { |
| 2100 UnlinkedVariable variable = serializeVariableText(''' | 2081 UnlinkedVariable variable = serializeVariableText(''' |
| 2101 class C<K, V> { | 2082 class C<K, V> { |
| 2102 const C(); | 2083 const C(); |
| 2103 } | 2084 } |
| 2104 const v = const C<int, String>(); | 2085 const v = const C<int, String>(); |
| 2105 '''); | 2086 '''); |
| 2106 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2087 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2107 UnlinkedExprOperation.invokeConstructor, | 2088 UnlinkedExprOperation.invokeConstructor, |
| 2108 ], ints: [ | 2089 ], ints: [ |
| 2109 0, | 2090 0, |
| 2110 0 | 2091 0 |
| 2111 ], referenceValidators: [ | 2092 ], referenceValidators: [ |
| 2112 (EntityRef r) { | 2093 (EntityRef r) { |
| 2113 checkTypeRef(r, null, null, 'C', | 2094 checkTypeRef(r, null, 'C', |
| 2114 expectedKind: ReferenceKind.classOrEnum, | 2095 expectedKind: ReferenceKind.classOrEnum, |
| 2115 numTypeParameters: 2, | 2096 numTypeParameters: 2, |
| 2116 numTypeArguments: 2); | 2097 numTypeArguments: 2); |
| 2117 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2098 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2118 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2099 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2119 } | 2100 } |
| 2120 ]); | 2101 ]); |
| 2121 } | 2102 } |
| 2122 | 2103 |
| 2123 test_constExpr_invokeConstructor_generic_unnamed_imported() { | 2104 test_constExpr_invokeConstructor_generic_unnamed_imported() { |
| 2124 addNamedSource( | 2105 addNamedSource( |
| 2125 '/a.dart', | 2106 '/a.dart', |
| 2126 ''' | 2107 ''' |
| 2127 class C<K, V> { | 2108 class C<K, V> { |
| 2128 const C(); | 2109 const C(); |
| 2129 } | 2110 } |
| 2130 '''); | 2111 '''); |
| 2131 UnlinkedVariable variable = serializeVariableText(''' | 2112 UnlinkedVariable variable = serializeVariableText(''' |
| 2132 import 'a.dart'; | 2113 import 'a.dart'; |
| 2133 const v = const C<int, String>(); | 2114 const v = const C<int, String>(); |
| 2134 '''); | 2115 '''); |
| 2135 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2116 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2136 UnlinkedExprOperation.invokeConstructor, | 2117 UnlinkedExprOperation.invokeConstructor, |
| 2137 ], ints: [ | 2118 ], ints: [ |
| 2138 0, | 2119 0, |
| 2139 0 | 2120 0 |
| 2140 ], referenceValidators: [ | 2121 ], referenceValidators: [ |
| 2141 (EntityRef r) { | 2122 (EntityRef r) { |
| 2142 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2123 checkTypeRef(r, absUri('/a.dart'), 'C', |
| 2143 expectedKind: ReferenceKind.classOrEnum, | 2124 expectedKind: ReferenceKind.classOrEnum, |
| 2144 numTypeParameters: 2, | 2125 numTypeParameters: 2, |
| 2145 numTypeArguments: 2); | 2126 numTypeArguments: 2); |
| 2146 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2127 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2147 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2128 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2148 } | 2129 } |
| 2149 ]); | 2130 ]); |
| 2150 } | 2131 } |
| 2151 | 2132 |
| 2152 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { | 2133 test_constExpr_invokeConstructor_generic_unnamed_imported_withPrefix() { |
| 2153 addNamedSource( | 2134 addNamedSource( |
| 2154 '/a.dart', | 2135 '/a.dart', |
| 2155 ''' | 2136 ''' |
| 2156 class C<K, V> { | 2137 class C<K, V> { |
| 2157 const C(); | 2138 const C(); |
| 2158 } | 2139 } |
| 2159 '''); | 2140 '''); |
| 2160 UnlinkedVariable variable = serializeVariableText(''' | 2141 UnlinkedVariable variable = serializeVariableText(''' |
| 2161 import 'a.dart' as p; | 2142 import 'a.dart' as p; |
| 2162 const v = const p.C<int, String>(); | 2143 const v = const p.C<int, String>(); |
| 2163 '''); | 2144 '''); |
| 2164 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2145 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2165 UnlinkedExprOperation.invokeConstructor, | 2146 UnlinkedExprOperation.invokeConstructor, |
| 2166 ], ints: [ | 2147 ], ints: [ |
| 2167 0, | 2148 0, |
| 2168 0 | 2149 0 |
| 2169 ], referenceValidators: [ | 2150 ], referenceValidators: [ |
| 2170 (EntityRef r) { | 2151 (EntityRef r) { |
| 2171 checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2152 checkTypeRef(r, absUri('/a.dart'), 'C', |
| 2172 expectedKind: ReferenceKind.classOrEnum, | 2153 expectedKind: ReferenceKind.classOrEnum, |
| 2173 numTypeParameters: 2, | 2154 numTypeParameters: 2, |
| 2174 numTypeArguments: 2, | 2155 numTypeArguments: 2, |
| 2175 prefixExpectations: [ | 2156 prefixExpectations: [ |
| 2176 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2157 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2177 ]); | 2158 ]); |
| 2178 checkTypeRef(r.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 2159 checkTypeRef(r.typeArguments[0], 'dart:core', 'int'); |
| 2179 checkTypeRef(r.typeArguments[1], 'dart:core', 'dart:core', 'String'); | 2160 checkTypeRef(r.typeArguments[1], 'dart:core', 'String'); |
| 2180 } | 2161 } |
| 2181 ]); | 2162 ]); |
| 2182 } | 2163 } |
| 2183 | 2164 |
| 2184 test_constExpr_invokeConstructor_named() { | 2165 test_constExpr_invokeConstructor_named() { |
| 2185 UnlinkedVariable variable = serializeVariableText(''' | 2166 UnlinkedVariable variable = serializeVariableText(''' |
| 2186 class C { | 2167 class C { |
| 2187 const C.named(); | 2168 const C.named(); |
| 2188 } | 2169 } |
| 2189 const v = const C.named(); | 2170 const v = const C.named(); |
| 2190 '''); | 2171 '''); |
| 2191 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2172 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2192 UnlinkedExprOperation.invokeConstructor, | 2173 UnlinkedExprOperation.invokeConstructor, |
| 2193 ], ints: [ | 2174 ], ints: [ |
| 2194 0, | 2175 0, |
| 2195 0 | 2176 0 |
| 2196 ], referenceValidators: [ | 2177 ], referenceValidators: [ |
| 2197 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2178 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 2198 expectedKind: ReferenceKind.constructor, | 2179 expectedKind: ReferenceKind.constructor, |
| 2199 prefixExpectations: [ | 2180 prefixExpectations: [ |
| 2200 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2181 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2201 ]) | 2182 ]) |
| 2202 ]); | 2183 ]); |
| 2203 } | 2184 } |
| 2204 | 2185 |
| 2205 test_constExpr_invokeConstructor_named_imported() { | 2186 test_constExpr_invokeConstructor_named_imported() { |
| 2206 addNamedSource( | 2187 addNamedSource( |
| 2207 '/a.dart', | 2188 '/a.dart', |
| 2208 ''' | 2189 ''' |
| 2209 class C { | 2190 class C { |
| 2210 const C.named(); | 2191 const C.named(); |
| 2211 } | 2192 } |
| 2212 '''); | 2193 '''); |
| 2213 UnlinkedVariable variable = serializeVariableText(''' | 2194 UnlinkedVariable variable = serializeVariableText(''' |
| 2214 import 'a.dart'; | 2195 import 'a.dart'; |
| 2215 const v = const C.named(); | 2196 const v = const C.named(); |
| 2216 '''); | 2197 '''); |
| 2217 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2198 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2218 UnlinkedExprOperation.invokeConstructor, | 2199 UnlinkedExprOperation.invokeConstructor, |
| 2219 ], ints: [ | 2200 ], ints: [ |
| 2220 0, | 2201 0, |
| 2221 0 | 2202 0 |
| 2222 ], referenceValidators: [ | 2203 ], referenceValidators: [ |
| 2223 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2204 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 2224 expectedKind: ReferenceKind.constructor, | 2205 expectedKind: ReferenceKind.constructor, |
| 2225 prefixExpectations: [ | 2206 prefixExpectations: [ |
| 2226 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2207 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2227 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2208 absoluteUri: absUri('/a.dart')) |
| 2228 ]) | 2209 ]) |
| 2229 ]); | 2210 ]); |
| 2230 } | 2211 } |
| 2231 | 2212 |
| 2232 test_constExpr_invokeConstructor_named_imported_withPrefix() { | 2213 test_constExpr_invokeConstructor_named_imported_withPrefix() { |
| 2233 addNamedSource( | 2214 addNamedSource( |
| 2234 '/a.dart', | 2215 '/a.dart', |
| 2235 ''' | 2216 ''' |
| 2236 class C { | 2217 class C { |
| 2237 const C.named(); | 2218 const C.named(); |
| 2238 } | 2219 } |
| 2239 '''); | 2220 '''); |
| 2240 UnlinkedVariable variable = serializeVariableText(''' | 2221 UnlinkedVariable variable = serializeVariableText(''' |
| 2241 import 'a.dart' as p; | 2222 import 'a.dart' as p; |
| 2242 const v = const p.C.named(); | 2223 const v = const p.C.named(); |
| 2243 '''); | 2224 '''); |
| 2244 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2225 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2245 UnlinkedExprOperation.invokeConstructor, | 2226 UnlinkedExprOperation.invokeConstructor, |
| 2246 ], ints: [ | 2227 ], ints: [ |
| 2247 0, | 2228 0, |
| 2248 0 | 2229 0 |
| 2249 ], referenceValidators: [ | 2230 ], referenceValidators: [ |
| 2250 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 2231 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 2251 expectedKind: ReferenceKind.constructor, | 2232 expectedKind: ReferenceKind.constructor, |
| 2252 prefixExpectations: [ | 2233 prefixExpectations: [ |
| 2253 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2234 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2254 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2235 absoluteUri: absUri('/a.dart')), |
| 2255 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2236 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2256 ]) | 2237 ]) |
| 2257 ]); | 2238 ]); |
| 2258 } | 2239 } |
| 2259 | 2240 |
| 2260 test_constExpr_invokeConstructor_unnamed() { | 2241 test_constExpr_invokeConstructor_unnamed() { |
| 2261 UnlinkedVariable variable = serializeVariableText(''' | 2242 UnlinkedVariable variable = serializeVariableText(''' |
| 2262 class C { | 2243 class C { |
| 2263 const C(a, b, c, d, {e, f, g}); | 2244 const C(a, b, c, d, {e, f, g}); |
| 2264 } | 2245 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2286 4, | 2267 4, |
| 2287 ], doubles: [ | 2268 ], doubles: [ |
| 2288 3.3 | 2269 3.3 |
| 2289 ], strings: [ | 2270 ], strings: [ |
| 2290 '444', | 2271 '444', |
| 2291 '777', | 2272 '777', |
| 2292 'e', | 2273 'e', |
| 2293 'g', | 2274 'g', |
| 2294 'f' | 2275 'f' |
| 2295 ], referenceValidators: [ | 2276 ], referenceValidators: [ |
| 2296 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2277 (EntityRef r) => |
| 2297 expectedKind: ReferenceKind.classOrEnum) | 2278 checkTypeRef(r, null, 'C', expectedKind: ReferenceKind.classOrEnum) |
| 2298 ]); | 2279 ]); |
| 2299 } | 2280 } |
| 2300 | 2281 |
| 2301 test_constExpr_invokeConstructor_unnamed_imported() { | 2282 test_constExpr_invokeConstructor_unnamed_imported() { |
| 2302 addNamedSource( | 2283 addNamedSource( |
| 2303 '/a.dart', | 2284 '/a.dart', |
| 2304 ''' | 2285 ''' |
| 2305 class C { | 2286 class C { |
| 2306 const C(); | 2287 const C(); |
| 2307 } | 2288 } |
| 2308 '''); | 2289 '''); |
| 2309 UnlinkedVariable variable = serializeVariableText(''' | 2290 UnlinkedVariable variable = serializeVariableText(''' |
| 2310 import 'a.dart'; | 2291 import 'a.dart'; |
| 2311 const v = const C(); | 2292 const v = const C(); |
| 2312 '''); | 2293 '''); |
| 2313 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2294 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2314 UnlinkedExprOperation.invokeConstructor, | 2295 UnlinkedExprOperation.invokeConstructor, |
| 2315 ], ints: [ | 2296 ], ints: [ |
| 2316 0, | 2297 0, |
| 2317 0 | 2298 0 |
| 2318 ], referenceValidators: [ | 2299 ], referenceValidators: [ |
| 2319 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2300 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C', |
| 2320 expectedKind: ReferenceKind.classOrEnum) | 2301 expectedKind: ReferenceKind.classOrEnum) |
| 2321 ]); | 2302 ]); |
| 2322 } | 2303 } |
| 2323 | 2304 |
| 2324 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() { | 2305 test_constExpr_invokeConstructor_unnamed_imported_withPrefix() { |
| 2325 addNamedSource( | 2306 addNamedSource( |
| 2326 '/a.dart', | 2307 '/a.dart', |
| 2327 ''' | 2308 ''' |
| 2328 class C { | 2309 class C { |
| 2329 const C(); | 2310 const C(); |
| 2330 } | 2311 } |
| 2331 '''); | 2312 '''); |
| 2332 UnlinkedVariable variable = serializeVariableText(''' | 2313 UnlinkedVariable variable = serializeVariableText(''' |
| 2333 import 'a.dart' as p; | 2314 import 'a.dart' as p; |
| 2334 const v = const p.C(); | 2315 const v = const p.C(); |
| 2335 '''); | 2316 '''); |
| 2336 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2317 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2337 UnlinkedExprOperation.invokeConstructor, | 2318 UnlinkedExprOperation.invokeConstructor, |
| 2338 ], ints: [ | 2319 ], ints: [ |
| 2339 0, | 2320 0, |
| 2340 0 | 2321 0 |
| 2341 ], referenceValidators: [ | 2322 ], referenceValidators: [ |
| 2342 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', | 2323 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'C', |
| 2343 expectedKind: ReferenceKind.classOrEnum, | 2324 expectedKind: ReferenceKind.classOrEnum, |
| 2344 prefixExpectations: [ | 2325 prefixExpectations: [ |
| 2345 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2326 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2346 ]) | 2327 ]) |
| 2347 ]); | 2328 ]); |
| 2348 } | 2329 } |
| 2349 | 2330 |
| 2350 test_constExpr_invokeConstructor_unresolved_named() { | 2331 test_constExpr_invokeConstructor_unresolved_named() { |
| 2351 UnlinkedVariable variable = serializeVariableText( | 2332 UnlinkedVariable variable = serializeVariableText( |
| 2352 ''' | 2333 ''' |
| 2353 class C {} | 2334 class C {} |
| 2354 const v = const C.foo(); | 2335 const v = const C.foo(); |
| 2355 ''', | 2336 ''', |
| 2356 allowErrors: true); | 2337 allowErrors: true); |
| 2357 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2338 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2358 UnlinkedExprOperation.invokeConstructor, | 2339 UnlinkedExprOperation.invokeConstructor, |
| 2359 ], ints: [ | 2340 ], ints: [ |
| 2360 0, | 2341 0, |
| 2361 0 | 2342 0 |
| 2362 ], referenceValidators: [ | 2343 ], referenceValidators: [ |
| 2363 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2344 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 2364 expectedKind: ReferenceKind.unresolved, | 2345 expectedKind: ReferenceKind.unresolved, |
| 2365 prefixExpectations: [ | 2346 prefixExpectations: [ |
| 2366 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2347 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2367 ]) | 2348 ]) |
| 2368 ]); | 2349 ]); |
| 2369 } | 2350 } |
| 2370 | 2351 |
| 2371 test_constExpr_invokeConstructor_unresolved_named2() { | 2352 test_constExpr_invokeConstructor_unresolved_named2() { |
| 2372 UnlinkedVariable variable = serializeVariableText( | 2353 UnlinkedVariable variable = serializeVariableText( |
| 2373 ''' | 2354 ''' |
| 2374 const v = const C.foo(); | 2355 const v = const C.foo(); |
| 2375 ''', | 2356 ''', |
| 2376 allowErrors: true); | 2357 allowErrors: true); |
| 2377 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2358 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2378 UnlinkedExprOperation.invokeConstructor, | 2359 UnlinkedExprOperation.invokeConstructor, |
| 2379 ], ints: [ | 2360 ], ints: [ |
| 2380 0, | 2361 0, |
| 2381 0 | 2362 0 |
| 2382 ], referenceValidators: [ | 2363 ], referenceValidators: [ |
| 2383 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2364 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 2384 expectedKind: ReferenceKind.unresolved, | 2365 expectedKind: ReferenceKind.unresolved, |
| 2385 prefixExpectations: [ | 2366 prefixExpectations: [ |
| 2386 new _PrefixExpectation(ReferenceKind.unresolved, 'C') | 2367 new _PrefixExpectation(ReferenceKind.unresolved, 'C') |
| 2387 ]) | 2368 ]) |
| 2388 ]); | 2369 ]); |
| 2389 } | 2370 } |
| 2390 | 2371 |
| 2391 test_constExpr_invokeConstructor_unresolved_named_prefixed() { | 2372 test_constExpr_invokeConstructor_unresolved_named_prefixed() { |
| 2392 addNamedSource( | 2373 addNamedSource( |
| 2393 '/a.dart', | 2374 '/a.dart', |
| 2394 ''' | 2375 ''' |
| 2395 class C { | 2376 class C { |
| 2396 } | 2377 } |
| 2397 '''); | 2378 '''); |
| 2398 UnlinkedVariable variable = serializeVariableText( | 2379 UnlinkedVariable variable = serializeVariableText( |
| 2399 ''' | 2380 ''' |
| 2400 import 'a.dart' as p; | 2381 import 'a.dart' as p; |
| 2401 const v = const p.C.foo(); | 2382 const v = const p.C.foo(); |
| 2402 ''', | 2383 ''', |
| 2403 allowErrors: true); | 2384 allowErrors: true); |
| 2404 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2385 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2405 UnlinkedExprOperation.invokeConstructor, | 2386 UnlinkedExprOperation.invokeConstructor, |
| 2406 ], ints: [ | 2387 ], ints: [ |
| 2407 0, | 2388 0, |
| 2408 0 | 2389 0 |
| 2409 ], referenceValidators: [ | 2390 ], referenceValidators: [ |
| 2410 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2391 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 2411 expectedKind: ReferenceKind.unresolved, | 2392 expectedKind: ReferenceKind.unresolved, |
| 2412 prefixExpectations: [ | 2393 prefixExpectations: [ |
| 2413 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2394 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2414 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2395 absoluteUri: absUri('/a.dart')), |
| 2415 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2396 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2416 ]) | 2397 ]) |
| 2417 ]); | 2398 ]); |
| 2418 } | 2399 } |
| 2419 | 2400 |
| 2420 test_constExpr_invokeConstructor_unresolved_named_prefixed2() { | 2401 test_constExpr_invokeConstructor_unresolved_named_prefixed2() { |
| 2421 addNamedSource('/a.dart', ''); | 2402 addNamedSource('/a.dart', ''); |
| 2422 UnlinkedVariable variable = serializeVariableText( | 2403 UnlinkedVariable variable = serializeVariableText( |
| 2423 ''' | 2404 ''' |
| 2424 import 'a.dart' as p; | 2405 import 'a.dart' as p; |
| 2425 const v = const p.C.foo(); | 2406 const v = const p.C.foo(); |
| 2426 ''', | 2407 ''', |
| 2427 allowErrors: true); | 2408 allowErrors: true); |
| 2428 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2409 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2429 UnlinkedExprOperation.invokeConstructor, | 2410 UnlinkedExprOperation.invokeConstructor, |
| 2430 ], ints: [ | 2411 ], ints: [ |
| 2431 0, | 2412 0, |
| 2432 0 | 2413 0 |
| 2433 ], referenceValidators: [ | 2414 ], referenceValidators: [ |
| 2434 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 2415 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 2435 expectedKind: ReferenceKind.unresolved, | 2416 expectedKind: ReferenceKind.unresolved, |
| 2436 prefixExpectations: [ | 2417 prefixExpectations: [ |
| 2437 new _PrefixExpectation(ReferenceKind.unresolved, 'C'), | 2418 new _PrefixExpectation(ReferenceKind.unresolved, 'C'), |
| 2438 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2419 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2439 ]) | 2420 ]) |
| 2440 ]); | 2421 ]); |
| 2441 } | 2422 } |
| 2442 | 2423 |
| 2443 test_constExpr_invokeConstructor_unresolved_unnamed() { | 2424 test_constExpr_invokeConstructor_unresolved_unnamed() { |
| 2444 UnlinkedVariable variable = serializeVariableText( | 2425 UnlinkedVariable variable = serializeVariableText( |
| 2445 ''' | 2426 ''' |
| 2446 const v = const Foo(); | 2427 const v = const Foo(); |
| 2447 ''', | 2428 ''', |
| 2448 allowErrors: true); | 2429 allowErrors: true); |
| 2449 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2430 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2450 UnlinkedExprOperation.invokeConstructor, | 2431 UnlinkedExprOperation.invokeConstructor, |
| 2451 ], ints: [ | 2432 ], ints: [ |
| 2452 0, | 2433 0, |
| 2453 0 | 2434 0 |
| 2454 ], referenceValidators: [ | 2435 ], referenceValidators: [ |
| 2455 (EntityRef r) => checkTypeRef(r, null, null, 'Foo', | 2436 (EntityRef r) => |
| 2456 expectedKind: ReferenceKind.unresolved) | 2437 checkTypeRef(r, null, 'Foo', expectedKind: ReferenceKind.unresolved) |
| 2457 ]); | 2438 ]); |
| 2458 } | 2439 } |
| 2459 | 2440 |
| 2460 test_constExpr_invokeMethodRef_identical() { | 2441 test_constExpr_invokeMethodRef_identical() { |
| 2461 UnlinkedVariable variable = | 2442 UnlinkedVariable variable = |
| 2462 serializeVariableText('const v = identical(42, null);'); | 2443 serializeVariableText('const v = identical(42, null);'); |
| 2463 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2444 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2464 UnlinkedExprOperation.pushInt, | 2445 UnlinkedExprOperation.pushInt, |
| 2465 UnlinkedExprOperation.pushNull, | 2446 UnlinkedExprOperation.pushNull, |
| 2466 UnlinkedExprOperation.invokeMethodRef | 2447 UnlinkedExprOperation.invokeMethodRef |
| 2467 ], ints: [ | 2448 ], ints: [ |
| 2468 42, | 2449 42, |
| 2469 0, | 2450 0, |
| 2470 2, | 2451 2, |
| 2471 0 | 2452 0 |
| 2472 ], referenceValidators: [ | 2453 ], referenceValidators: [ |
| 2473 (EntityRef r) { | 2454 (EntityRef r) { |
| 2474 checkTypeRef(r, 'dart:core', 'dart:core', 'identical', | 2455 checkTypeRef(r, 'dart:core', 'identical', |
| 2475 expectedKind: ReferenceKind.topLevelFunction); | 2456 expectedKind: ReferenceKind.topLevelFunction); |
| 2476 } | 2457 } |
| 2477 ]); | 2458 ]); |
| 2478 } | 2459 } |
| 2479 | 2460 |
| 2480 test_constExpr_length_classConstField() { | 2461 test_constExpr_length_classConstField() { |
| 2481 UnlinkedVariable variable = serializeVariableText(''' | 2462 UnlinkedVariable variable = serializeVariableText(''' |
| 2482 class C { | 2463 class C { |
| 2483 static const int length = 0; | 2464 static const int length = 0; |
| 2484 } | 2465 } |
| 2485 const int v = C.length; | 2466 const int v = C.length; |
| 2486 '''); | 2467 '''); |
| 2487 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2468 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2488 UnlinkedExprOperation.pushReference | 2469 UnlinkedExprOperation.pushReference |
| 2489 ], referenceValidators: [ | 2470 ], referenceValidators: [ |
| 2490 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2471 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2491 expectedKind: ReferenceKind.propertyAccessor, | 2472 expectedKind: ReferenceKind.propertyAccessor, |
| 2492 prefixExpectations: [ | 2473 prefixExpectations: [ |
| 2493 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2474 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2494 ]) | 2475 ]) |
| 2495 ]); | 2476 ]); |
| 2496 } | 2477 } |
| 2497 | 2478 |
| 2498 test_constExpr_length_classConstField_imported_withPrefix() { | 2479 test_constExpr_length_classConstField_imported_withPrefix() { |
| 2499 addNamedSource( | 2480 addNamedSource( |
| 2500 '/a.dart', | 2481 '/a.dart', |
| 2501 ''' | 2482 ''' |
| 2502 class C { | 2483 class C { |
| 2503 static const int length = 0; | 2484 static const int length = 0; |
| 2504 } | 2485 } |
| 2505 '''); | 2486 '''); |
| 2506 UnlinkedVariable variable = serializeVariableText(''' | 2487 UnlinkedVariable variable = serializeVariableText(''' |
| 2507 import 'a.dart' as p; | 2488 import 'a.dart' as p; |
| 2508 const int v = p.C.length; | 2489 const int v = p.C.length; |
| 2509 '''); | 2490 '''); |
| 2510 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2491 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2511 UnlinkedExprOperation.pushReference | 2492 UnlinkedExprOperation.pushReference |
| 2512 ], referenceValidators: [ | 2493 ], referenceValidators: [ |
| 2513 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2494 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2514 expectedKind: ReferenceKind.propertyAccessor, | 2495 expectedKind: ReferenceKind.propertyAccessor, |
| 2515 prefixExpectations: [ | 2496 prefixExpectations: [ |
| 2516 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2497 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2517 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2498 absoluteUri: absUri('/a.dart')), |
| 2518 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2499 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2519 ]) | 2500 ]) |
| 2520 ]); | 2501 ]); |
| 2521 } | 2502 } |
| 2522 | 2503 |
| 2523 test_constExpr_length_identifierTarget() { | 2504 test_constExpr_length_identifierTarget() { |
| 2524 UnlinkedVariable variable = serializeVariableText(''' | 2505 UnlinkedVariable variable = serializeVariableText(''' |
| 2525 const String a = 'aaa'; | 2506 const String a = 'aaa'; |
| 2526 const int v = a.length; | 2507 const int v = a.length; |
| 2527 '''); | 2508 '''); |
| 2528 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2509 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2529 UnlinkedExprOperation.pushReference | 2510 UnlinkedExprOperation.pushReference |
| 2530 ], referenceValidators: [ | 2511 ], referenceValidators: [ |
| 2531 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2512 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2532 expectedKind: ReferenceKind.unresolved, | 2513 expectedKind: ReferenceKind.unresolved, |
| 2533 unresolvedHasName: true, | 2514 unresolvedHasName: true, |
| 2534 prefixExpectations: [ | 2515 prefixExpectations: [ |
| 2535 new _PrefixExpectation( | 2516 new _PrefixExpectation( |
| 2536 ReferenceKind.topLevelPropertyAccessor, 'a') | 2517 ReferenceKind.topLevelPropertyAccessor, 'a') |
| 2537 ]) | 2518 ]) |
| 2538 ]); | 2519 ]); |
| 2539 } | 2520 } |
| 2540 | 2521 |
| 2541 test_constExpr_length_identifierTarget_classConstField() { | 2522 test_constExpr_length_identifierTarget_classConstField() { |
| 2542 UnlinkedVariable variable = serializeVariableText(''' | 2523 UnlinkedVariable variable = serializeVariableText(''' |
| 2543 class C { | 2524 class C { |
| 2544 static const String F = ''; | 2525 static const String F = ''; |
| 2545 } | 2526 } |
| 2546 const int v = C.F.length; | 2527 const int v = C.F.length; |
| 2547 '''); | 2528 '''); |
| 2548 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2529 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2549 UnlinkedExprOperation.pushReference | 2530 UnlinkedExprOperation.pushReference |
| 2550 ], referenceValidators: [ | 2531 ], referenceValidators: [ |
| 2551 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2532 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2552 expectedKind: ReferenceKind.unresolved, | 2533 expectedKind: ReferenceKind.unresolved, |
| 2553 unresolvedHasName: true, | 2534 unresolvedHasName: true, |
| 2554 prefixExpectations: [ | 2535 prefixExpectations: [ |
| 2555 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'), | 2536 new _PrefixExpectation(ReferenceKind.propertyAccessor, 'F'), |
| 2556 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), | 2537 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'), |
| 2557 ]) | 2538 ]) |
| 2558 ]); | 2539 ]); |
| 2559 } | 2540 } |
| 2560 | 2541 |
| 2561 test_constExpr_length_identifierTarget_imported() { | 2542 test_constExpr_length_identifierTarget_imported() { |
| 2562 addNamedSource( | 2543 addNamedSource( |
| 2563 '/a.dart', | 2544 '/a.dart', |
| 2564 ''' | 2545 ''' |
| 2565 const String a = 'aaa'; | 2546 const String a = 'aaa'; |
| 2566 '''); | 2547 '''); |
| 2567 UnlinkedVariable variable = serializeVariableText(''' | 2548 UnlinkedVariable variable = serializeVariableText(''' |
| 2568 import 'a.dart'; | 2549 import 'a.dart'; |
| 2569 const int v = a.length; | 2550 const int v = a.length; |
| 2570 '''); | 2551 '''); |
| 2571 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2552 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2572 UnlinkedExprOperation.pushReference | 2553 UnlinkedExprOperation.pushReference |
| 2573 ], referenceValidators: [ | 2554 ], referenceValidators: [ |
| 2574 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2555 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2575 expectedKind: ReferenceKind.unresolved, | 2556 expectedKind: ReferenceKind.unresolved, |
| 2576 unresolvedHasName: true, | 2557 unresolvedHasName: true, |
| 2577 prefixExpectations: [ | 2558 prefixExpectations: [ |
| 2578 new _PrefixExpectation( | 2559 new _PrefixExpectation( |
| 2579 ReferenceKind.topLevelPropertyAccessor, 'a', | 2560 ReferenceKind.topLevelPropertyAccessor, 'a', |
| 2580 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2561 absoluteUri: absUri('/a.dart')) |
| 2581 ]) | 2562 ]) |
| 2582 ]); | 2563 ]); |
| 2583 } | 2564 } |
| 2584 | 2565 |
| 2585 test_constExpr_length_identifierTarget_imported_withPrefix() { | 2566 test_constExpr_length_identifierTarget_imported_withPrefix() { |
| 2586 addNamedSource( | 2567 addNamedSource( |
| 2587 '/a.dart', | 2568 '/a.dart', |
| 2588 ''' | 2569 ''' |
| 2589 const String a = 'aaa'; | 2570 const String a = 'aaa'; |
| 2590 '''); | 2571 '''); |
| 2591 UnlinkedVariable variable = serializeVariableText(''' | 2572 UnlinkedVariable variable = serializeVariableText(''' |
| 2592 import 'a.dart' as p; | 2573 import 'a.dart' as p; |
| 2593 const int v = p.a.length; | 2574 const int v = p.a.length; |
| 2594 '''); | 2575 '''); |
| 2595 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2576 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2596 UnlinkedExprOperation.pushReference | 2577 UnlinkedExprOperation.pushReference |
| 2597 ], referenceValidators: [ | 2578 ], referenceValidators: [ |
| 2598 (EntityRef r) => checkTypeRef(r, null, null, 'length', | 2579 (EntityRef r) => checkTypeRef(r, null, 'length', |
| 2599 expectedKind: ReferenceKind.unresolved, | 2580 expectedKind: ReferenceKind.unresolved, |
| 2600 unresolvedHasName: true, | 2581 unresolvedHasName: true, |
| 2601 prefixExpectations: [ | 2582 prefixExpectations: [ |
| 2602 new _PrefixExpectation( | 2583 new _PrefixExpectation( |
| 2603 ReferenceKind.topLevelPropertyAccessor, 'a', | 2584 ReferenceKind.topLevelPropertyAccessor, 'a', |
| 2604 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2585 absoluteUri: absUri('/a.dart')), |
| 2605 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 2586 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2606 ]) | 2587 ]) |
| 2607 ]); | 2588 ]); |
| 2608 } | 2589 } |
| 2609 | 2590 |
| 2610 test_constExpr_length_parenthesizedBinaryTarget() { | 2591 test_constExpr_length_parenthesizedBinaryTarget() { |
| 2611 UnlinkedVariable variable = | 2592 UnlinkedVariable variable = |
| 2612 serializeVariableText('const v = ("abc" + "edf").length;'); | 2593 serializeVariableText('const v = ("abc" + "edf").length;'); |
| 2613 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2594 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2614 UnlinkedExprOperation.pushString, | 2595 UnlinkedExprOperation.pushString, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 UnlinkedExprOperation.pushInt, | 2640 UnlinkedExprOperation.pushInt, |
| 2660 UnlinkedExprOperation.pushInt, | 2641 UnlinkedExprOperation.pushInt, |
| 2661 UnlinkedExprOperation.pushInt, | 2642 UnlinkedExprOperation.pushInt, |
| 2662 UnlinkedExprOperation.makeTypedList | 2643 UnlinkedExprOperation.makeTypedList |
| 2663 ], ints: [ | 2644 ], ints: [ |
| 2664 11, | 2645 11, |
| 2665 22, | 2646 22, |
| 2666 33, | 2647 33, |
| 2667 3 | 2648 3 |
| 2668 ], referenceValidators: [ | 2649 ], referenceValidators: [ |
| 2669 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 2650 (EntityRef r) => checkTypeRef(r, 'dart:core', 'int', |
| 2670 expectedKind: ReferenceKind.classOrEnum) | 2651 expectedKind: ReferenceKind.classOrEnum) |
| 2671 ]); | 2652 ]); |
| 2672 } | 2653 } |
| 2673 | 2654 |
| 2674 test_constExpr_makeTypedList_dynamic() { | 2655 test_constExpr_makeTypedList_dynamic() { |
| 2675 UnlinkedVariable variable = | 2656 UnlinkedVariable variable = |
| 2676 serializeVariableText('const v = const <dynamic>[11, 22, 33];'); | 2657 serializeVariableText('const v = const <dynamic>[11, 22, 33];'); |
| 2677 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2658 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2678 UnlinkedExprOperation.pushInt, | 2659 UnlinkedExprOperation.pushInt, |
| 2679 UnlinkedExprOperation.pushInt, | 2660 UnlinkedExprOperation.pushInt, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2703 ], ints: [ | 2684 ], ints: [ |
| 2704 11, | 2685 11, |
| 2705 22, | 2686 22, |
| 2706 33, | 2687 33, |
| 2707 3 | 2688 3 |
| 2708 ], strings: [ | 2689 ], strings: [ |
| 2709 'aaa', | 2690 'aaa', |
| 2710 'bbb', | 2691 'bbb', |
| 2711 'ccc' | 2692 'ccc' |
| 2712 ], referenceValidators: [ | 2693 ], referenceValidators: [ |
| 2713 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int', | 2694 (EntityRef r) => checkTypeRef(r, 'dart:core', 'int', |
| 2714 expectedKind: ReferenceKind.classOrEnum), | 2695 expectedKind: ReferenceKind.classOrEnum), |
| 2715 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String', | 2696 (EntityRef r) => checkTypeRef(r, 'dart:core', 'String', |
| 2716 expectedKind: ReferenceKind.classOrEnum) | 2697 expectedKind: ReferenceKind.classOrEnum) |
| 2717 ]); | 2698 ]); |
| 2718 } | 2699 } |
| 2719 | 2700 |
| 2720 test_constExpr_makeTypedMap_dynamic() { | 2701 test_constExpr_makeTypedMap_dynamic() { |
| 2721 UnlinkedVariable variable = serializeVariableText( | 2702 UnlinkedVariable variable = serializeVariableText( |
| 2722 'const v = const <dynamic, dynamic>{11: "aaa", 22: "bbb", 33: "ccc"};'); | 2703 'const v = const <dynamic, dynamic>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
| 2723 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2704 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2724 UnlinkedExprOperation.pushInt, | 2705 UnlinkedExprOperation.pushInt, |
| 2725 UnlinkedExprOperation.pushString, | 2706 UnlinkedExprOperation.pushString, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2899 } | 2880 } |
| 2900 | 2881 |
| 2901 test_constExpr_pushReference_class() { | 2882 test_constExpr_pushReference_class() { |
| 2902 UnlinkedVariable variable = serializeVariableText(''' | 2883 UnlinkedVariable variable = serializeVariableText(''' |
| 2903 class C {} | 2884 class C {} |
| 2904 const v = C; | 2885 const v = C; |
| 2905 '''); | 2886 '''); |
| 2906 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2887 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2907 UnlinkedExprOperation.pushReference | 2888 UnlinkedExprOperation.pushReference |
| 2908 ], referenceValidators: [ | 2889 ], referenceValidators: [ |
| 2909 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2890 (EntityRef r) => |
| 2910 expectedKind: ReferenceKind.classOrEnum) | 2891 checkTypeRef(r, null, 'C', expectedKind: ReferenceKind.classOrEnum) |
| 2911 ]); | 2892 ]); |
| 2912 } | 2893 } |
| 2913 | 2894 |
| 2914 test_constExpr_pushReference_enum() { | 2895 test_constExpr_pushReference_enum() { |
| 2915 UnlinkedVariable variable = serializeVariableText(''' | 2896 UnlinkedVariable variable = serializeVariableText(''' |
| 2916 enum C {V1, V2, V3} | 2897 enum C {V1, V2, V3} |
| 2917 const v = C; | 2898 const v = C; |
| 2918 '''); | 2899 '''); |
| 2919 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2900 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2920 UnlinkedExprOperation.pushReference | 2901 UnlinkedExprOperation.pushReference |
| 2921 ], referenceValidators: [ | 2902 ], referenceValidators: [ |
| 2922 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2903 (EntityRef r) => |
| 2923 expectedKind: ReferenceKind.classOrEnum) | 2904 checkTypeRef(r, null, 'C', expectedKind: ReferenceKind.classOrEnum) |
| 2924 ]); | 2905 ]); |
| 2925 } | 2906 } |
| 2926 | 2907 |
| 2927 test_constExpr_pushReference_enumValue() { | 2908 test_constExpr_pushReference_enumValue() { |
| 2928 UnlinkedVariable variable = serializeVariableText(''' | 2909 UnlinkedVariable variable = serializeVariableText(''' |
| 2929 enum C {V1, V2, V3} | 2910 enum C {V1, V2, V3} |
| 2930 const v = C.V1; | 2911 const v = C.V1; |
| 2931 '''); | 2912 '''); |
| 2932 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2913 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2933 UnlinkedExprOperation.pushReference | 2914 UnlinkedExprOperation.pushReference |
| 2934 ], referenceValidators: [ | 2915 ], referenceValidators: [ |
| 2935 (EntityRef r) => checkTypeRef(r, null, null, 'V1', | 2916 (EntityRef r) => checkTypeRef(r, null, 'V1', |
| 2936 expectedKind: ReferenceKind.propertyAccessor, | 2917 expectedKind: ReferenceKind.propertyAccessor, |
| 2937 prefixExpectations: [ | 2918 prefixExpectations: [ |
| 2938 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2919 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2939 ]) | 2920 ]) |
| 2940 ]); | 2921 ]); |
| 2941 } | 2922 } |
| 2942 | 2923 |
| 2943 test_constExpr_pushReference_enumValue_viaImport() { | 2924 test_constExpr_pushReference_enumValue_viaImport() { |
| 2944 addNamedSource( | 2925 addNamedSource( |
| 2945 '/a.dart', | 2926 '/a.dart', |
| 2946 ''' | 2927 ''' |
| 2947 enum C {V1, V2, V3} | 2928 enum C {V1, V2, V3} |
| 2948 '''); | 2929 '''); |
| 2949 UnlinkedVariable variable = serializeVariableText(''' | 2930 UnlinkedVariable variable = serializeVariableText(''' |
| 2950 import 'a.dart'; | 2931 import 'a.dart'; |
| 2951 const v = C.V1; | 2932 const v = C.V1; |
| 2952 '''); | 2933 '''); |
| 2953 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2934 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2954 UnlinkedExprOperation.pushReference | 2935 UnlinkedExprOperation.pushReference |
| 2955 ], referenceValidators: [ | 2936 ], referenceValidators: [ |
| 2956 (EntityRef r) => checkTypeRef(r, null, null, 'V1', | 2937 (EntityRef r) => checkTypeRef(r, null, 'V1', |
| 2957 expectedKind: ReferenceKind.propertyAccessor, | 2938 expectedKind: ReferenceKind.propertyAccessor, |
| 2958 prefixExpectations: [ | 2939 prefixExpectations: [ |
| 2959 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2940 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2960 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2941 absoluteUri: absUri('/a.dart')) |
| 2961 ]) | 2942 ]) |
| 2962 ]); | 2943 ]); |
| 2963 } | 2944 } |
| 2964 | 2945 |
| 2965 test_constExpr_pushReference_enumValues() { | 2946 test_constExpr_pushReference_enumValues() { |
| 2966 UnlinkedVariable variable = serializeVariableText(''' | 2947 UnlinkedVariable variable = serializeVariableText(''' |
| 2967 enum C {V1, V2, V3} | 2948 enum C {V1, V2, V3} |
| 2968 const v = C.values; | 2949 const v = C.values; |
| 2969 '''); | 2950 '''); |
| 2970 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2951 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2971 UnlinkedExprOperation.pushReference | 2952 UnlinkedExprOperation.pushReference |
| 2972 ], referenceValidators: [ | 2953 ], referenceValidators: [ |
| 2973 (EntityRef r) => checkTypeRef(r, null, null, 'values', | 2954 (EntityRef r) => checkTypeRef(r, null, 'values', |
| 2974 expectedKind: ReferenceKind.propertyAccessor, | 2955 expectedKind: ReferenceKind.propertyAccessor, |
| 2975 prefixExpectations: [ | 2956 prefixExpectations: [ |
| 2976 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2957 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2977 ]) | 2958 ]) |
| 2978 ]); | 2959 ]); |
| 2979 } | 2960 } |
| 2980 | 2961 |
| 2981 test_constExpr_pushReference_enumValues_viaImport() { | 2962 test_constExpr_pushReference_enumValues_viaImport() { |
| 2982 addNamedSource( | 2963 addNamedSource( |
| 2983 '/a.dart', | 2964 '/a.dart', |
| 2984 ''' | 2965 ''' |
| 2985 enum C {V1, V2, V3} | 2966 enum C {V1, V2, V3} |
| 2986 '''); | 2967 '''); |
| 2987 UnlinkedVariable variable = serializeVariableText(''' | 2968 UnlinkedVariable variable = serializeVariableText(''' |
| 2988 import 'a.dart'; | 2969 import 'a.dart'; |
| 2989 const v = C.values; | 2970 const v = C.values; |
| 2990 '''); | 2971 '''); |
| 2991 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2972 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 2992 UnlinkedExprOperation.pushReference | 2973 UnlinkedExprOperation.pushReference |
| 2993 ], referenceValidators: [ | 2974 ], referenceValidators: [ |
| 2994 (EntityRef r) => checkTypeRef(r, null, null, 'values', | 2975 (EntityRef r) => checkTypeRef(r, null, 'values', |
| 2995 expectedKind: ReferenceKind.propertyAccessor, | 2976 expectedKind: ReferenceKind.propertyAccessor, |
| 2996 prefixExpectations: [ | 2977 prefixExpectations: [ |
| 2997 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2978 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2998 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 2979 absoluteUri: absUri('/a.dart')) |
| 2999 ]) | 2980 ]) |
| 3000 ]); | 2981 ]); |
| 3001 } | 2982 } |
| 3002 | 2983 |
| 3003 test_constExpr_pushReference_field() { | 2984 test_constExpr_pushReference_field() { |
| 3004 UnlinkedVariable variable = serializeVariableText(''' | 2985 UnlinkedVariable variable = serializeVariableText(''' |
| 3005 class C { | 2986 class C { |
| 3006 static const int F = 1; | 2987 static const int F = 1; |
| 3007 } | 2988 } |
| 3008 const v = C.F; | 2989 const v = C.F; |
| 3009 '''); | 2990 '''); |
| 3010 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 2991 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3011 UnlinkedExprOperation.pushReference | 2992 UnlinkedExprOperation.pushReference |
| 3012 ], referenceValidators: [ | 2993 ], referenceValidators: [ |
| 3013 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 2994 (EntityRef r) => checkTypeRef(r, null, 'F', |
| 3014 expectedKind: ReferenceKind.propertyAccessor, | 2995 expectedKind: ReferenceKind.propertyAccessor, |
| 3015 prefixExpectations: [ | 2996 prefixExpectations: [ |
| 3016 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2997 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3017 ]) | 2998 ]) |
| 3018 ]); | 2999 ]); |
| 3019 } | 3000 } |
| 3020 | 3001 |
| 3021 test_constExpr_pushReference_field_imported() { | 3002 test_constExpr_pushReference_field_imported() { |
| 3022 addNamedSource( | 3003 addNamedSource( |
| 3023 '/a.dart', | 3004 '/a.dart', |
| 3024 ''' | 3005 ''' |
| 3025 class C { | 3006 class C { |
| 3026 static const int F = 1; | 3007 static const int F = 1; |
| 3027 } | 3008 } |
| 3028 '''); | 3009 '''); |
| 3029 UnlinkedVariable variable = serializeVariableText(''' | 3010 UnlinkedVariable variable = serializeVariableText(''' |
| 3030 import 'a.dart'; | 3011 import 'a.dart'; |
| 3031 const v = C.F; | 3012 const v = C.F; |
| 3032 '''); | 3013 '''); |
| 3033 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3014 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3034 UnlinkedExprOperation.pushReference | 3015 UnlinkedExprOperation.pushReference |
| 3035 ], referenceValidators: [ | 3016 ], referenceValidators: [ |
| 3036 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 3017 (EntityRef r) => checkTypeRef(r, null, 'F', |
| 3037 expectedKind: ReferenceKind.propertyAccessor, | 3018 expectedKind: ReferenceKind.propertyAccessor, |
| 3038 prefixExpectations: [ | 3019 prefixExpectations: [ |
| 3039 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3020 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3040 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 3021 absoluteUri: absUri('/a.dart')) |
| 3041 ]) | 3022 ]) |
| 3042 ]); | 3023 ]); |
| 3043 } | 3024 } |
| 3044 | 3025 |
| 3045 test_constExpr_pushReference_field_imported_withPrefix() { | 3026 test_constExpr_pushReference_field_imported_withPrefix() { |
| 3046 addNamedSource( | 3027 addNamedSource( |
| 3047 '/a.dart', | 3028 '/a.dart', |
| 3048 ''' | 3029 ''' |
| 3049 class C { | 3030 class C { |
| 3050 static const int F = 1; | 3031 static const int F = 1; |
| 3051 } | 3032 } |
| 3052 '''); | 3033 '''); |
| 3053 UnlinkedVariable variable = serializeVariableText(''' | 3034 UnlinkedVariable variable = serializeVariableText(''' |
| 3054 import 'a.dart' as p; | 3035 import 'a.dart' as p; |
| 3055 const v = p.C.F; | 3036 const v = p.C.F; |
| 3056 '''); | 3037 '''); |
| 3057 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3038 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3058 UnlinkedExprOperation.pushReference | 3039 UnlinkedExprOperation.pushReference |
| 3059 ], referenceValidators: [ | 3040 ], referenceValidators: [ |
| 3060 (EntityRef r) => checkTypeRef(r, null, null, 'F', | 3041 (EntityRef r) => checkTypeRef(r, null, 'F', |
| 3061 expectedKind: ReferenceKind.propertyAccessor, | 3042 expectedKind: ReferenceKind.propertyAccessor, |
| 3062 prefixExpectations: [ | 3043 prefixExpectations: [ |
| 3063 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3044 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3064 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3045 absoluteUri: absUri('/a.dart')), |
| 3065 new _PrefixExpectation(ReferenceKind.prefix, 'p'), | 3046 new _PrefixExpectation(ReferenceKind.prefix, 'p'), |
| 3066 ]) | 3047 ]) |
| 3067 ]); | 3048 ]); |
| 3068 } | 3049 } |
| 3069 | 3050 |
| 3070 test_constExpr_pushReference_field_simpleIdentifier() { | 3051 test_constExpr_pushReference_field_simpleIdentifier() { |
| 3071 UnlinkedVariable variable = serializeClassText(''' | 3052 UnlinkedVariable variable = serializeClassText(''' |
| 3072 class C { | 3053 class C { |
| 3073 static const a = b; | 3054 static const a = b; |
| 3074 static const b = null; | 3055 static const b = null; |
| 3075 } | 3056 } |
| 3076 ''').fields[0]; | 3057 ''').fields[0]; |
| 3077 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3058 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3078 UnlinkedExprOperation.pushReference | 3059 UnlinkedExprOperation.pushReference |
| 3079 ], referenceValidators: [ | 3060 ], referenceValidators: [ |
| 3080 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 3061 (EntityRef r) => checkTypeRef(r, null, 'b', |
| 3081 expectedKind: ReferenceKind.propertyAccessor, | 3062 expectedKind: ReferenceKind.propertyAccessor, |
| 3082 prefixExpectations: [ | 3063 prefixExpectations: [ |
| 3083 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3064 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3084 ]) | 3065 ]) |
| 3085 ]); | 3066 ]); |
| 3086 } | 3067 } |
| 3087 | 3068 |
| 3088 test_constExpr_pushReference_staticGetter() { | 3069 test_constExpr_pushReference_staticGetter() { |
| 3089 UnlinkedVariable variable = serializeVariableText(''' | 3070 UnlinkedVariable variable = serializeVariableText(''' |
| 3090 class C { | 3071 class C { |
| 3091 static int get x => null; | 3072 static int get x => null; |
| 3092 } | 3073 } |
| 3093 const v = C.x; | 3074 const v = C.x; |
| 3094 '''); | 3075 '''); |
| 3095 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3076 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3096 UnlinkedExprOperation.pushReference | 3077 UnlinkedExprOperation.pushReference |
| 3097 ], referenceValidators: [ | 3078 ], referenceValidators: [ |
| 3098 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3079 (EntityRef r) => checkTypeRef(r, null, 'x', |
| 3099 expectedKind: ReferenceKind.propertyAccessor, | 3080 expectedKind: ReferenceKind.propertyAccessor, |
| 3100 prefixExpectations: [ | 3081 prefixExpectations: [ |
| 3101 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3082 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3102 ]) | 3083 ]) |
| 3103 ]); | 3084 ]); |
| 3104 } | 3085 } |
| 3105 | 3086 |
| 3106 test_constExpr_pushReference_staticGetter_imported() { | 3087 test_constExpr_pushReference_staticGetter_imported() { |
| 3107 addNamedSource( | 3088 addNamedSource( |
| 3108 '/a.dart', | 3089 '/a.dart', |
| 3109 ''' | 3090 ''' |
| 3110 class C { | 3091 class C { |
| 3111 static int get x => null; | 3092 static int get x => null; |
| 3112 } | 3093 } |
| 3113 '''); | 3094 '''); |
| 3114 UnlinkedVariable variable = serializeVariableText(''' | 3095 UnlinkedVariable variable = serializeVariableText(''' |
| 3115 import 'a.dart'; | 3096 import 'a.dart'; |
| 3116 const v = C.x; | 3097 const v = C.x; |
| 3117 '''); | 3098 '''); |
| 3118 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3099 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3119 UnlinkedExprOperation.pushReference | 3100 UnlinkedExprOperation.pushReference |
| 3120 ], referenceValidators: [ | 3101 ], referenceValidators: [ |
| 3121 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3102 (EntityRef r) => checkTypeRef(r, null, 'x', |
| 3122 expectedKind: ReferenceKind.propertyAccessor, | 3103 expectedKind: ReferenceKind.propertyAccessor, |
| 3123 prefixExpectations: [ | 3104 prefixExpectations: [ |
| 3124 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3105 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3125 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 3106 absoluteUri: absUri('/a.dart')) |
| 3126 ]) | 3107 ]) |
| 3127 ]); | 3108 ]); |
| 3128 } | 3109 } |
| 3129 | 3110 |
| 3130 test_constExpr_pushReference_staticGetter_imported_withPrefix() { | 3111 test_constExpr_pushReference_staticGetter_imported_withPrefix() { |
| 3131 addNamedSource( | 3112 addNamedSource( |
| 3132 '/a.dart', | 3113 '/a.dart', |
| 3133 ''' | 3114 ''' |
| 3134 class C { | 3115 class C { |
| 3135 static int get x => null; | 3116 static int get x => null; |
| 3136 } | 3117 } |
| 3137 '''); | 3118 '''); |
| 3138 UnlinkedVariable variable = serializeVariableText(''' | 3119 UnlinkedVariable variable = serializeVariableText(''' |
| 3139 import 'a.dart' as p; | 3120 import 'a.dart' as p; |
| 3140 const v = p.C.x; | 3121 const v = p.C.x; |
| 3141 '''); | 3122 '''); |
| 3142 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3123 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3143 UnlinkedExprOperation.pushReference | 3124 UnlinkedExprOperation.pushReference |
| 3144 ], referenceValidators: [ | 3125 ], referenceValidators: [ |
| 3145 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3126 (EntityRef r) => checkTypeRef(r, null, 'x', |
| 3146 expectedKind: ReferenceKind.propertyAccessor, | 3127 expectedKind: ReferenceKind.propertyAccessor, |
| 3147 prefixExpectations: [ | 3128 prefixExpectations: [ |
| 3148 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3129 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3149 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3130 absoluteUri: absUri('/a.dart')), |
| 3150 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3131 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 3151 ]) | 3132 ]) |
| 3152 ]); | 3133 ]); |
| 3153 } | 3134 } |
| 3154 | 3135 |
| 3155 test_constExpr_pushReference_staticMethod() { | 3136 test_constExpr_pushReference_staticMethod() { |
| 3156 UnlinkedVariable variable = serializeVariableText(''' | 3137 UnlinkedVariable variable = serializeVariableText(''' |
| 3157 class C { | 3138 class C { |
| 3158 static m() {} | 3139 static m() {} |
| 3159 } | 3140 } |
| 3160 const v = C.m; | 3141 const v = C.m; |
| 3161 '''); | 3142 '''); |
| 3162 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3143 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3163 UnlinkedExprOperation.pushReference | 3144 UnlinkedExprOperation.pushReference |
| 3164 ], referenceValidators: [ | 3145 ], referenceValidators: [ |
| 3165 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3146 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 3166 expectedKind: ReferenceKind.method, | 3147 expectedKind: ReferenceKind.method, |
| 3167 prefixExpectations: [ | 3148 prefixExpectations: [ |
| 3168 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3149 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3169 ]) | 3150 ]) |
| 3170 ]); | 3151 ]); |
| 3171 } | 3152 } |
| 3172 | 3153 |
| 3173 test_constExpr_pushReference_staticMethod_imported() { | 3154 test_constExpr_pushReference_staticMethod_imported() { |
| 3174 addNamedSource( | 3155 addNamedSource( |
| 3175 '/a.dart', | 3156 '/a.dart', |
| 3176 ''' | 3157 ''' |
| 3177 class C { | 3158 class C { |
| 3178 static m() {} | 3159 static m() {} |
| 3179 } | 3160 } |
| 3180 '''); | 3161 '''); |
| 3181 UnlinkedVariable variable = serializeVariableText(''' | 3162 UnlinkedVariable variable = serializeVariableText(''' |
| 3182 import 'a.dart'; | 3163 import 'a.dart'; |
| 3183 const v = C.m; | 3164 const v = C.m; |
| 3184 '''); | 3165 '''); |
| 3185 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3166 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3186 UnlinkedExprOperation.pushReference | 3167 UnlinkedExprOperation.pushReference |
| 3187 ], referenceValidators: [ | 3168 ], referenceValidators: [ |
| 3188 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3169 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 3189 expectedKind: ReferenceKind.method, | 3170 expectedKind: ReferenceKind.method, |
| 3190 prefixExpectations: [ | 3171 prefixExpectations: [ |
| 3191 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3172 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3192 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') | 3173 absoluteUri: absUri('/a.dart')) |
| 3193 ]) | 3174 ]) |
| 3194 ]); | 3175 ]); |
| 3195 } | 3176 } |
| 3196 | 3177 |
| 3197 test_constExpr_pushReference_staticMethod_imported_withPrefix() { | 3178 test_constExpr_pushReference_staticMethod_imported_withPrefix() { |
| 3198 addNamedSource( | 3179 addNamedSource( |
| 3199 '/a.dart', | 3180 '/a.dart', |
| 3200 ''' | 3181 ''' |
| 3201 class C { | 3182 class C { |
| 3202 static m() {} | 3183 static m() {} |
| 3203 } | 3184 } |
| 3204 '''); | 3185 '''); |
| 3205 UnlinkedVariable variable = serializeVariableText(''' | 3186 UnlinkedVariable variable = serializeVariableText(''' |
| 3206 import 'a.dart' as p; | 3187 import 'a.dart' as p; |
| 3207 const v = p.C.m; | 3188 const v = p.C.m; |
| 3208 '''); | 3189 '''); |
| 3209 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3190 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3210 UnlinkedExprOperation.pushReference | 3191 UnlinkedExprOperation.pushReference |
| 3211 ], referenceValidators: [ | 3192 ], referenceValidators: [ |
| 3212 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3193 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 3213 expectedKind: ReferenceKind.method, | 3194 expectedKind: ReferenceKind.method, |
| 3214 prefixExpectations: [ | 3195 prefixExpectations: [ |
| 3215 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3196 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3216 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3197 absoluteUri: absUri('/a.dart')), |
| 3217 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3198 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 3218 ]) | 3199 ]) |
| 3219 ]); | 3200 ]); |
| 3220 } | 3201 } |
| 3221 | 3202 |
| 3222 test_constExpr_pushReference_staticMethod_simpleIdentifier() { | 3203 test_constExpr_pushReference_staticMethod_simpleIdentifier() { |
| 3223 UnlinkedVariable variable = serializeClassText(''' | 3204 UnlinkedVariable variable = serializeClassText(''' |
| 3224 class C { | 3205 class C { |
| 3225 static const a = m; | 3206 static const a = m; |
| 3226 static m() {} | 3207 static m() {} |
| 3227 } | 3208 } |
| 3228 ''').fields[0]; | 3209 ''').fields[0]; |
| 3229 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3210 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3230 UnlinkedExprOperation.pushReference | 3211 UnlinkedExprOperation.pushReference |
| 3231 ], referenceValidators: [ | 3212 ], referenceValidators: [ |
| 3232 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 3213 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 3233 expectedKind: ReferenceKind.method, | 3214 expectedKind: ReferenceKind.method, |
| 3234 prefixExpectations: [ | 3215 prefixExpectations: [ |
| 3235 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3216 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3236 ]) | 3217 ]) |
| 3237 ]); | 3218 ]); |
| 3238 } | 3219 } |
| 3239 | 3220 |
| 3240 test_constExpr_pushReference_topLevelFunction() { | 3221 test_constExpr_pushReference_topLevelFunction() { |
| 3241 UnlinkedVariable variable = serializeVariableText(''' | 3222 UnlinkedVariable variable = serializeVariableText(''' |
| 3242 f() {} | 3223 f() {} |
| 3243 const v = f; | 3224 const v = f; |
| 3244 '''); | 3225 '''); |
| 3245 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3226 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3246 UnlinkedExprOperation.pushReference | 3227 UnlinkedExprOperation.pushReference |
| 3247 ], referenceValidators: [ | 3228 ], referenceValidators: [ |
| 3248 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 3229 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 3249 expectedKind: ReferenceKind.topLevelFunction) | 3230 expectedKind: ReferenceKind.topLevelFunction) |
| 3250 ]); | 3231 ]); |
| 3251 } | 3232 } |
| 3252 | 3233 |
| 3253 test_constExpr_pushReference_topLevelFunction_imported() { | 3234 test_constExpr_pushReference_topLevelFunction_imported() { |
| 3254 addNamedSource( | 3235 addNamedSource( |
| 3255 '/a.dart', | 3236 '/a.dart', |
| 3256 ''' | 3237 ''' |
| 3257 f() {} | 3238 f() {} |
| 3258 '''); | 3239 '''); |
| 3259 UnlinkedVariable variable = serializeVariableText(''' | 3240 UnlinkedVariable variable = serializeVariableText(''' |
| 3260 import 'a.dart'; | 3241 import 'a.dart'; |
| 3261 const v = f; | 3242 const v = f; |
| 3262 '''); | 3243 '''); |
| 3263 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3244 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3264 UnlinkedExprOperation.pushReference | 3245 UnlinkedExprOperation.pushReference |
| 3265 ], referenceValidators: [ | 3246 ], referenceValidators: [ |
| 3266 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', | 3247 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f', |
| 3267 expectedKind: ReferenceKind.topLevelFunction) | 3248 expectedKind: ReferenceKind.topLevelFunction) |
| 3268 ]); | 3249 ]); |
| 3269 } | 3250 } |
| 3270 | 3251 |
| 3271 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() { | 3252 test_constExpr_pushReference_topLevelFunction_imported_withPrefix() { |
| 3272 addNamedSource( | 3253 addNamedSource( |
| 3273 '/a.dart', | 3254 '/a.dart', |
| 3274 ''' | 3255 ''' |
| 3275 f() {} | 3256 f() {} |
| 3276 '''); | 3257 '''); |
| 3277 UnlinkedVariable variable = serializeVariableText(''' | 3258 UnlinkedVariable variable = serializeVariableText(''' |
| 3278 import 'a.dart' as p; | 3259 import 'a.dart' as p; |
| 3279 const v = p.f; | 3260 const v = p.f; |
| 3280 '''); | 3261 '''); |
| 3281 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3262 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3282 UnlinkedExprOperation.pushReference | 3263 UnlinkedExprOperation.pushReference |
| 3283 ], referenceValidators: [ | 3264 ], referenceValidators: [ |
| 3284 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', | 3265 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'f', |
| 3285 expectedKind: ReferenceKind.topLevelFunction, | 3266 expectedKind: ReferenceKind.topLevelFunction, |
| 3286 prefixExpectations: [ | 3267 prefixExpectations: [ |
| 3287 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3268 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 3288 ]) | 3269 ]) |
| 3289 ]); | 3270 ]); |
| 3290 } | 3271 } |
| 3291 | 3272 |
| 3292 test_constExpr_pushReference_topLevelGetter() { | 3273 test_constExpr_pushReference_topLevelGetter() { |
| 3293 UnlinkedVariable variable = serializeVariableText(''' | 3274 UnlinkedVariable variable = serializeVariableText(''' |
| 3294 int get x => null; | 3275 int get x => null; |
| 3295 const v = x; | 3276 const v = x; |
| 3296 '''); | 3277 '''); |
| 3297 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3278 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3298 UnlinkedExprOperation.pushReference | 3279 UnlinkedExprOperation.pushReference |
| 3299 ], referenceValidators: [ | 3280 ], referenceValidators: [ |
| 3300 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 3281 (EntityRef r) => checkTypeRef(r, null, 'x', |
| 3301 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3282 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3302 ]); | 3283 ]); |
| 3303 } | 3284 } |
| 3304 | 3285 |
| 3305 test_constExpr_pushReference_topLevelGetter_imported() { | 3286 test_constExpr_pushReference_topLevelGetter_imported() { |
| 3306 addNamedSource('/a.dart', 'int get x => null;'); | 3287 addNamedSource('/a.dart', 'int get x => null;'); |
| 3307 UnlinkedVariable variable = serializeVariableText(''' | 3288 UnlinkedVariable variable = serializeVariableText(''' |
| 3308 import 'a.dart'; | 3289 import 'a.dart'; |
| 3309 const v = x; | 3290 const v = x; |
| 3310 '''); | 3291 '''); |
| 3311 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3292 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3312 UnlinkedExprOperation.pushReference | 3293 UnlinkedExprOperation.pushReference |
| 3313 ], referenceValidators: [ | 3294 ], referenceValidators: [ |
| 3314 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', | 3295 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'x', |
| 3315 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3296 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3316 ]); | 3297 ]); |
| 3317 } | 3298 } |
| 3318 | 3299 |
| 3319 test_constExpr_pushReference_topLevelGetter_imported_withPrefix() { | 3300 test_constExpr_pushReference_topLevelGetter_imported_withPrefix() { |
| 3320 addNamedSource('/a.dart', 'int get x => null;'); | 3301 addNamedSource('/a.dart', 'int get x => null;'); |
| 3321 UnlinkedVariable variable = serializeVariableText(''' | 3302 UnlinkedVariable variable = serializeVariableText(''' |
| 3322 import 'a.dart' as p; | 3303 import 'a.dart' as p; |
| 3323 const v = p.x; | 3304 const v = p.x; |
| 3324 '''); | 3305 '''); |
| 3325 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3306 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3326 UnlinkedExprOperation.pushReference | 3307 UnlinkedExprOperation.pushReference |
| 3327 ], referenceValidators: [ | 3308 ], referenceValidators: [ |
| 3328 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', | 3309 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'x', |
| 3329 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 3310 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 3330 expectedPrefix: 'p') | 3311 expectedPrefix: 'p') |
| 3331 ]); | 3312 ]); |
| 3332 } | 3313 } |
| 3333 | 3314 |
| 3334 test_constExpr_pushReference_topLevelVariable() { | 3315 test_constExpr_pushReference_topLevelVariable() { |
| 3335 UnlinkedVariable variable = serializeVariableText(''' | 3316 UnlinkedVariable variable = serializeVariableText(''' |
| 3336 const int a = 1; | 3317 const int a = 1; |
| 3337 const v = a; | 3318 const v = a; |
| 3338 '''); | 3319 '''); |
| 3339 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3320 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3340 UnlinkedExprOperation.pushReference | 3321 UnlinkedExprOperation.pushReference |
| 3341 ], referenceValidators: [ | 3322 ], referenceValidators: [ |
| 3342 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 3323 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 3343 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3324 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3344 ]); | 3325 ]); |
| 3345 } | 3326 } |
| 3346 | 3327 |
| 3347 test_constExpr_pushReference_topLevelVariable_imported() { | 3328 test_constExpr_pushReference_topLevelVariable_imported() { |
| 3348 addNamedSource('/a.dart', 'const int a = 1;'); | 3329 addNamedSource('/a.dart', 'const int a = 1;'); |
| 3349 UnlinkedVariable variable = serializeVariableText(''' | 3330 UnlinkedVariable variable = serializeVariableText(''' |
| 3350 import 'a.dart'; | 3331 import 'a.dart'; |
| 3351 const v = a; | 3332 const v = a; |
| 3352 '''); | 3333 '''); |
| 3353 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3334 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3354 UnlinkedExprOperation.pushReference | 3335 UnlinkedExprOperation.pushReference |
| 3355 ], referenceValidators: [ | 3336 ], referenceValidators: [ |
| 3356 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 3337 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a', |
| 3357 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3338 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3358 ]); | 3339 ]); |
| 3359 } | 3340 } |
| 3360 | 3341 |
| 3361 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() { | 3342 test_constExpr_pushReference_topLevelVariable_imported_withPrefix() { |
| 3362 addNamedSource('/a.dart', 'const int a = 1;'); | 3343 addNamedSource('/a.dart', 'const int a = 1;'); |
| 3363 UnlinkedVariable variable = serializeVariableText(''' | 3344 UnlinkedVariable variable = serializeVariableText(''' |
| 3364 import 'a.dart' as p; | 3345 import 'a.dart' as p; |
| 3365 const v = p.a; | 3346 const v = p.a; |
| 3366 '''); | 3347 '''); |
| 3367 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3348 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3368 UnlinkedExprOperation.pushReference | 3349 UnlinkedExprOperation.pushReference |
| 3369 ], referenceValidators: [ | 3350 ], referenceValidators: [ |
| 3370 (EntityRef r) { | 3351 (EntityRef r) { |
| 3371 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 3352 return checkTypeRef(r, absUri('/a.dart'), 'a', |
| 3372 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 3353 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 3373 expectedPrefix: 'p'); | 3354 expectedPrefix: 'p'); |
| 3374 } | 3355 } |
| 3375 ]); | 3356 ]); |
| 3376 } | 3357 } |
| 3377 | 3358 |
| 3378 test_constExpr_pushReference_typeParameter() { | 3359 test_constExpr_pushReference_typeParameter() { |
| 3379 String text = ''' | 3360 String text = ''' |
| 3380 class C<T> { | 3361 class C<T> { |
| 3381 static const a = T; | 3362 static const a = T; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3394 | 3375 |
| 3395 test_constExpr_pushReference_unresolved_prefix0() { | 3376 test_constExpr_pushReference_unresolved_prefix0() { |
| 3396 UnlinkedVariable variable = serializeVariableText( | 3377 UnlinkedVariable variable = serializeVariableText( |
| 3397 ''' | 3378 ''' |
| 3398 const v = foo; | 3379 const v = foo; |
| 3399 ''', | 3380 ''', |
| 3400 allowErrors: true); | 3381 allowErrors: true); |
| 3401 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3382 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3402 UnlinkedExprOperation.pushReference | 3383 UnlinkedExprOperation.pushReference |
| 3403 ], referenceValidators: [ | 3384 ], referenceValidators: [ |
| 3404 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3385 (EntityRef r) => |
| 3405 expectedKind: ReferenceKind.unresolved) | 3386 checkTypeRef(r, null, 'foo', expectedKind: ReferenceKind.unresolved) |
| 3406 ]); | 3387 ]); |
| 3407 } | 3388 } |
| 3408 | 3389 |
| 3409 test_constExpr_pushReference_unresolved_prefix1() { | 3390 test_constExpr_pushReference_unresolved_prefix1() { |
| 3410 UnlinkedVariable variable = serializeVariableText( | 3391 UnlinkedVariable variable = serializeVariableText( |
| 3411 ''' | 3392 ''' |
| 3412 class C {} | 3393 class C {} |
| 3413 const v = C.foo; | 3394 const v = C.foo; |
| 3414 ''', | 3395 ''', |
| 3415 allowErrors: true); | 3396 allowErrors: true); |
| 3416 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3397 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3417 UnlinkedExprOperation.pushReference | 3398 UnlinkedExprOperation.pushReference |
| 3418 ], referenceValidators: [ | 3399 ], referenceValidators: [ |
| 3419 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3400 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 3420 expectedKind: ReferenceKind.unresolved, | 3401 expectedKind: ReferenceKind.unresolved, |
| 3421 prefixExpectations: [ | 3402 prefixExpectations: [ |
| 3422 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 3403 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 3423 ]) | 3404 ]) |
| 3424 ]); | 3405 ]); |
| 3425 } | 3406 } |
| 3426 | 3407 |
| 3427 test_constExpr_pushReference_unresolved_prefix2() { | 3408 test_constExpr_pushReference_unresolved_prefix2() { |
| 3428 addNamedSource( | 3409 addNamedSource( |
| 3429 '/a.dart', | 3410 '/a.dart', |
| 3430 ''' | 3411 ''' |
| 3431 class C {} | 3412 class C {} |
| 3432 '''); | 3413 '''); |
| 3433 UnlinkedVariable variable = serializeVariableText( | 3414 UnlinkedVariable variable = serializeVariableText( |
| 3434 ''' | 3415 ''' |
| 3435 import 'a.dart' as p; | 3416 import 'a.dart' as p; |
| 3436 const v = p.C.foo; | 3417 const v = p.C.foo; |
| 3437 ''', | 3418 ''', |
| 3438 allowErrors: true); | 3419 allowErrors: true); |
| 3439 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ | 3420 assertUnlinkedConst(variable.initializer.bodyExpr, operators: [ |
| 3440 UnlinkedExprOperation.pushReference | 3421 UnlinkedExprOperation.pushReference |
| 3441 ], referenceValidators: [ | 3422 ], referenceValidators: [ |
| 3442 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3423 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 3443 expectedKind: ReferenceKind.unresolved, | 3424 expectedKind: ReferenceKind.unresolved, |
| 3444 prefixExpectations: [ | 3425 prefixExpectations: [ |
| 3445 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 3426 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 3446 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 3427 absoluteUri: absUri('/a.dart')), |
| 3447 new _PrefixExpectation(ReferenceKind.prefix, 'p'), | 3428 new _PrefixExpectation(ReferenceKind.prefix, 'p'), |
| 3448 ]) | 3429 ]) |
| 3449 ]); | 3430 ]); |
| 3450 } | 3431 } |
| 3451 | 3432 |
| 3452 test_constExpr_pushString_adjacent() { | 3433 test_constExpr_pushString_adjacent() { |
| 3453 UnlinkedVariable variable = | 3434 UnlinkedVariable variable = |
| 3454 serializeVariableText('const v = "aaa" "b" "ccc";'); | 3435 serializeVariableText('const v = "aaa" "b" "ccc";'); |
| 3455 assertUnlinkedConst(variable.initializer.bodyExpr, | 3436 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 3456 operators: [UnlinkedExprOperation.pushString], strings: ['aaabccc']); | 3437 operators: [UnlinkedExprOperation.pushString], strings: ['aaabccc']); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3836 serializeClassText('class C { C(this.x); final x; }').executables); | 3817 serializeClassText('class C { C(this.x); final x; }').executables); |
| 3837 UnlinkedParam parameter = executable.parameters[0]; | 3818 UnlinkedParam parameter = executable.parameters[0]; |
| 3838 expect(parameter.isInitializingFormal, isTrue); | 3819 expect(parameter.isInitializingFormal, isTrue); |
| 3839 } | 3820 } |
| 3840 | 3821 |
| 3841 test_constructor_initializing_formal_explicit_type() { | 3822 test_constructor_initializing_formal_explicit_type() { |
| 3842 UnlinkedExecutable executable = findExecutable('', | 3823 UnlinkedExecutable executable = findExecutable('', |
| 3843 executables: serializeClassText('class C { C(int this.x); final x; }') | 3824 executables: serializeClassText('class C { C(int this.x); final x; }') |
| 3844 .executables); | 3825 .executables); |
| 3845 UnlinkedParam parameter = executable.parameters[0]; | 3826 UnlinkedParam parameter = executable.parameters[0]; |
| 3846 checkTypeRef(parameter.type, 'dart:core', 'dart:core', 'int'); | 3827 checkTypeRef(parameter.type, 'dart:core', 'int'); |
| 3847 } | 3828 } |
| 3848 | 3829 |
| 3849 test_constructor_initializing_formal_function_typed() { | 3830 test_constructor_initializing_formal_function_typed() { |
| 3850 UnlinkedExecutable executable = findExecutable('', | 3831 UnlinkedExecutable executable = findExecutable('', |
| 3851 executables: serializeClassText('class C { C(this.x()); final x; }') | 3832 executables: serializeClassText('class C { C(this.x()); final x; }') |
| 3852 .executables); | 3833 .executables); |
| 3853 UnlinkedParam parameter = executable.parameters[0]; | 3834 UnlinkedParam parameter = executable.parameters[0]; |
| 3854 expect(parameter.isFunctionTyped, isTrue); | 3835 expect(parameter.isFunctionTyped, isTrue); |
| 3855 } | 3836 } |
| 3856 | 3837 |
| 3857 test_constructor_initializing_formal_function_typed_explicit_return_type() { | 3838 test_constructor_initializing_formal_function_typed_explicit_return_type() { |
| 3858 UnlinkedExecutable executable = findExecutable('', | 3839 UnlinkedExecutable executable = findExecutable('', |
| 3859 executables: | 3840 executables: |
| 3860 serializeClassText('class C { C(int this.x()); Function x; }') | 3841 serializeClassText('class C { C(int this.x()); Function x; }') |
| 3861 .executables); | 3842 .executables); |
| 3862 UnlinkedParam parameter = executable.parameters[0]; | 3843 UnlinkedParam parameter = executable.parameters[0]; |
| 3863 checkTypeRef(parameter.type, 'dart:core', 'dart:core', 'int'); | 3844 checkTypeRef(parameter.type, 'dart:core', 'int'); |
| 3864 } | 3845 } |
| 3865 | 3846 |
| 3866 test_constructor_initializing_formal_function_typed_implicit_return_type() { | 3847 test_constructor_initializing_formal_function_typed_implicit_return_type() { |
| 3867 UnlinkedExecutable executable = findExecutable('', | 3848 UnlinkedExecutable executable = findExecutable('', |
| 3868 executables: serializeClassText('class C { C(this.x()); Function x; }') | 3849 executables: serializeClassText('class C { C(this.x()); Function x; }') |
| 3869 .executables); | 3850 .executables); |
| 3870 UnlinkedParam parameter = executable.parameters[0]; | 3851 UnlinkedParam parameter = executable.parameters[0]; |
| 3871 expect(parameter.isFunctionTyped, isTrue); | 3852 expect(parameter.isFunctionTyped, isTrue); |
| 3872 expect(parameter.type, isNull); | 3853 expect(parameter.type, isNull); |
| 3873 } | 3854 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3907 } | 3888 } |
| 3908 int foo() => 0; | 3889 int foo() => 0; |
| 3909 ''').executables); | 3890 ''').executables); |
| 3910 UnlinkedParam param = executable.parameters[0]; | 3891 UnlinkedParam param = executable.parameters[0]; |
| 3911 expect(param.isFunctionTyped, isTrue); | 3892 expect(param.isFunctionTyped, isTrue); |
| 3912 expect(param.kind, UnlinkedParamKind.positional); | 3893 expect(param.kind, UnlinkedParamKind.positional); |
| 3913 expect(param.defaultValueCode, 'foo'); | 3894 expect(param.defaultValueCode, 'foo'); |
| 3914 assertUnlinkedConst(param.initializer.bodyExpr, operators: [ | 3895 assertUnlinkedConst(param.initializer.bodyExpr, operators: [ |
| 3915 UnlinkedExprOperation.pushReference | 3896 UnlinkedExprOperation.pushReference |
| 3916 ], referenceValidators: [ | 3897 ], referenceValidators: [ |
| 3917 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 3898 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 3918 expectedKind: ReferenceKind.topLevelFunction) | 3899 expectedKind: ReferenceKind.topLevelFunction) |
| 3919 ]); | 3900 ]); |
| 3920 } | 3901 } |
| 3921 | 3902 |
| 3922 test_constructor_initializing_formal_implicit_type() { | 3903 test_constructor_initializing_formal_implicit_type() { |
| 3923 // Note: the implicit type of an initializing formal is the type of the | 3904 // Note: the implicit type of an initializing formal is the type of the |
| 3924 // field. | 3905 // field. |
| 3925 UnlinkedExecutable executable = findExecutable('', | 3906 UnlinkedExecutable executable = findExecutable('', |
| 3926 executables: | 3907 executables: |
| 3927 serializeClassText('class C { C(this.x); int x; }').executables); | 3908 serializeClassText('class C { C(this.x); int x; }').executables); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4075 } | 4056 } |
| 4076 class D extends C { | 4057 class D extends C { |
| 4077 D.named() : super._(); | 4058 D.named() : super._(); |
| 4078 } | 4059 } |
| 4079 '''; | 4060 '''; |
| 4080 UnlinkedExecutable executable = | 4061 UnlinkedExecutable executable = |
| 4081 serializeClassText(text, className: 'C').executables[0]; | 4062 serializeClassText(text, className: 'C').executables[0]; |
| 4082 expect(executable.isRedirectedConstructor, isTrue); | 4063 expect(executable.isRedirectedConstructor, isTrue); |
| 4083 expect(executable.isFactory, isTrue); | 4064 expect(executable.isFactory, isTrue); |
| 4084 expect(executable.redirectedConstructorName, isEmpty); | 4065 expect(executable.redirectedConstructorName, isEmpty); |
| 4085 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4066 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4086 expectedKind: ReferenceKind.constructor, | 4067 expectedKind: ReferenceKind.constructor, |
| 4087 prefixExpectations: [ | 4068 prefixExpectations: [ |
| 4088 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D') | 4069 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D') |
| 4089 ]); | 4070 ]); |
| 4090 } | 4071 } |
| 4091 | 4072 |
| 4092 test_constructor_redirected_factory_named_generic() { | 4073 test_constructor_redirected_factory_named_generic() { |
| 4093 String text = ''' | 4074 String text = ''' |
| 4094 class C<T, U> { | 4075 class C<T, U> { |
| 4095 factory C() = D<U, T>.named; | 4076 factory C() = D<U, T>.named; |
| 4096 C._(); | 4077 C._(); |
| 4097 } | 4078 } |
| 4098 class D<T, U> extends C<U, T> { | 4079 class D<T, U> extends C<U, T> { |
| 4099 D.named() : super._(); | 4080 D.named() : super._(); |
| 4100 } | 4081 } |
| 4101 '''; | 4082 '''; |
| 4102 UnlinkedExecutable executable = | 4083 UnlinkedExecutable executable = |
| 4103 serializeClassText(text, className: 'C').executables[0]; | 4084 serializeClassText(text, className: 'C').executables[0]; |
| 4104 expect(executable.isRedirectedConstructor, isTrue); | 4085 expect(executable.isRedirectedConstructor, isTrue); |
| 4105 expect(executable.isFactory, isTrue); | 4086 expect(executable.isFactory, isTrue); |
| 4106 expect(executable.redirectedConstructorName, isEmpty); | 4087 expect(executable.redirectedConstructorName, isEmpty); |
| 4107 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4088 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4108 expectedKind: ReferenceKind.constructor, | 4089 expectedKind: ReferenceKind.constructor, |
| 4109 prefixExpectations: [ | 4090 prefixExpectations: [ |
| 4110 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 4091 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', |
| 4111 numTypeParameters: 2) | 4092 numTypeParameters: 2) |
| 4112 ], | 4093 ], |
| 4113 numTypeArguments: 2); | 4094 numTypeArguments: 2); |
| 4114 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4095 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4115 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4096 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4116 } | 4097 } |
| 4117 | 4098 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4129 class C { | 4110 class C { |
| 4130 factory C() = D.named; | 4111 factory C() = D.named; |
| 4131 C._(); | 4112 C._(); |
| 4132 } | 4113 } |
| 4133 '''; | 4114 '''; |
| 4134 UnlinkedExecutable executable = | 4115 UnlinkedExecutable executable = |
| 4135 serializeClassText(text, className: 'C').executables[0]; | 4116 serializeClassText(text, className: 'C').executables[0]; |
| 4136 expect(executable.isRedirectedConstructor, isTrue); | 4117 expect(executable.isRedirectedConstructor, isTrue); |
| 4137 expect(executable.isFactory, isTrue); | 4118 expect(executable.isFactory, isTrue); |
| 4138 expect(executable.redirectedConstructorName, isEmpty); | 4119 expect(executable.redirectedConstructorName, isEmpty); |
| 4139 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4120 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4140 expectedKind: ReferenceKind.constructor, | 4121 expectedKind: ReferenceKind.constructor, |
| 4141 prefixExpectations: [ | 4122 prefixExpectations: [ |
| 4142 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 4123 new _PrefixExpectation( |
| 4143 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart') | 4124 ReferenceKind.classOrEnum, |
| 4125 'D', |
| 4126 absoluteUri: absUri('/foo.dart'), |
| 4127 ) |
| 4144 ]); | 4128 ]); |
| 4145 } | 4129 } |
| 4146 | 4130 |
| 4147 test_constructor_redirected_factory_named_imported_generic() { | 4131 test_constructor_redirected_factory_named_imported_generic() { |
| 4148 addNamedSource( | 4132 addNamedSource( |
| 4149 '/foo.dart', | 4133 '/foo.dart', |
| 4150 ''' | 4134 ''' |
| 4151 import 'test.dart'; | 4135 import 'test.dart'; |
| 4152 class D<T, U> extends C<U, T> { | 4136 class D<T, U> extends C<U, T> { |
| 4153 D.named() : super._(); | 4137 D.named() : super._(); |
| 4154 } | 4138 } |
| 4155 '''); | 4139 '''); |
| 4156 String text = ''' | 4140 String text = ''' |
| 4157 import 'foo.dart'; | 4141 import 'foo.dart'; |
| 4158 class C<T, U> { | 4142 class C<T, U> { |
| 4159 factory C() = D<U, T>.named; | 4143 factory C() = D<U, T>.named; |
| 4160 C._(); | 4144 C._(); |
| 4161 } | 4145 } |
| 4162 '''; | 4146 '''; |
| 4163 UnlinkedExecutable executable = | 4147 UnlinkedExecutable executable = |
| 4164 serializeClassText(text, className: 'C').executables[0]; | 4148 serializeClassText(text, className: 'C').executables[0]; |
| 4165 expect(executable.isRedirectedConstructor, isTrue); | 4149 expect(executable.isRedirectedConstructor, isTrue); |
| 4166 expect(executable.isFactory, isTrue); | 4150 expect(executable.isFactory, isTrue); |
| 4167 expect(executable.redirectedConstructorName, isEmpty); | 4151 expect(executable.redirectedConstructorName, isEmpty); |
| 4168 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4152 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4169 expectedKind: ReferenceKind.constructor, | 4153 expectedKind: ReferenceKind.constructor, |
| 4170 prefixExpectations: [ | 4154 prefixExpectations: [ |
| 4171 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 4155 new _PrefixExpectation( |
| 4172 numTypeParameters: 2, | 4156 ReferenceKind.classOrEnum, |
| 4173 absoluteUri: absUri('/foo.dart'), | 4157 'D', |
| 4174 relativeUri: 'foo.dart') | 4158 numTypeParameters: 2, |
| 4159 absoluteUri: absUri('/foo.dart'), |
| 4160 ) |
| 4175 ], | 4161 ], |
| 4176 numTypeArguments: 2); | 4162 numTypeArguments: 2); |
| 4177 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4163 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4178 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4164 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4179 } | 4165 } |
| 4180 | 4166 |
| 4181 test_constructor_redirected_factory_named_prefixed() { | 4167 test_constructor_redirected_factory_named_prefixed() { |
| 4182 addNamedSource( | 4168 addNamedSource( |
| 4183 '/foo.dart', | 4169 '/foo.dart', |
| 4184 ''' | 4170 ''' |
| 4185 import 'test.dart'; | 4171 import 'test.dart'; |
| 4186 class D extends C { | 4172 class D extends C { |
| 4187 D.named() : super._(); | 4173 D.named() : super._(); |
| 4188 } | 4174 } |
| 4189 '''); | 4175 '''); |
| 4190 String text = ''' | 4176 String text = ''' |
| 4191 import 'foo.dart' as foo; | 4177 import 'foo.dart' as foo; |
| 4192 class C { | 4178 class C { |
| 4193 factory C() = foo.D.named; | 4179 factory C() = foo.D.named; |
| 4194 C._(); | 4180 C._(); |
| 4195 } | 4181 } |
| 4196 '''; | 4182 '''; |
| 4197 UnlinkedExecutable executable = | 4183 UnlinkedExecutable executable = |
| 4198 serializeClassText(text, className: 'C').executables[0]; | 4184 serializeClassText(text, className: 'C').executables[0]; |
| 4199 expect(executable.isRedirectedConstructor, isTrue); | 4185 expect(executable.isRedirectedConstructor, isTrue); |
| 4200 expect(executable.isFactory, isTrue); | 4186 expect(executable.isFactory, isTrue); |
| 4201 expect(executable.redirectedConstructorName, isEmpty); | 4187 expect(executable.redirectedConstructorName, isEmpty); |
| 4202 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4188 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4203 expectedKind: ReferenceKind.constructor, | 4189 expectedKind: ReferenceKind.constructor, |
| 4204 prefixExpectations: [ | 4190 prefixExpectations: [ |
| 4205 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 4191 new _PrefixExpectation( |
| 4206 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), | 4192 ReferenceKind.classOrEnum, |
| 4193 'D', |
| 4194 absoluteUri: absUri('/foo.dart'), |
| 4195 ), |
| 4207 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 4196 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
| 4208 ]); | 4197 ]); |
| 4209 } | 4198 } |
| 4210 | 4199 |
| 4211 test_constructor_redirected_factory_named_prefixed_generic() { | 4200 test_constructor_redirected_factory_named_prefixed_generic() { |
| 4212 addNamedSource( | 4201 addNamedSource( |
| 4213 '/foo.dart', | 4202 '/foo.dart', |
| 4214 ''' | 4203 ''' |
| 4215 import 'test.dart'; | 4204 import 'test.dart'; |
| 4216 class D<T, U> extends C<U, T> { | 4205 class D<T, U> extends C<U, T> { |
| 4217 D.named() : super._(); | 4206 D.named() : super._(); |
| 4218 } | 4207 } |
| 4219 '''); | 4208 '''); |
| 4220 String text = ''' | 4209 String text = ''' |
| 4221 import 'foo.dart' as foo; | 4210 import 'foo.dart' as foo; |
| 4222 class C<T, U> { | 4211 class C<T, U> { |
| 4223 factory C() = foo.D<U, T>.named; | 4212 factory C() = foo.D<U, T>.named; |
| 4224 C._(); | 4213 C._(); |
| 4225 } | 4214 } |
| 4226 '''; | 4215 '''; |
| 4227 UnlinkedExecutable executable = | 4216 UnlinkedExecutable executable = |
| 4228 serializeClassText(text, className: 'C').executables[0]; | 4217 serializeClassText(text, className: 'C').executables[0]; |
| 4229 expect(executable.isRedirectedConstructor, isTrue); | 4218 expect(executable.isRedirectedConstructor, isTrue); |
| 4230 expect(executable.isFactory, isTrue); | 4219 expect(executable.isFactory, isTrue); |
| 4231 expect(executable.redirectedConstructorName, isEmpty); | 4220 expect(executable.redirectedConstructorName, isEmpty); |
| 4232 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 4221 checkTypeRef(executable.redirectedConstructor, null, 'named', |
| 4233 expectedKind: ReferenceKind.constructor, | 4222 expectedKind: ReferenceKind.constructor, |
| 4234 prefixExpectations: [ | 4223 prefixExpectations: [ |
| 4235 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', | 4224 new _PrefixExpectation( |
| 4236 numTypeParameters: 2, | 4225 ReferenceKind.classOrEnum, |
| 4237 absoluteUri: absUri('/foo.dart'), | 4226 'D', |
| 4238 relativeUri: 'foo.dart'), | 4227 numTypeParameters: 2, |
| 4228 absoluteUri: absUri('/foo.dart'), |
| 4229 ), |
| 4239 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 4230 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
| 4240 ], | 4231 ], |
| 4241 numTypeArguments: 2); | 4232 numTypeArguments: 2); |
| 4242 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4233 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4243 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4234 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4244 } | 4235 } |
| 4245 | 4236 |
| 4246 test_constructor_redirected_factory_unnamed() { | 4237 test_constructor_redirected_factory_unnamed() { |
| 4247 String text = ''' | 4238 String text = ''' |
| 4248 class C { | 4239 class C { |
| 4249 factory C() = D; | 4240 factory C() = D; |
| 4250 C._(); | 4241 C._(); |
| 4251 } | 4242 } |
| 4252 class D extends C { | 4243 class D extends C { |
| 4253 D() : super._(); | 4244 D() : super._(); |
| 4254 } | 4245 } |
| 4255 '''; | 4246 '''; |
| 4256 UnlinkedExecutable executable = | 4247 UnlinkedExecutable executable = |
| 4257 serializeClassText(text, className: 'C').executables[0]; | 4248 serializeClassText(text, className: 'C').executables[0]; |
| 4258 expect(executable.isRedirectedConstructor, isTrue); | 4249 expect(executable.isRedirectedConstructor, isTrue); |
| 4259 expect(executable.isFactory, isTrue); | 4250 expect(executable.isFactory, isTrue); |
| 4260 expect(executable.redirectedConstructorName, isEmpty); | 4251 expect(executable.redirectedConstructorName, isEmpty); |
| 4261 checkTypeRef(executable.redirectedConstructor, null, null, 'D'); | 4252 checkTypeRef(executable.redirectedConstructor, null, 'D'); |
| 4262 } | 4253 } |
| 4263 | 4254 |
| 4264 test_constructor_redirected_factory_unnamed_generic() { | 4255 test_constructor_redirected_factory_unnamed_generic() { |
| 4265 String text = ''' | 4256 String text = ''' |
| 4266 class C<T, U> { | 4257 class C<T, U> { |
| 4267 factory C() = D<U, T>; | 4258 factory C() = D<U, T>; |
| 4268 C._(); | 4259 C._(); |
| 4269 } | 4260 } |
| 4270 class D<T, U> extends C<U, T> { | 4261 class D<T, U> extends C<U, T> { |
| 4271 D() : super._(); | 4262 D() : super._(); |
| 4272 } | 4263 } |
| 4273 '''; | 4264 '''; |
| 4274 UnlinkedExecutable executable = | 4265 UnlinkedExecutable executable = |
| 4275 serializeClassText(text, className: 'C').executables[0]; | 4266 serializeClassText(text, className: 'C').executables[0]; |
| 4276 expect(executable.isRedirectedConstructor, isTrue); | 4267 expect(executable.isRedirectedConstructor, isTrue); |
| 4277 expect(executable.isFactory, isTrue); | 4268 expect(executable.isFactory, isTrue); |
| 4278 expect(executable.redirectedConstructorName, isEmpty); | 4269 expect(executable.redirectedConstructorName, isEmpty); |
| 4279 checkTypeRef(executable.redirectedConstructor, null, null, 'D', | 4270 checkTypeRef(executable.redirectedConstructor, null, 'D', |
| 4280 numTypeParameters: 2, numTypeArguments: 2); | 4271 numTypeParameters: 2, numTypeArguments: 2); |
| 4281 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4272 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4282 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4273 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4283 } | 4274 } |
| 4284 | 4275 |
| 4285 test_constructor_redirected_factory_unnamed_imported() { | 4276 test_constructor_redirected_factory_unnamed_imported() { |
| 4286 addNamedSource( | 4277 addNamedSource( |
| 4287 '/foo.dart', | 4278 '/foo.dart', |
| 4288 ''' | 4279 ''' |
| 4289 import 'test.dart'; | 4280 import 'test.dart'; |
| 4290 class D extends C { | 4281 class D extends C { |
| 4291 D() : super._(); | 4282 D() : super._(); |
| 4292 } | 4283 } |
| 4293 '''); | 4284 '''); |
| 4294 String text = ''' | 4285 String text = ''' |
| 4295 import 'foo.dart'; | 4286 import 'foo.dart'; |
| 4296 class C { | 4287 class C { |
| 4297 factory C() = D; | 4288 factory C() = D; |
| 4298 C._(); | 4289 C._(); |
| 4299 } | 4290 } |
| 4300 '''; | 4291 '''; |
| 4301 UnlinkedExecutable executable = | 4292 UnlinkedExecutable executable = |
| 4302 serializeClassText(text, className: 'C').executables[0]; | 4293 serializeClassText(text, className: 'C').executables[0]; |
| 4303 expect(executable.isRedirectedConstructor, isTrue); | 4294 expect(executable.isRedirectedConstructor, isTrue); |
| 4304 expect(executable.isFactory, isTrue); | 4295 expect(executable.isFactory, isTrue); |
| 4305 expect(executable.redirectedConstructorName, isEmpty); | 4296 expect(executable.redirectedConstructorName, isEmpty); |
| 4306 checkTypeRef( | 4297 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D'); |
| 4307 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D'); | |
| 4308 } | 4298 } |
| 4309 | 4299 |
| 4310 test_constructor_redirected_factory_unnamed_imported_generic() { | 4300 test_constructor_redirected_factory_unnamed_imported_generic() { |
| 4311 addNamedSource( | 4301 addNamedSource( |
| 4312 '/foo.dart', | 4302 '/foo.dart', |
| 4313 ''' | 4303 ''' |
| 4314 import 'test.dart'; | 4304 import 'test.dart'; |
| 4315 class D<T, U> extends C<U, T> { | 4305 class D<T, U> extends C<U, T> { |
| 4316 D() : super._(); | 4306 D() : super._(); |
| 4317 } | 4307 } |
| 4318 '''); | 4308 '''); |
| 4319 String text = ''' | 4309 String text = ''' |
| 4320 import 'foo.dart'; | 4310 import 'foo.dart'; |
| 4321 class C<T, U> { | 4311 class C<T, U> { |
| 4322 factory C() = D<U, T>; | 4312 factory C() = D<U, T>; |
| 4323 C._(); | 4313 C._(); |
| 4324 } | 4314 } |
| 4325 '''; | 4315 '''; |
| 4326 UnlinkedExecutable executable = | 4316 UnlinkedExecutable executable = |
| 4327 serializeClassText(text, className: 'C').executables[0]; | 4317 serializeClassText(text, className: 'C').executables[0]; |
| 4328 expect(executable.isRedirectedConstructor, isTrue); | 4318 expect(executable.isRedirectedConstructor, isTrue); |
| 4329 expect(executable.isFactory, isTrue); | 4319 expect(executable.isFactory, isTrue); |
| 4330 expect(executable.redirectedConstructorName, isEmpty); | 4320 expect(executable.redirectedConstructorName, isEmpty); |
| 4331 checkTypeRef( | 4321 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D', |
| 4332 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', | |
| 4333 numTypeParameters: 2, numTypeArguments: 2); | 4322 numTypeParameters: 2, numTypeArguments: 2); |
| 4334 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4323 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4335 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4324 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4336 } | 4325 } |
| 4337 | 4326 |
| 4338 test_constructor_redirected_factory_unnamed_prefixed() { | 4327 test_constructor_redirected_factory_unnamed_prefixed() { |
| 4339 addNamedSource( | 4328 addNamedSource( |
| 4340 '/foo.dart', | 4329 '/foo.dart', |
| 4341 ''' | 4330 ''' |
| 4342 import 'test.dart'; | 4331 import 'test.dart'; |
| 4343 class D extends C { | 4332 class D extends C { |
| 4344 D() : super._(); | 4333 D() : super._(); |
| 4345 } | 4334 } |
| 4346 '''); | 4335 '''); |
| 4347 String text = ''' | 4336 String text = ''' |
| 4348 import 'foo.dart' as foo; | 4337 import 'foo.dart' as foo; |
| 4349 class C { | 4338 class C { |
| 4350 factory C() = foo.D; | 4339 factory C() = foo.D; |
| 4351 C._(); | 4340 C._(); |
| 4352 } | 4341 } |
| 4353 '''; | 4342 '''; |
| 4354 UnlinkedExecutable executable = | 4343 UnlinkedExecutable executable = |
| 4355 serializeClassText(text, className: 'C').executables[0]; | 4344 serializeClassText(text, className: 'C').executables[0]; |
| 4356 expect(executable.isRedirectedConstructor, isTrue); | 4345 expect(executable.isRedirectedConstructor, isTrue); |
| 4357 expect(executable.isFactory, isTrue); | 4346 expect(executable.isFactory, isTrue); |
| 4358 expect(executable.redirectedConstructorName, isEmpty); | 4347 expect(executable.redirectedConstructorName, isEmpty); |
| 4359 checkTypeRef( | 4348 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D', |
| 4360 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', | |
| 4361 expectedPrefix: 'foo'); | 4349 expectedPrefix: 'foo'); |
| 4362 } | 4350 } |
| 4363 | 4351 |
| 4364 test_constructor_redirected_factory_unnamed_prefixed_generic() { | 4352 test_constructor_redirected_factory_unnamed_prefixed_generic() { |
| 4365 addNamedSource( | 4353 addNamedSource( |
| 4366 '/foo.dart', | 4354 '/foo.dart', |
| 4367 ''' | 4355 ''' |
| 4368 import 'test.dart'; | 4356 import 'test.dart'; |
| 4369 class D<T, U> extends C<U, T> { | 4357 class D<T, U> extends C<U, T> { |
| 4370 D() : super._(); | 4358 D() : super._(); |
| 4371 } | 4359 } |
| 4372 '''); | 4360 '''); |
| 4373 String text = ''' | 4361 String text = ''' |
| 4374 import 'foo.dart' as foo; | 4362 import 'foo.dart' as foo; |
| 4375 class C<T, U> { | 4363 class C<T, U> { |
| 4376 factory C() = foo.D<U, T>; | 4364 factory C() = foo.D<U, T>; |
| 4377 C._(); | 4365 C._(); |
| 4378 } | 4366 } |
| 4379 '''; | 4367 '''; |
| 4380 UnlinkedExecutable executable = | 4368 UnlinkedExecutable executable = |
| 4381 serializeClassText(text, className: 'C').executables[0]; | 4369 serializeClassText(text, className: 'C').executables[0]; |
| 4382 expect(executable.isRedirectedConstructor, isTrue); | 4370 expect(executable.isRedirectedConstructor, isTrue); |
| 4383 expect(executable.isFactory, isTrue); | 4371 expect(executable.isFactory, isTrue); |
| 4384 expect(executable.redirectedConstructorName, isEmpty); | 4372 expect(executable.redirectedConstructorName, isEmpty); |
| 4385 checkTypeRef( | 4373 checkTypeRef(executable.redirectedConstructor, absUri('/foo.dart'), 'D', |
| 4386 executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D', | |
| 4387 numTypeParameters: 2, expectedPrefix: 'foo', numTypeArguments: 2); | 4374 numTypeParameters: 2, expectedPrefix: 'foo', numTypeArguments: 2); |
| 4388 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); | 4375 checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1); |
| 4389 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); | 4376 checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2); |
| 4390 } | 4377 } |
| 4391 | 4378 |
| 4392 test_constructor_redirected_thisInvocation_named() { | 4379 test_constructor_redirected_thisInvocation_named() { |
| 4393 String text = ''' | 4380 String text = ''' |
| 4394 class C { | 4381 class C { |
| 4395 C() : this.named(); | 4382 C() : this.named(); |
| 4396 C.named(); | 4383 C.named(); |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4977 } | 4964 } |
| 4978 | 4965 |
| 4979 test_dependencies_export_to_export_unused() { | 4966 test_dependencies_export_to_export_unused() { |
| 4980 addNamedSource('/a.dart', 'export "b.dart";'); | 4967 addNamedSource('/a.dart', 'export "b.dart";'); |
| 4981 addNamedSource('/b.dart', ''); | 4968 addNamedSource('/b.dart', ''); |
| 4982 serializeLibraryText('export "a.dart";'); | 4969 serializeLibraryText('export "a.dart";'); |
| 4983 // The main test library depends on b.dart, even though it doesn't | 4970 // The main test library depends on b.dart, even though it doesn't |
| 4984 // re-export any names defined in b.dart, because a change to b.dart might | 4971 // re-export any names defined in b.dart, because a change to b.dart might |
| 4985 // cause it to start exporting a name that the main test library *does* | 4972 // cause it to start exporting a name that the main test library *does* |
| 4986 // use. | 4973 // use. |
| 4987 checkHasDependency('b.dart'); | 4974 checkHasDependency(absUri('/b.dart')); |
| 4988 } | 4975 } |
| 4989 | 4976 |
| 4990 test_dependencies_export_unused() { | 4977 test_dependencies_export_unused() { |
| 4991 addNamedSource('/a.dart', ''); | 4978 addNamedSource('/a.dart', ''); |
| 4992 serializeLibraryText('export "a.dart";'); | 4979 serializeLibraryText('export "a.dart";'); |
| 4993 // The main test library depends on a.dart, even though it doesn't | 4980 // The main test library depends on a.dart, even though it doesn't |
| 4994 // re-export any names defined in a.dart, because a change to a.dart might | 4981 // re-export any names defined in a.dart, because a change to a.dart might |
| 4995 // cause it to start exporting a name that the main test library *will* | 4982 // cause it to start exporting a name that the main test library *will* |
| 4996 // re-export. | 4983 // re-export. |
| 4997 checkHasDependency('a.dart'); | 4984 checkHasDependency(absUri('/a.dart')); |
| 4998 } | 4985 } |
| 4999 | 4986 |
| 5000 test_dependencies_import_to_export() { | 4987 test_dependencies_import_to_export() { |
| 5001 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); | 4988 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); |
| 5002 addNamedSource('/b.dart', 'library b;'); | 4989 addNamedSource('/b.dart', 'library b;'); |
| 5003 serializeLibraryText('import "a.dart"; A a;'); | 4990 serializeLibraryText('import "a.dart"; A a;'); |
| 5004 checkHasDependency('a.dart'); | 4991 checkHasDependency(absUri('/a.dart')); |
| 5005 // The main test library depends on b.dart, because names defined in | 4992 // The main test library depends on b.dart, because names defined in |
| 5006 // b.dart are exported by a.dart. | 4993 // b.dart are exported by a.dart. |
| 5007 checkHasDependency('b.dart'); | 4994 checkHasDependency(absUri('/b.dart')); |
| 5008 } | 4995 } |
| 5009 | 4996 |
| 5010 test_dependencies_import_to_export_in_subdirs_absolute_export() { | 4997 test_dependencies_import_to_export_in_subdirs_absolute_export() { |
| 5011 addNamedSource('/a/a.dart', | 4998 addNamedSource('/a/a.dart', |
| 5012 'library a; export "${absUri('/a/b/b.dart')}"; class A {}'); | 4999 'library a; export "${absUri('/a/b/b.dart')}"; class A {}'); |
| 5013 addNamedSource('/a/b/b.dart', 'library b;'); | 5000 addNamedSource('/a/b/b.dart', 'library b;'); |
| 5014 serializeLibraryText('import "a/a.dart"; A a;'); | 5001 serializeLibraryText('import "a/a.dart"; A a;'); |
| 5015 checkHasDependency('a/a.dart'); | 5002 checkHasDependency(absUri('/a/a.dart')); |
| 5016 // The main test library depends on b.dart, because names defined in | 5003 // The main test library depends on b.dart, because names defined in |
| 5017 // b.dart are exported by a.dart. | 5004 // b.dart are exported by a.dart. |
| 5018 checkHasDependency(absUri('/a/b/b.dart')); | 5005 checkHasDependency(absUri('/a/b/b.dart')); |
| 5019 } | 5006 } |
| 5020 | 5007 |
| 5021 test_dependencies_import_to_export_in_subdirs_absolute_import() { | 5008 test_dependencies_import_to_export_in_subdirs_absolute_import() { |
| 5022 addNamedSource('/a/a.dart', 'library a; export "b/b.dart"; class A {}'); | 5009 addNamedSource('/a/a.dart', 'library a; export "b/b.dart"; class A {}'); |
| 5023 addNamedSource('/a/b/b.dart', 'library b;'); | 5010 addNamedSource('/a/b/b.dart', 'library b;'); |
| 5024 serializeLibraryText('import "${absUri('/a/a.dart')}"; A a;'); | 5011 serializeLibraryText('import "${absUri('/a/a.dart')}"; A a;'); |
| 5025 checkHasDependency(absUri('/a/a.dart')); | 5012 checkHasDependency(absUri('/a/a.dart')); |
| 5026 // The main test library depends on b.dart, because names defined in | 5013 // The main test library depends on b.dart, because names defined in |
| 5027 // b.dart are exported by a.dart. | 5014 // b.dart are exported by a.dart. |
| 5028 checkHasDependency(absUri('/a/b/b.dart')); | 5015 checkHasDependency(absUri('/a/b/b.dart')); |
| 5029 } | 5016 } |
| 5030 | 5017 |
| 5031 test_dependencies_import_to_export_in_subdirs_relative() { | 5018 test_dependencies_import_to_export_in_subdirs_relative() { |
| 5032 addNamedSource('/a/a.dart', 'library a; export "b/b.dart"; class A {}'); | 5019 addNamedSource('/a/a.dart', 'library a; export "b/b.dart"; class A {}'); |
| 5033 addNamedSource('/a/b/b.dart', 'library b;'); | 5020 addNamedSource('/a/b/b.dart', 'library b;'); |
| 5034 serializeLibraryText('import "a/a.dart"; A a;'); | 5021 serializeLibraryText('import "a/a.dart"; A a;'); |
| 5035 checkHasDependency('a/a.dart'); | 5022 checkHasDependency(absUri('/a/a.dart')); |
| 5036 // The main test library depends on b.dart, because names defined in | 5023 // The main test library depends on b.dart, because names defined in |
| 5037 // b.dart are exported by a.dart. | 5024 // b.dart are exported by a.dart. |
| 5038 checkHasDependency('a/b/b.dart'); | 5025 checkHasDependency(absUri('/a/b/b.dart')); |
| 5039 } | 5026 } |
| 5040 | 5027 |
| 5041 test_dependencies_import_to_export_loop() { | 5028 test_dependencies_import_to_export_loop() { |
| 5042 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); | 5029 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); |
| 5043 addNamedSource('/b.dart', 'library b; export "a.dart";'); | 5030 addNamedSource('/b.dart', 'library b; export "a.dart";'); |
| 5044 serializeLibraryText('import "a.dart"; A a;'); | 5031 serializeLibraryText('import "a.dart"; A a;'); |
| 5045 checkHasDependency('a.dart'); | 5032 checkHasDependency(absUri('/a.dart')); |
| 5046 // Serialization should have been able to walk the transitive export | 5033 // Serialization should have been able to walk the transitive export |
| 5047 // dependencies to b.dart without going into an infinite loop. | 5034 // dependencies to b.dart without going into an infinite loop. |
| 5048 checkHasDependency('b.dart'); | 5035 checkHasDependency(absUri('/b.dart')); |
| 5049 } | 5036 } |
| 5050 | 5037 |
| 5051 test_dependencies_import_to_export_transitive_closure() { | 5038 test_dependencies_import_to_export_transitive_closure() { |
| 5052 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); | 5039 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); |
| 5053 addNamedSource('/b.dart', 'library b; export "c.dart";'); | 5040 addNamedSource('/b.dart', 'library b; export "c.dart";'); |
| 5054 addNamedSource('/c.dart', 'library c;'); | 5041 addNamedSource('/c.dart', 'library c;'); |
| 5055 serializeLibraryText('import "a.dart"; A a;'); | 5042 serializeLibraryText('import "a.dart"; A a;'); |
| 5056 checkHasDependency('a.dart'); | 5043 checkHasDependency(absUri('/a.dart')); |
| 5057 // The main test library depends on c.dart, because names defined in | 5044 // The main test library depends on c.dart, because names defined in |
| 5058 // c.dart are exported by b.dart and then re-exported by a.dart. | 5045 // c.dart are exported by b.dart and then re-exported by a.dart. |
| 5059 checkHasDependency('c.dart'); | 5046 checkHasDependency(absUri('/c.dart')); |
| 5060 } | 5047 } |
| 5061 | 5048 |
| 5062 test_dependencies_import_to_export_unused() { | 5049 test_dependencies_import_to_export_unused() { |
| 5063 addNamedSource('/a.dart', 'export "b.dart";'); | 5050 addNamedSource('/a.dart', 'export "b.dart";'); |
| 5064 addNamedSource('/b.dart', ''); | 5051 addNamedSource('/b.dart', ''); |
| 5065 serializeLibraryText('import "a.dart";', allowErrors: true); | 5052 serializeLibraryText('import "a.dart";', allowErrors: true); |
| 5066 // The main test library depends on b.dart, even though it doesn't use any | 5053 // The main test library depends on b.dart, even though it doesn't use any |
| 5067 // names defined in b.dart, because a change to b.dart might cause it to | 5054 // names defined in b.dart, because a change to b.dart might cause it to |
| 5068 // start exporting a name that the main test library *does* use. | 5055 // start exporting a name that the main test library *does* use. |
| 5069 checkHasDependency('b.dart'); | 5056 checkHasDependency(absUri('/b.dart')); |
| 5070 } | 5057 } |
| 5071 | 5058 |
| 5072 test_dependencies_import_transitive_closure() { | 5059 test_dependencies_import_transitive_closure() { |
| 5073 addNamedSource( | 5060 addNamedSource( |
| 5074 '/a.dart', 'library a; import "b.dart"; class A extends B {}'); | 5061 '/a.dart', 'library a; import "b.dart"; class A extends B {}'); |
| 5075 addNamedSource('/b.dart', 'library b; class B {}'); | 5062 addNamedSource('/b.dart', 'library b; class B {}'); |
| 5076 serializeLibraryText('import "a.dart"; A a;'); | 5063 serializeLibraryText('import "a.dart"; A a;'); |
| 5077 checkHasDependency('a.dart'); | 5064 checkHasDependency(absUri('/a.dart')); |
| 5078 // The main test library doesn't depend on b.dart, because no change to | 5065 // The main test library doesn't depend on b.dart, because no change to |
| 5079 // b.dart can possibly affect the serialized element model for it. | 5066 // b.dart can possibly affect the serialized element model for it. |
| 5080 checkLacksDependency('b.dart'); | 5067 checkLacksDependency(absUri('/b.dart')); |
| 5081 } | 5068 } |
| 5082 | 5069 |
| 5083 test_dependencies_import_unused() { | 5070 test_dependencies_import_unused() { |
| 5084 addNamedSource('/a.dart', ''); | 5071 addNamedSource('/a.dart', ''); |
| 5085 serializeLibraryText('import "a.dart";', allowErrors: true); | 5072 serializeLibraryText('import "a.dart";', allowErrors: true); |
| 5086 // The main test library depends on a.dart, even though it doesn't use any | 5073 // The main test library depends on a.dart, even though it doesn't use any |
| 5087 // names defined in a.dart, because a change to a.dart might cause it to | 5074 // names defined in a.dart, because a change to a.dart might cause it to |
| 5088 // start exporting a name that the main test library *does* use. | 5075 // start exporting a name that the main test library *does* use. |
| 5089 checkHasDependency('a.dart'); | 5076 checkHasDependency(absUri('/a.dart')); |
| 5090 } | 5077 } |
| 5091 | 5078 |
| 5092 test_dependencies_parts() { | 5079 test_dependencies_parts() { |
| 5093 addNamedSource( | 5080 addNamedSource( |
| 5094 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); | 5081 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); |
| 5095 addNamedSource('/b.dart', 'part of a;'); | 5082 addNamedSource('/b.dart', 'part of a;'); |
| 5096 addNamedSource('/c.dart', 'part of a;'); | 5083 addNamedSource('/c.dart', 'part of a;'); |
| 5097 serializeLibraryText('import "a.dart"; A a;'); | 5084 serializeLibraryText('import "a.dart"; A a;'); |
| 5098 int dep = checkHasDependency('a.dart'); | 5085 int dep = checkHasDependency(absUri('/a.dart')); |
| 5099 checkDependencyParts(linked.dependencies[dep], ['b.dart', 'c.dart']); | 5086 checkDependencyParts( |
| 5087 linked.dependencies[dep], [absUri('/b.dart'), absUri('/c.dart')]); |
| 5100 } | 5088 } |
| 5101 | 5089 |
| 5102 test_dependencies_parts_relative_to_importing_library() { | 5090 test_dependencies_parts_relative_to_importing_library() { |
| 5103 addNamedSource('/a/b.dart', 'export "c/d.dart";'); | 5091 addNamedSource('/a/b.dart', 'export "c/d.dart";'); |
| 5104 addNamedSource('/a/c/d.dart', | 5092 addNamedSource('/a/c/d.dart', |
| 5105 'library d; part "e/f.dart"; part "g/h.dart"; class D {}'); | 5093 'library d; part "e/f.dart"; part "g/h.dart"; class D {}'); |
| 5106 addNamedSource('/a/c/e/f.dart', 'part of d;'); | 5094 addNamedSource('/a/c/e/f.dart', 'part of d;'); |
| 5107 addNamedSource('/a/c/g/h.dart', 'part of d;'); | 5095 addNamedSource('/a/c/g/h.dart', 'part of d;'); |
| 5108 serializeLibraryText('import "a/b.dart"; D d;'); | 5096 serializeLibraryText('import "a/b.dart"; D d;'); |
| 5109 int dep = checkHasDependency('a/c/d.dart'); | 5097 int dep = checkHasDependency(absUri('/a/c/d.dart')); |
| 5110 checkDependencyParts( | 5098 checkDependencyParts(linked.dependencies[dep], |
| 5111 linked.dependencies[dep], ['a/c/e/f.dart', 'a/c/g/h.dart']); | 5099 [absUri('/a/c/e/f.dart'), absUri('/a/c/g/h.dart')]); |
| 5112 } | 5100 } |
| 5113 | 5101 |
| 5114 test_elements_in_part() { | 5102 test_elements_in_part() { |
| 5115 addNamedSource( | 5103 addNamedSource( |
| 5116 '/part1.dart', | 5104 '/part1.dart', |
| 5117 ''' | 5105 ''' |
| 5118 part of my.lib; | 5106 part of my.lib; |
| 5119 | 5107 |
| 5120 class C {} | 5108 class C {} |
| 5121 enum E { v } | 5109 enum E { v } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5302 expect(executable.isExternal, isTrue); | 5290 expect(executable.isExternal, isTrue); |
| 5303 } | 5291 } |
| 5304 | 5292 |
| 5305 test_executable_getter_private() { | 5293 test_executable_getter_private() { |
| 5306 serializeExecutableText('int get _f => 1;', executableName: '_f'); | 5294 serializeExecutableText('int get _f => 1;', executableName: '_f'); |
| 5307 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 5295 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 5308 } | 5296 } |
| 5309 | 5297 |
| 5310 test_executable_getter_type() { | 5298 test_executable_getter_type() { |
| 5311 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); | 5299 UnlinkedExecutable executable = serializeExecutableText('int get f => 1;'); |
| 5312 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); | 5300 checkTypeRef(executable.returnType, 'dart:core', 'int'); |
| 5313 expect(executable.parameters, isEmpty); | 5301 expect(executable.parameters, isEmpty); |
| 5314 } | 5302 } |
| 5315 | 5303 |
| 5316 test_executable_getter_type_implicit() { | 5304 test_executable_getter_type_implicit() { |
| 5317 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); | 5305 UnlinkedExecutable executable = serializeExecutableText('get f => 1;'); |
| 5318 expect(executable.returnType, isNull); | 5306 expect(executable.returnType, isNull); |
| 5319 expect(executable.parameters, isEmpty); | 5307 expect(executable.parameters, isEmpty); |
| 5320 } | 5308 } |
| 5321 | 5309 |
| 5322 test_executable_localFunctions() { | 5310 test_executable_localFunctions() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5403 } // 4 | 5391 } // 4 |
| 5404 ); | 5392 ); |
| 5405 '''; | 5393 '''; |
| 5406 UnlinkedExecutable executable = | 5394 UnlinkedExecutable executable = |
| 5407 serializeVariableText(code).initializer.localFunctions[0]; | 5395 serializeVariableText(code).initializer.localFunctions[0]; |
| 5408 List<UnlinkedVariable> variables = executable.localVariables; | 5396 List<UnlinkedVariable> variables = executable.localVariables; |
| 5409 expect(variables, hasLength(2)); | 5397 expect(variables, hasLength(2)); |
| 5410 { | 5398 { |
| 5411 UnlinkedVariable e = variables.singleWhere((v) => v.name == 'e'); | 5399 UnlinkedVariable e = variables.singleWhere((v) => v.name == 'e'); |
| 5412 _assertVariableVisible(code, e, 'on int catch (', '} // 3'); | 5400 _assertVariableVisible(code, e, 'on int catch (', '} // 3'); |
| 5413 checkTypeRef(e.type, 'dart:core', 'dart:core', 'int'); | 5401 checkTypeRef(e.type, 'dart:core', 'int'); |
| 5414 } | 5402 } |
| 5415 { | 5403 { |
| 5416 UnlinkedVariable st = variables.singleWhere((v) => v.name == 'st'); | 5404 UnlinkedVariable st = variables.singleWhere((v) => v.name == 'st'); |
| 5417 _assertVariableVisible(code, st, 'on int catch (', '} // 3'); | 5405 _assertVariableVisible(code, st, 'on int catch (', '} // 3'); |
| 5418 } | 5406 } |
| 5419 } | 5407 } |
| 5420 | 5408 |
| 5421 test_executable_localVariables_catch_noVariables() { | 5409 test_executable_localVariables_catch_noVariables() { |
| 5422 String code = r''' | 5410 String code = r''' |
| 5423 f() { | 5411 f() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5451 '''; | 5439 '''; |
| 5452 UnlinkedExecutable executable = serializeVariableText(code) | 5440 UnlinkedExecutable executable = serializeVariableText(code) |
| 5453 .initializer | 5441 .initializer |
| 5454 .localFunctions[0] | 5442 .localFunctions[0] |
| 5455 .localFunctions[0]; | 5443 .localFunctions[0]; |
| 5456 List<UnlinkedVariable> variables = executable.localVariables; | 5444 List<UnlinkedVariable> variables = executable.localVariables; |
| 5457 expect(variables, hasLength(1)); | 5445 expect(variables, hasLength(1)); |
| 5458 { | 5446 { |
| 5459 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); | 5447 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); |
| 5460 _assertVariableVisible(code, i, 'for', '} // 3'); | 5448 _assertVariableVisible(code, i, 'for', '} // 3'); |
| 5461 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 5449 checkTypeRef(i.type, 'dart:core', 'int'); |
| 5462 } | 5450 } |
| 5463 } | 5451 } |
| 5464 | 5452 |
| 5465 test_executable_localVariables_forEachLoop_outside() { | 5453 test_executable_localVariables_forEachLoop_outside() { |
| 5466 String code = r''' | 5454 String code = r''' |
| 5467 var v = (() { | 5455 var v = (() { |
| 5468 f() { // 1 | 5456 f() { // 1 |
| 5469 int i; | 5457 int i; |
| 5470 for (i in <int>[]) { | 5458 for (i in <int>[]) { |
| 5471 print(i); | 5459 print(i); |
| 5472 } | 5460 } |
| 5473 } // 4 | 5461 } // 4 |
| 5474 }); | 5462 }); |
| 5475 '''; | 5463 '''; |
| 5476 UnlinkedExecutable executable = serializeVariableText(code) | 5464 UnlinkedExecutable executable = serializeVariableText(code) |
| 5477 .initializer | 5465 .initializer |
| 5478 .localFunctions[0] | 5466 .localFunctions[0] |
| 5479 .localFunctions[0]; | 5467 .localFunctions[0]; |
| 5480 List<UnlinkedVariable> variables = executable.localVariables; | 5468 List<UnlinkedVariable> variables = executable.localVariables; |
| 5481 expect(variables, hasLength(1)); | 5469 expect(variables, hasLength(1)); |
| 5482 { | 5470 { |
| 5483 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); | 5471 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); |
| 5484 _assertVariableVisible(code, i, '{ // 1', '} // 4'); | 5472 _assertVariableVisible(code, i, '{ // 1', '} // 4'); |
| 5485 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 5473 checkTypeRef(i.type, 'dart:core', 'int'); |
| 5486 } | 5474 } |
| 5487 } | 5475 } |
| 5488 | 5476 |
| 5489 test_executable_localVariables_forLoop() { | 5477 test_executable_localVariables_forLoop() { |
| 5490 String code = r''' | 5478 String code = r''' |
| 5491 var v = (() { | 5479 var v = (() { |
| 5492 f() { // 1 | 5480 f() { // 1 |
| 5493 for (int i = 0, j = 0; i < 10; i++, j++) { // 2 | 5481 for (int i = 0, j = 0; i < 10; i++, j++) { // 2 |
| 5494 print(i); | 5482 print(i); |
| 5495 } // 3 | 5483 } // 3 |
| 5496 } // 4 | 5484 } // 4 |
| 5497 }); | 5485 }); |
| 5498 '''; | 5486 '''; |
| 5499 UnlinkedExecutable executable = serializeVariableText(code) | 5487 UnlinkedExecutable executable = serializeVariableText(code) |
| 5500 .initializer | 5488 .initializer |
| 5501 .localFunctions[0] | 5489 .localFunctions[0] |
| 5502 .localFunctions[0]; | 5490 .localFunctions[0]; |
| 5503 List<UnlinkedVariable> variables = executable.localVariables; | 5491 List<UnlinkedVariable> variables = executable.localVariables; |
| 5504 expect(variables, hasLength(2)); | 5492 expect(variables, hasLength(2)); |
| 5505 { | 5493 { |
| 5506 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); | 5494 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i'); |
| 5507 _assertVariableVisible(code, i, 'for', '} // 3'); | 5495 _assertVariableVisible(code, i, 'for', '} // 3'); |
| 5508 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 5496 checkTypeRef(i.type, 'dart:core', 'int'); |
| 5509 } | 5497 } |
| 5510 { | 5498 { |
| 5511 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'j'); | 5499 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'j'); |
| 5512 _assertVariableVisible(code, i, 'for', '} // 3'); | 5500 _assertVariableVisible(code, i, 'for', '} // 3'); |
| 5513 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 5501 checkTypeRef(i.type, 'dart:core', 'int'); |
| 5514 } | 5502 } |
| 5515 } | 5503 } |
| 5516 | 5504 |
| 5517 test_executable_localVariables_forLoop_noVariables() { | 5505 test_executable_localVariables_forLoop_noVariables() { |
| 5518 String code = r''' | 5506 String code = r''' |
| 5519 var v = (() { | 5507 var v = (() { |
| 5520 f() { | 5508 f() { |
| 5521 for (; true;) {} | 5509 for (; true;) {} |
| 5522 } | 5510 } |
| 5523 }); | 5511 }); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5567 List<UnlinkedExecutable> functions = executable.localFunctions; | 5555 List<UnlinkedExecutable> functions = executable.localFunctions; |
| 5568 expect(functions, hasLength(2)); | 5556 expect(functions, hasLength(2)); |
| 5569 // f - f1 | 5557 // f - f1 |
| 5570 { | 5558 { |
| 5571 UnlinkedExecutable f1 = functions.singleWhere((v) => v.name == 'f1'); | 5559 UnlinkedExecutable f1 = functions.singleWhere((v) => v.name == 'f1'); |
| 5572 List<UnlinkedVariable> variables = f1.localVariables; | 5560 List<UnlinkedVariable> variables = f1.localVariables; |
| 5573 expect(variables, hasLength(1)); | 5561 expect(variables, hasLength(1)); |
| 5574 // f1 - v1 | 5562 // f1 - v1 |
| 5575 UnlinkedVariable v1 = variables.singleWhere((v) => v.name == 'v1'); | 5563 UnlinkedVariable v1 = variables.singleWhere((v) => v.name == 'v1'); |
| 5576 _assertVariableVisible(code, v1, '{ // 1', '} // 2'); | 5564 _assertVariableVisible(code, v1, '{ // 1', '} // 2'); |
| 5577 checkTypeRef(v1.type, 'dart:core', 'dart:core', 'int'); | 5565 checkTypeRef(v1.type, 'dart:core', 'int'); |
| 5578 } | 5566 } |
| 5579 // f - f2 | 5567 // f - f2 |
| 5580 { | 5568 { |
| 5581 UnlinkedExecutable f2 = functions.singleWhere((v) => v.name == 'f2'); | 5569 UnlinkedExecutable f2 = functions.singleWhere((v) => v.name == 'f2'); |
| 5582 List<UnlinkedVariable> variables2 = f2.localVariables; | 5570 List<UnlinkedVariable> variables2 = f2.localVariables; |
| 5583 List<UnlinkedExecutable> functions2 = f2.localFunctions; | 5571 List<UnlinkedExecutable> functions2 = f2.localFunctions; |
| 5584 expect(variables2, hasLength(1)); | 5572 expect(variables2, hasLength(1)); |
| 5585 expect(functions2, hasLength(1)); | 5573 expect(functions2, hasLength(1)); |
| 5586 // f - f2 - v1 | 5574 // f - f2 - v1 |
| 5587 UnlinkedVariable v1 = variables2.singleWhere((v) => v.name == 'v1'); | 5575 UnlinkedVariable v1 = variables2.singleWhere((v) => v.name == 'v1'); |
| 5588 _assertVariableVisible(code, v1, '{ // 3', '} // 6'); | 5576 _assertVariableVisible(code, v1, '{ // 3', '} // 6'); |
| 5589 checkTypeRef(v1.type, 'dart:core', 'dart:core', 'int'); | 5577 checkTypeRef(v1.type, 'dart:core', 'int'); |
| 5590 // f - f2 - f3 | 5578 // f - f2 - f3 |
| 5591 UnlinkedExecutable f3 = functions2.singleWhere((v) => v.name == 'f3'); | 5579 UnlinkedExecutable f3 = functions2.singleWhere((v) => v.name == 'f3'); |
| 5592 _assertExecutableVisible(code, f3, '{ // 3', '} // 6'); | 5580 _assertExecutableVisible(code, f3, '{ // 3', '} // 6'); |
| 5593 List<UnlinkedVariable> variables3 = f3.localVariables; | 5581 List<UnlinkedVariable> variables3 = f3.localVariables; |
| 5594 List<UnlinkedExecutable> functions3 = f3.localFunctions; | 5582 List<UnlinkedExecutable> functions3 = f3.localFunctions; |
| 5595 expect(variables3, hasLength(1)); | 5583 expect(variables3, hasLength(1)); |
| 5596 expect(functions3, hasLength(0)); | 5584 expect(functions3, hasLength(0)); |
| 5597 // f - f3 - v2 | 5585 // f - f3 - v2 |
| 5598 UnlinkedVariable v2 = variables3.singleWhere((v) => v.name == 'v2'); | 5586 UnlinkedVariable v2 = variables3.singleWhere((v) => v.name == 'v2'); |
| 5599 _assertVariableVisible(code, v2, '{ // 4', '} // 5'); | 5587 _assertVariableVisible(code, v2, '{ // 4', '} // 5'); |
| 5600 checkTypeRef(v2.type, 'dart:core', 'dart:core', 'int'); | 5588 checkTypeRef(v2.type, 'dart:core', 'int'); |
| 5601 } | 5589 } |
| 5602 } | 5590 } |
| 5603 | 5591 |
| 5604 test_executable_localVariables_inMethod() { | 5592 test_executable_localVariables_inMethod() { |
| 5605 String code = r''' | 5593 String code = r''' |
| 5606 class C { | 5594 class C { |
| 5607 m() { | 5595 m() { |
| 5608 int v; | 5596 int v; |
| 5609 f() {} | 5597 f() {} |
| 5610 } | 5598 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5806 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 5794 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 5807 expect(executable.name, '+'); | 5795 expect(executable.name, '+'); |
| 5808 expect(executable.returnType, isNotNull); | 5796 expect(executable.returnType, isNotNull); |
| 5809 expect(executable.isAbstract, false); | 5797 expect(executable.isAbstract, false); |
| 5810 expect(executable.isAsynchronous, isFalse); | 5798 expect(executable.isAsynchronous, isFalse); |
| 5811 expect(executable.isConst, false); | 5799 expect(executable.isConst, false); |
| 5812 expect(executable.isFactory, false); | 5800 expect(executable.isFactory, false); |
| 5813 expect(executable.isGenerator, isFalse); | 5801 expect(executable.isGenerator, isFalse); |
| 5814 expect(executable.isStatic, false); | 5802 expect(executable.isStatic, false); |
| 5815 expect(executable.parameters, hasLength(1)); | 5803 expect(executable.parameters, hasLength(1)); |
| 5816 checkTypeRef(executable.returnType, null, null, 'C'); | 5804 checkTypeRef(executable.returnType, null, 'C'); |
| 5817 expect(executable.typeParameters, isEmpty); | 5805 expect(executable.typeParameters, isEmpty); |
| 5818 expect(executable.isExternal, false); | 5806 expect(executable.isExternal, false); |
| 5819 } | 5807 } |
| 5820 | 5808 |
| 5821 test_executable_operator_abstract() { | 5809 test_executable_operator_abstract() { |
| 5822 UnlinkedExecutable executable = | 5810 UnlinkedExecutable executable = |
| 5823 serializeClassText('class C { C operator+(C c); }', allowErrors: true) | 5811 serializeClassText('class C { C operator+(C c); }', allowErrors: true) |
| 5824 .executables[0]; | 5812 .executables[0]; |
| 5825 expect(executable.isAbstract, true); | 5813 expect(executable.isAbstract, true); |
| 5826 expect(executable.isAsynchronous, isFalse); | 5814 expect(executable.isAsynchronous, isFalse); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5857 serializeClassText('class C { bool operator[](int i) => null; }') | 5845 serializeClassText('class C { bool operator[](int i) => null; }') |
| 5858 .executables[0]; | 5846 .executables[0]; |
| 5859 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 5847 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 5860 expect(executable.name, '[]'); | 5848 expect(executable.name, '[]'); |
| 5861 expect(executable.returnType, isNotNull); | 5849 expect(executable.returnType, isNotNull); |
| 5862 expect(executable.isAbstract, false); | 5850 expect(executable.isAbstract, false); |
| 5863 expect(executable.isConst, false); | 5851 expect(executable.isConst, false); |
| 5864 expect(executable.isFactory, false); | 5852 expect(executable.isFactory, false); |
| 5865 expect(executable.isStatic, false); | 5853 expect(executable.isStatic, false); |
| 5866 expect(executable.parameters, hasLength(1)); | 5854 expect(executable.parameters, hasLength(1)); |
| 5867 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'bool'); | 5855 checkTypeRef(executable.returnType, 'dart:core', 'bool'); |
| 5868 expect(executable.typeParameters, isEmpty); | 5856 expect(executable.typeParameters, isEmpty); |
| 5869 } | 5857 } |
| 5870 | 5858 |
| 5871 test_executable_operator_index_set() { | 5859 test_executable_operator_index_set() { |
| 5872 UnlinkedExecutable executable = serializeClassText( | 5860 UnlinkedExecutable executable = serializeClassText( |
| 5873 'class C { void operator[]=(int i, bool v) => null; }') | 5861 'class C { void operator[]=(int i, bool v) => null; }') |
| 5874 .executables[0]; | 5862 .executables[0]; |
| 5875 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 5863 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
| 5876 expect(executable.name, '[]='); | 5864 expect(executable.name, '[]='); |
| 5877 expect(executable.returnType, isNotNull); | 5865 expect(executable.returnType, isNotNull); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5922 | 5910 |
| 5923 test_executable_param_function_typed_param_order() { | 5911 test_executable_param_function_typed_param_order() { |
| 5924 UnlinkedExecutable executable = serializeExecutableText('f(g(x, y)) {}'); | 5912 UnlinkedExecutable executable = serializeExecutableText('f(g(x, y)) {}'); |
| 5925 expect(executable.parameters[0].parameters, hasLength(2)); | 5913 expect(executable.parameters[0].parameters, hasLength(2)); |
| 5926 expect(executable.parameters[0].parameters[0].name, 'x'); | 5914 expect(executable.parameters[0].parameters[0].name, 'x'); |
| 5927 expect(executable.parameters[0].parameters[1].name, 'y'); | 5915 expect(executable.parameters[0].parameters[1].name, 'y'); |
| 5928 } | 5916 } |
| 5929 | 5917 |
| 5930 test_executable_param_function_typed_return_type() { | 5918 test_executable_param_function_typed_return_type() { |
| 5931 UnlinkedExecutable executable = serializeExecutableText('f(int g()) {}'); | 5919 UnlinkedExecutable executable = serializeExecutableText('f(int g()) {}'); |
| 5932 checkTypeRef( | 5920 checkTypeRef(executable.parameters[0].type, 'dart:core', 'int'); |
| 5933 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); | |
| 5934 } | 5921 } |
| 5935 | 5922 |
| 5936 test_executable_param_function_typed_return_type_implicit() { | 5923 test_executable_param_function_typed_return_type_implicit() { |
| 5937 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); | 5924 UnlinkedExecutable executable = serializeExecutableText('f(g()) {}'); |
| 5938 expect(executable.parameters[0].isFunctionTyped, isTrue); | 5925 expect(executable.parameters[0].isFunctionTyped, isTrue); |
| 5939 expect(executable.parameters[0].type, isNull); | 5926 expect(executable.parameters[0].type, isNull); |
| 5940 } | 5927 } |
| 5941 | 5928 |
| 5942 test_executable_param_function_typed_return_type_void() { | 5929 test_executable_param_function_typed_return_type_void() { |
| 5943 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); | 5930 UnlinkedExecutable executable = serializeExecutableText('f(void g()) {}'); |
| 5944 checkVoidTypeRef(executable.parameters[0].type); | 5931 checkVoidTypeRef(executable.parameters[0].type); |
| 5945 } | 5932 } |
| 5946 | 5933 |
| 5947 test_executable_param_function_typed_withDefault() { | 5934 test_executable_param_function_typed_withDefault() { |
| 5948 UnlinkedExecutable executable = serializeExecutableText(r''' | 5935 UnlinkedExecutable executable = serializeExecutableText(r''' |
| 5949 f([int p(int a2, String b2) = foo]) {} | 5936 f([int p(int a2, String b2) = foo]) {} |
| 5950 int foo(int a, String b) => 0; | 5937 int foo(int a, String b) => 0; |
| 5951 '''); | 5938 '''); |
| 5952 UnlinkedParam param = executable.parameters[0]; | 5939 UnlinkedParam param = executable.parameters[0]; |
| 5953 expect(param.kind, UnlinkedParamKind.positional); | 5940 expect(param.kind, UnlinkedParamKind.positional); |
| 5954 expect(param.initializer, isNotNull); | 5941 expect(param.initializer, isNotNull); |
| 5955 expect(param.defaultValueCode, 'foo'); | 5942 expect(param.defaultValueCode, 'foo'); |
| 5956 assertUnlinkedConst(param.initializer.bodyExpr, operators: [ | 5943 assertUnlinkedConst(param.initializer.bodyExpr, operators: [ |
| 5957 UnlinkedExprOperation.pushReference | 5944 UnlinkedExprOperation.pushReference |
| 5958 ], referenceValidators: [ | 5945 ], referenceValidators: [ |
| 5959 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 5946 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 5960 expectedKind: ReferenceKind.topLevelFunction) | 5947 expectedKind: ReferenceKind.topLevelFunction) |
| 5961 ]); | 5948 ]); |
| 5962 } | 5949 } |
| 5963 | 5950 |
| 5964 test_executable_param_isFinal() { | 5951 test_executable_param_isFinal() { |
| 5965 String text = 'f(x, final y) {}'; | 5952 String text = 'f(x, final y) {}'; |
| 5966 UnlinkedExecutable executable = serializeExecutableText(text); | 5953 UnlinkedExecutable executable = serializeExecutableText(text); |
| 5967 expect(executable.parameters, hasLength(2)); | 5954 expect(executable.parameters, hasLength(2)); |
| 5968 expect(executable.parameters[0].name, 'x'); | 5955 expect(executable.parameters[0].name, 'x'); |
| 5969 expect(executable.parameters[0].isFinal, isFalse); | 5956 expect(executable.parameters[0].isFinal, isFalse); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6098 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); | 6085 UnlinkedExecutable executable = serializeExecutableText('f(x) {}'); |
| 6099 expect(executable.parameters[0].type, isNull); | 6086 expect(executable.parameters[0].type, isNull); |
| 6100 } | 6087 } |
| 6101 | 6088 |
| 6102 test_executable_param_type_typedef() { | 6089 test_executable_param_type_typedef() { |
| 6103 UnlinkedExecutable executable = serializeExecutableText(r''' | 6090 UnlinkedExecutable executable = serializeExecutableText(r''' |
| 6104 typedef MyFunction(int p); | 6091 typedef MyFunction(int p); |
| 6105 f(MyFunction myFunction) {} | 6092 f(MyFunction myFunction) {} |
| 6106 '''); | 6093 '''); |
| 6107 expect(executable.parameters[0].isFunctionTyped, isFalse); | 6094 expect(executable.parameters[0].isFunctionTyped, isFalse); |
| 6108 checkTypeRef(executable.parameters[0].type, null, null, 'MyFunction', | 6095 checkTypeRef(executable.parameters[0].type, null, 'MyFunction', |
| 6109 expectedKind: ReferenceKind.typedef); | 6096 expectedKind: ReferenceKind.typedef); |
| 6110 } | 6097 } |
| 6111 | 6098 |
| 6112 test_executable_return_type() { | 6099 test_executable_return_type() { |
| 6113 UnlinkedExecutable executable = serializeExecutableText('int f() => 1;'); | 6100 UnlinkedExecutable executable = serializeExecutableText('int f() => 1;'); |
| 6114 checkTypeRef(executable.returnType, 'dart:core', 'dart:core', 'int'); | 6101 checkTypeRef(executable.returnType, 'dart:core', 'int'); |
| 6115 } | 6102 } |
| 6116 | 6103 |
| 6117 test_executable_return_type_implicit() { | 6104 test_executable_return_type_implicit() { |
| 6118 UnlinkedExecutable executable = serializeExecutableText('f() {}'); | 6105 UnlinkedExecutable executable = serializeExecutableText('f() {}'); |
| 6119 expect(executable.returnType, isNull); | 6106 expect(executable.returnType, isNull); |
| 6120 } | 6107 } |
| 6121 | 6108 |
| 6122 test_executable_return_type_void() { | 6109 test_executable_return_type_void() { |
| 6123 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); | 6110 UnlinkedExecutable executable = serializeExecutableText('void f() {}'); |
| 6124 checkVoidTypeRef(executable.returnType); | 6111 checkVoidTypeRef(executable.returnType); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6162 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 6149 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 6163 } | 6150 } |
| 6164 | 6151 |
| 6165 test_executable_setter_type() { | 6152 test_executable_setter_type() { |
| 6166 UnlinkedExecutable executable = serializeExecutableText( | 6153 UnlinkedExecutable executable = serializeExecutableText( |
| 6167 'void set f(int value) {}', | 6154 'void set f(int value) {}', |
| 6168 executableName: 'f='); | 6155 executableName: 'f='); |
| 6169 checkVoidTypeRef(executable.returnType); | 6156 checkVoidTypeRef(executable.returnType); |
| 6170 expect(executable.parameters, hasLength(1)); | 6157 expect(executable.parameters, hasLength(1)); |
| 6171 expect(executable.parameters[0].name, 'value'); | 6158 expect(executable.parameters[0].name, 'value'); |
| 6172 checkTypeRef( | 6159 checkTypeRef(executable.parameters[0].type, 'dart:core', 'int'); |
| 6173 executable.parameters[0].type, 'dart:core', 'dart:core', 'int'); | |
| 6174 } | 6160 } |
| 6175 | 6161 |
| 6176 test_executable_static() { | 6162 test_executable_static() { |
| 6177 UnlinkedExecutable executable = | 6163 UnlinkedExecutable executable = |
| 6178 serializeClassText('class C { static f() {} }').executables[0]; | 6164 serializeClassText('class C { static f() {} }').executables[0]; |
| 6179 expect(executable.isStatic, isTrue); | 6165 expect(executable.isStatic, isTrue); |
| 6180 } | 6166 } |
| 6181 | 6167 |
| 6182 test_executable_type_param_f_bound_function() { | 6168 test_executable_type_param_f_bound_function() { |
| 6183 UnlinkedExecutable ex = | 6169 UnlinkedExecutable ex = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6225 | 6211 |
| 6226 test_executable_type_param_in_return_type_method() { | 6212 test_executable_type_param_in_return_type_method() { |
| 6227 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); | 6213 UnlinkedExecutable ex = serializeMethodText('T f<T>() => null;'); |
| 6228 checkParamTypeRef(ex.returnType, 1); | 6214 checkParamTypeRef(ex.returnType, 1); |
| 6229 } | 6215 } |
| 6230 | 6216 |
| 6231 test_export_class() { | 6217 test_export_class() { |
| 6232 addNamedSource('/a.dart', 'class C {}'); | 6218 addNamedSource('/a.dart', 'class C {}'); |
| 6233 serializeLibraryText('export "a.dart";'); | 6219 serializeLibraryText('export "a.dart";'); |
| 6234 expect(linked.exportNames, hasLength(1)); | 6220 expect(linked.exportNames, hasLength(1)); |
| 6235 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', | 6221 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'C', |
| 6236 ReferenceKind.classOrEnum); | 6222 ReferenceKind.classOrEnum); |
| 6237 } | 6223 } |
| 6238 | 6224 |
| 6239 test_export_class_alias() { | 6225 test_export_class_alias() { |
| 6240 addNamedSource( | 6226 addNamedSource( |
| 6241 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}'); | 6227 '/a.dart', 'class C extends _D with _E {} class _D {} class _E {}'); |
| 6242 serializeLibraryText('export "a.dart";'); | 6228 serializeLibraryText('export "a.dart";'); |
| 6243 expect(linked.exportNames, hasLength(1)); | 6229 expect(linked.exportNames, hasLength(1)); |
| 6244 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'C', | 6230 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'C', |
| 6245 ReferenceKind.classOrEnum); | 6231 ReferenceKind.classOrEnum); |
| 6246 } | 6232 } |
| 6247 | 6233 |
| 6248 test_export_configurations() { | 6234 test_export_configurations() { |
| 6249 addNamedSource('/foo.dart', 'class A {}'); | 6235 addNamedSource('/foo.dart', 'class A {}'); |
| 6250 addNamedSource('/foo_io.dart', 'class A {}'); | 6236 addNamedSource('/foo_io.dart', 'class A {}'); |
| 6251 addNamedSource('/foo_html.dart', 'class A {}'); | 6237 addNamedSource('/foo_html.dart', 'class A {}'); |
| 6252 String libraryText = r''' | 6238 String libraryText = r''' |
| 6253 export 'foo.dart' | 6239 export 'foo.dart' |
| 6254 if (dart.library.io) 'foo_io.dart' | 6240 if (dart.library.io) 'foo_io.dart' |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6269 UnlinkedConfiguration configuration = exp.configurations[1]; | 6255 UnlinkedConfiguration configuration = exp.configurations[1]; |
| 6270 expect(configuration.name, 'dart.flavor'); | 6256 expect(configuration.name, 'dart.flavor'); |
| 6271 expect(configuration.value, 'html'); | 6257 expect(configuration.value, 'html'); |
| 6272 expect(configuration.uri, 'foo_html.dart'); | 6258 expect(configuration.uri, 'foo_html.dart'); |
| 6273 } | 6259 } |
| 6274 } | 6260 } |
| 6275 | 6261 |
| 6276 test_export_dependency() { | 6262 test_export_dependency() { |
| 6277 serializeLibraryText('export "dart:async";'); | 6263 serializeLibraryText('export "dart:async";'); |
| 6278 expect(unlinkedUnits[0].exports, hasLength(1)); | 6264 expect(unlinkedUnits[0].exports, hasLength(1)); |
| 6279 checkDependency(linked.exportDependencies[0], 'dart:async', 'dart:async'); | 6265 checkDependency(linked.exportDependencies[0], 'dart:async'); |
| 6280 } | 6266 } |
| 6281 | 6267 |
| 6282 test_export_enum() { | 6268 test_export_enum() { |
| 6283 addNamedSource('/a.dart', 'enum E { v }'); | 6269 addNamedSource('/a.dart', 'enum E { v }'); |
| 6284 serializeLibraryText('export "a.dart";'); | 6270 serializeLibraryText('export "a.dart";'); |
| 6285 expect(linked.exportNames, hasLength(1)); | 6271 expect(linked.exportNames, hasLength(1)); |
| 6286 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'E', | 6272 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'E', |
| 6287 ReferenceKind.classOrEnum); | 6273 ReferenceKind.classOrEnum); |
| 6288 } | 6274 } |
| 6289 | 6275 |
| 6290 test_export_from_part() { | 6276 test_export_from_part() { |
| 6291 addNamedSource('/a.dart', 'library foo; part "b.dart";'); | 6277 addNamedSource('/a.dart', 'library foo; part "b.dart";'); |
| 6292 addNamedSource('/b.dart', 'part of foo; f() {}'); | 6278 addNamedSource('/b.dart', 'part of foo; f() {}'); |
| 6293 serializeLibraryText('export "a.dart";'); | 6279 serializeLibraryText('export "a.dart";'); |
| 6294 expect(linked.exportNames, hasLength(1)); | 6280 expect(linked.exportNames, hasLength(1)); |
| 6295 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6281 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6296 ReferenceKind.topLevelFunction, | 6282 ReferenceKind.topLevelFunction, |
| 6297 expectedTargetUnit: 1); | 6283 expectedTargetUnit: 1); |
| 6298 } | 6284 } |
| 6299 | 6285 |
| 6300 test_export_function() { | 6286 test_export_function() { |
| 6301 addNamedSource('/a.dart', 'f() {}'); | 6287 addNamedSource('/a.dart', 'f() {}'); |
| 6302 serializeLibraryText('export "a.dart";'); | 6288 serializeLibraryText('export "a.dart";'); |
| 6303 expect(linked.exportNames, hasLength(1)); | 6289 expect(linked.exportNames, hasLength(1)); |
| 6304 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6290 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6305 ReferenceKind.topLevelFunction); | 6291 ReferenceKind.topLevelFunction); |
| 6306 } | 6292 } |
| 6307 | 6293 |
| 6308 test_export_getter() { | 6294 test_export_getter() { |
| 6309 addNamedSource('/a.dart', 'get f => null'); | 6295 addNamedSource('/a.dart', 'get f => null'); |
| 6310 serializeLibraryText('export "a.dart";'); | 6296 serializeLibraryText('export "a.dart";'); |
| 6311 expect(linked.exportNames, hasLength(1)); | 6297 expect(linked.exportNames, hasLength(1)); |
| 6312 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6298 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6313 ReferenceKind.topLevelPropertyAccessor); | 6299 ReferenceKind.topLevelPropertyAccessor); |
| 6314 } | 6300 } |
| 6315 | 6301 |
| 6316 test_export_hide() { | 6302 test_export_hide() { |
| 6317 addNamedSource('/a.dart', 'f() {} g() {}'); | 6303 addNamedSource('/a.dart', 'f() {} g() {}'); |
| 6318 serializeLibraryText('export "a.dart" hide g;'); | 6304 serializeLibraryText('export "a.dart" hide g;'); |
| 6319 expect(linked.exportNames, hasLength(1)); | 6305 expect(linked.exportNames, hasLength(1)); |
| 6320 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6306 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6321 ReferenceKind.topLevelFunction); | 6307 ReferenceKind.topLevelFunction); |
| 6322 } | 6308 } |
| 6323 | 6309 |
| 6324 test_export_hide_order() { | 6310 test_export_hide_order() { |
| 6325 serializeLibraryText('export "dart:async" hide Future, Stream;'); | 6311 serializeLibraryText('export "dart:async" hide Future, Stream;'); |
| 6326 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 6312 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 6327 expect( | 6313 expect( |
| 6328 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); | 6314 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); |
| 6329 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, | 6315 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, |
| 6330 isEmpty); | 6316 isEmpty); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6341 } | 6327 } |
| 6342 expect(linked.exportNames, isNotEmpty); | 6328 expect(linked.exportNames, isNotEmpty); |
| 6343 } | 6329 } |
| 6344 | 6330 |
| 6345 test_export_missing() { | 6331 test_export_missing() { |
| 6346 // Unresolved exports are included since this is necessary for proper | 6332 // Unresolved exports are included since this is necessary for proper |
| 6347 // dependency tracking. | 6333 // dependency tracking. |
| 6348 allowMissingFiles = true; | 6334 allowMissingFiles = true; |
| 6349 serializeLibraryText('export "foo.dart";', allowErrors: true); | 6335 serializeLibraryText('export "foo.dart";', allowErrors: true); |
| 6350 expect(unlinkedUnits[0].imports, hasLength(1)); | 6336 expect(unlinkedUnits[0].imports, hasLength(1)); |
| 6351 checkDependency( | 6337 checkDependency(linked.exportDependencies[0], absUri('/foo.dart')); |
| 6352 linked.exportDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 6353 } | 6338 } |
| 6354 | 6339 |
| 6355 test_export_names_excludes_names_from_library() { | 6340 test_export_names_excludes_names_from_library() { |
| 6356 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;'); | 6341 addNamedSource('/a.dart', 'part of my.lib; int y; int _y;'); |
| 6357 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;'); | 6342 serializeLibraryText('library my.lib; part "a.dart"; int x; int _x;'); |
| 6358 expect(linked.exportNames, isEmpty); | 6343 expect(linked.exportNames, isEmpty); |
| 6359 } | 6344 } |
| 6360 | 6345 |
| 6361 test_export_no_combinators() { | 6346 test_export_no_combinators() { |
| 6362 serializeLibraryText('export "dart:async";'); | 6347 serializeLibraryText('export "dart:async";'); |
| 6363 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 6348 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 6364 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty); | 6349 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty); |
| 6365 } | 6350 } |
| 6366 | 6351 |
| 6367 test_export_not_shadowed_by_prefix() { | 6352 test_export_not_shadowed_by_prefix() { |
| 6368 addNamedSource('/a.dart', 'f() {}'); | 6353 addNamedSource('/a.dart', 'f() {}'); |
| 6369 serializeLibraryText('export "a.dart"; import "dart:core" as f; f.int _x;'); | 6354 serializeLibraryText('export "a.dart"; import "dart:core" as f; f.int _x;'); |
| 6370 expect(linked.exportNames, hasLength(1)); | 6355 expect(linked.exportNames, hasLength(1)); |
| 6371 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6356 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6372 ReferenceKind.topLevelFunction); | 6357 ReferenceKind.topLevelFunction); |
| 6373 } | 6358 } |
| 6374 | 6359 |
| 6375 test_export_offset() { | 6360 test_export_offset() { |
| 6376 String libraryText = ' export "dart:async";'; | 6361 String libraryText = ' export "dart:async";'; |
| 6377 serializeLibraryText(libraryText); | 6362 serializeLibraryText(libraryText); |
| 6378 expect(unlinkedUnits[0].exports[0].uriOffset, | 6363 expect(unlinkedUnits[0].exports[0].uriOffset, |
| 6379 libraryText.indexOf('"dart:async"')); | 6364 libraryText.indexOf('"dart:async"')); |
| 6380 expect(unlinkedUnits[0].exports[0].uriEnd, libraryText.indexOf(';')); | 6365 expect(unlinkedUnits[0].exports[0].uriEnd, libraryText.indexOf(';')); |
| 6381 expect(unlinkedUnits[0].exports[0].offset, libraryText.indexOf('export')); | 6366 expect(unlinkedUnits[0].exports[0].offset, libraryText.indexOf('export')); |
| 6382 } | 6367 } |
| 6383 | 6368 |
| 6384 test_export_private() { | 6369 test_export_private() { |
| 6385 // Private names should not be exported. | 6370 // Private names should not be exported. |
| 6386 addNamedSource('/a.dart', '_f() {}'); | 6371 addNamedSource('/a.dart', '_f() {}'); |
| 6387 serializeLibraryText('export "a.dart";'); | 6372 serializeLibraryText('export "a.dart";'); |
| 6388 expect(linked.exportNames, isEmpty); | 6373 expect(linked.exportNames, isEmpty); |
| 6389 } | 6374 } |
| 6390 | 6375 |
| 6391 test_export_setter() { | 6376 test_export_setter() { |
| 6392 addNamedSource('/a.dart', 'void set f(value) {}'); | 6377 addNamedSource('/a.dart', 'void set f(value) {}'); |
| 6393 serializeLibraryText('export "a.dart";'); | 6378 serializeLibraryText('export "a.dart";'); |
| 6394 expect(linked.exportNames, hasLength(1)); | 6379 expect(linked.exportNames, hasLength(1)); |
| 6395 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f=', | 6380 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f=', |
| 6396 ReferenceKind.topLevelPropertyAccessor); | 6381 ReferenceKind.topLevelPropertyAccessor); |
| 6397 } | 6382 } |
| 6398 | 6383 |
| 6399 test_export_shadowed() { | 6384 test_export_shadowed() { |
| 6400 // f() is not shown in exportNames because it is already defined at top | 6385 // f() is not shown in exportNames because it is already defined at top |
| 6401 // level in the library. | 6386 // level in the library. |
| 6402 addNamedSource('/a.dart', 'f() {}'); | 6387 addNamedSource('/a.dart', 'f() {}'); |
| 6403 serializeLibraryText('export "a.dart"; f() {}'); | 6388 serializeLibraryText('export "a.dart"; f() {}'); |
| 6404 expect(linked.exportNames, isEmpty); | 6389 expect(linked.exportNames, isEmpty); |
| 6405 } | 6390 } |
| 6406 | 6391 |
| 6407 test_export_shadowed_variable() { | 6392 test_export_shadowed_variable() { |
| 6408 // Neither `v` nor `v=` is shown in exportNames because both are defined at | 6393 // Neither `v` nor `v=` is shown in exportNames because both are defined at |
| 6409 // top level in the library by the declaration `var v;`. | 6394 // top level in the library by the declaration `var v;`. |
| 6410 addNamedSource('/a.dart', 'var v;'); | 6395 addNamedSource('/a.dart', 'var v;'); |
| 6411 serializeLibraryText('export "a.dart"; var v;'); | 6396 serializeLibraryText('export "a.dart"; var v;'); |
| 6412 expect(linked.exportNames, isEmpty); | 6397 expect(linked.exportNames, isEmpty); |
| 6413 } | 6398 } |
| 6414 | 6399 |
| 6415 test_export_shadowed_variable_const() { | 6400 test_export_shadowed_variable_const() { |
| 6416 // `v=` is shown in exportNames because the top level declaration | 6401 // `v=` is shown in exportNames because the top level declaration |
| 6417 // `const v = 0;` only shadows `v`, not `v=`. | 6402 // `const v = 0;` only shadows `v`, not `v=`. |
| 6418 addNamedSource('/a.dart', 'var v;'); | 6403 addNamedSource('/a.dart', 'var v;'); |
| 6419 serializeLibraryText('export "a.dart"; const v = 0;'); | 6404 serializeLibraryText('export "a.dart"; const v = 0;'); |
| 6420 expect(linked.exportNames, hasLength(1)); | 6405 expect(linked.exportNames, hasLength(1)); |
| 6421 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', | 6406 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'v=', |
| 6422 ReferenceKind.topLevelPropertyAccessor); | 6407 ReferenceKind.topLevelPropertyAccessor); |
| 6423 } | 6408 } |
| 6424 | 6409 |
| 6425 test_export_shadowed_variable_final() { | 6410 test_export_shadowed_variable_final() { |
| 6426 // `v=` is shown in exportNames because the top level declaration | 6411 // `v=` is shown in exportNames because the top level declaration |
| 6427 // `final v = 0;` only shadows `v`, not `v=`. | 6412 // `final v = 0;` only shadows `v`, not `v=`. |
| 6428 addNamedSource('/a.dart', 'var v;'); | 6413 addNamedSource('/a.dart', 'var v;'); |
| 6429 serializeLibraryText('export "a.dart"; final v = 0;'); | 6414 serializeLibraryText('export "a.dart"; final v = 0;'); |
| 6430 expect(linked.exportNames, hasLength(1)); | 6415 expect(linked.exportNames, hasLength(1)); |
| 6431 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'v=', | 6416 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'v=', |
| 6432 ReferenceKind.topLevelPropertyAccessor); | 6417 ReferenceKind.topLevelPropertyAccessor); |
| 6433 } | 6418 } |
| 6434 | 6419 |
| 6435 test_export_show() { | 6420 test_export_show() { |
| 6436 addNamedSource('/a.dart', 'f() {} g() {}'); | 6421 addNamedSource('/a.dart', 'f() {} g() {}'); |
| 6437 serializeLibraryText('export "a.dart" show f;'); | 6422 serializeLibraryText('export "a.dart" show f;'); |
| 6438 expect(linked.exportNames, hasLength(1)); | 6423 expect(linked.exportNames, hasLength(1)); |
| 6439 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'f', | 6424 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'f', |
| 6440 ReferenceKind.topLevelFunction); | 6425 ReferenceKind.topLevelFunction); |
| 6441 } | 6426 } |
| 6442 | 6427 |
| 6443 test_export_show_order() { | 6428 test_export_show_order() { |
| 6444 String libraryText = 'export "dart:async" show Future, Stream;'; | 6429 String libraryText = 'export "dart:async" show Future, Stream;'; |
| 6445 serializeLibraryText(libraryText); | 6430 serializeLibraryText(libraryText); |
| 6446 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 6431 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 6447 expect( | 6432 expect( |
| 6448 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); | 6433 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); |
| 6449 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, | 6434 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, |
| 6450 hasLength(2)); | 6435 hasLength(2)); |
| 6451 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, | 6436 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, |
| 6452 isEmpty); | 6437 isEmpty); |
| 6453 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], | 6438 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], |
| 6454 'Future'); | 6439 'Future'); |
| 6455 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1], | 6440 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[1], |
| 6456 'Stream'); | 6441 'Stream'); |
| 6457 if (includeInformative) { | 6442 if (includeInformative) { |
| 6458 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].offset, | 6443 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].offset, |
| 6459 libraryText.indexOf('show')); | 6444 libraryText.indexOf('show')); |
| 6460 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].end, | 6445 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].end, |
| 6461 libraryText.indexOf(';')); | 6446 libraryText.indexOf(';')); |
| 6462 } | 6447 } |
| 6463 } | 6448 } |
| 6464 | 6449 |
| 6465 test_export_typedef() { | 6450 test_export_typedef() { |
| 6466 addNamedSource('/a.dart', 'typedef F();'); | 6451 addNamedSource('/a.dart', 'typedef F();'); |
| 6467 serializeLibraryText('export "a.dart";'); | 6452 serializeLibraryText('export "a.dart";'); |
| 6468 expect(linked.exportNames, hasLength(1)); | 6453 expect(linked.exportNames, hasLength(1)); |
| 6469 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'a.dart', 'F', | 6454 checkExportName( |
| 6470 ReferenceKind.typedef); | 6455 linked.exportNames[0], absUri('/a.dart'), 'F', ReferenceKind.typedef); |
| 6471 } | 6456 } |
| 6472 | 6457 |
| 6473 test_export_uri() { | 6458 test_export_uri() { |
| 6474 addNamedSource('/a.dart', 'library my.lib;'); | 6459 addNamedSource('/a.dart', 'library my.lib;'); |
| 6475 String uriString = '"a.dart"'; | 6460 String uriString = '"a.dart"'; |
| 6476 String libraryText = 'export $uriString;'; | 6461 String libraryText = 'export $uriString;'; |
| 6477 serializeLibraryText(libraryText); | 6462 serializeLibraryText(libraryText); |
| 6478 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; | 6463 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; |
| 6479 expect(unlinkedExports, hasLength(1)); | 6464 expect(unlinkedExports, hasLength(1)); |
| 6480 expect(unlinkedExports[0].uri, 'a.dart'); | 6465 expect(unlinkedExports[0].uri, 'a.dart'); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6500 expect(unlinkedExports[0].configurations, isEmpty); | 6485 expect(unlinkedExports[0].configurations, isEmpty); |
| 6501 } | 6486 } |
| 6502 | 6487 |
| 6503 test_export_variable() { | 6488 test_export_variable() { |
| 6504 addNamedSource('/a.dart', 'var v;'); | 6489 addNamedSource('/a.dart', 'var v;'); |
| 6505 serializeLibraryText('export "a.dart";'); | 6490 serializeLibraryText('export "a.dart";'); |
| 6506 expect(linked.exportNames, hasLength(2)); | 6491 expect(linked.exportNames, hasLength(2)); |
| 6507 LinkedExportName getter = | 6492 LinkedExportName getter = |
| 6508 linked.exportNames.firstWhere((e) => e.name == 'v'); | 6493 linked.exportNames.firstWhere((e) => e.name == 'v'); |
| 6509 expect(getter, isNotNull); | 6494 expect(getter, isNotNull); |
| 6510 checkExportName(getter, absUri('/a.dart'), 'a.dart', 'v', | 6495 checkExportName( |
| 6511 ReferenceKind.topLevelPropertyAccessor); | 6496 getter, absUri('/a.dart'), 'v', ReferenceKind.topLevelPropertyAccessor); |
| 6512 LinkedExportName setter = | 6497 LinkedExportName setter = |
| 6513 linked.exportNames.firstWhere((e) => e.name == 'v='); | 6498 linked.exportNames.firstWhere((e) => e.name == 'v='); |
| 6514 expect(setter, isNotNull); | 6499 expect(setter, isNotNull); |
| 6515 checkExportName(setter, absUri('/a.dart'), 'a.dart', 'v=', | 6500 checkExportName(setter, absUri('/a.dart'), 'v=', |
| 6516 ReferenceKind.topLevelPropertyAccessor); | 6501 ReferenceKind.topLevelPropertyAccessor); |
| 6517 } | 6502 } |
| 6518 | 6503 |
| 6519 test_expr_assignOperator_assign() { | 6504 test_expr_assignOperator_assign() { |
| 6520 _assertAssignmentOperator( | 6505 _assertAssignmentOperator( |
| 6521 '(a = 1 + 2) + 3', UnlinkedExprAssignOperator.assign); | 6506 '(a = 1 + 2) + 3', UnlinkedExprAssignOperator.assign); |
| 6522 } | 6507 } |
| 6523 | 6508 |
| 6524 test_expr_assignOperator_bitAnd() { | 6509 test_expr_assignOperator_bitAnd() { |
| 6525 _assertAssignmentOperator( | 6510 _assertAssignmentOperator( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6608 ], | 6593 ], |
| 6609 assignmentOperators: [ | 6594 assignmentOperators: [ |
| 6610 (UnlinkedExprAssignOperator.assign) | 6595 (UnlinkedExprAssignOperator.assign) |
| 6611 ], | 6596 ], |
| 6612 ints: [ | 6597 ints: [ |
| 6613 5, | 6598 5, |
| 6614 1 | 6599 1 |
| 6615 ], | 6600 ], |
| 6616 strings: [], | 6601 strings: [], |
| 6617 referenceValidators: [ | 6602 referenceValidators: [ |
| 6618 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6603 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 6619 expectedKind: ReferenceKind.unresolved, | 6604 expectedKind: ReferenceKind.unresolved, |
| 6620 prefixExpectations: [ | 6605 prefixExpectations: [ |
| 6621 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), | 6606 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), |
| 6622 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), | 6607 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), |
| 6623 new _PrefixExpectation( | 6608 new _PrefixExpectation( |
| 6624 ReferenceKind.topLevelPropertyAccessor, 'a') | 6609 ReferenceKind.topLevelPropertyAccessor, 'a') |
| 6625 ]) | 6610 ]) |
| 6626 ]); | 6611 ]); |
| 6627 } | 6612 } |
| 6628 | 6613 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6668 5, | 6653 5, |
| 6669 1, | 6654 1, |
| 6670 2, | 6655 2, |
| 6671 3, | 6656 3, |
| 6672 ], | 6657 ], |
| 6673 strings: [ | 6658 strings: [ |
| 6674 'c', | 6659 'c', |
| 6675 'f' | 6660 'f' |
| 6676 ], | 6661 ], |
| 6677 referenceValidators: [ | 6662 referenceValidators: [ |
| 6678 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 6663 (EntityRef r) => checkTypeRef(r, null, 'b', |
| 6679 expectedKind: ReferenceKind.unresolved, | 6664 expectedKind: ReferenceKind.unresolved, |
| 6680 prefixExpectations: [ | 6665 prefixExpectations: [ |
| 6681 new _PrefixExpectation( | 6666 new _PrefixExpectation( |
| 6682 ReferenceKind.topLevelPropertyAccessor, 'a') | 6667 ReferenceKind.topLevelPropertyAccessor, 'a') |
| 6683 ]) | 6668 ]) |
| 6684 ]); | 6669 ]); |
| 6685 } | 6670 } |
| 6686 | 6671 |
| 6687 test_expr_assignToIndex_ofTopLevelVariable() { | 6672 test_expr_assignToIndex_ofTopLevelVariable() { |
| 6688 if (skipNonConstInitializers) { | 6673 if (skipNonConstInitializers) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6702 ], | 6687 ], |
| 6703 assignmentOperators: [ | 6688 assignmentOperators: [ |
| 6704 (UnlinkedExprAssignOperator.assign) | 6689 (UnlinkedExprAssignOperator.assign) |
| 6705 ], | 6690 ], |
| 6706 ints: [ | 6691 ints: [ |
| 6707 5, | 6692 5, |
| 6708 1, | 6693 1, |
| 6709 ], | 6694 ], |
| 6710 strings: [], | 6695 strings: [], |
| 6711 referenceValidators: [ | 6696 referenceValidators: [ |
| 6712 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6697 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 6713 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6698 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6714 ]); | 6699 ]); |
| 6715 } | 6700 } |
| 6716 | 6701 |
| 6717 test_expr_assignToProperty_ofInstanceCreation() { | 6702 test_expr_assignToProperty_ofInstanceCreation() { |
| 6718 if (skipNonConstInitializers) { | 6703 if (skipNonConstInitializers) { |
| 6719 return; | 6704 return; |
| 6720 } | 6705 } |
| 6721 UnlinkedVariable variable = serializeVariableText(''' | 6706 UnlinkedVariable variable = serializeVariableText(''' |
| 6722 class C { | 6707 class C { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6736 ], | 6721 ], |
| 6737 ints: [ | 6722 ints: [ |
| 6738 5, | 6723 5, |
| 6739 0, | 6724 0, |
| 6740 0, | 6725 0, |
| 6741 ], | 6726 ], |
| 6742 strings: [ | 6727 strings: [ |
| 6743 'f' | 6728 'f' |
| 6744 ], | 6729 ], |
| 6745 referenceValidators: [ | 6730 referenceValidators: [ |
| 6746 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6731 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 6747 expectedKind: ReferenceKind.classOrEnum) | 6732 expectedKind: ReferenceKind.classOrEnum) |
| 6748 ]); | 6733 ]); |
| 6749 } | 6734 } |
| 6750 | 6735 |
| 6751 test_expr_assignToRef_classStaticField() { | 6736 test_expr_assignToRef_classStaticField() { |
| 6752 if (skipNonConstInitializers) { | 6737 if (skipNonConstInitializers) { |
| 6753 return; | 6738 return; |
| 6754 } | 6739 } |
| 6755 UnlinkedVariable variable = serializeVariableText(''' | 6740 UnlinkedVariable variable = serializeVariableText(''' |
| 6756 class C { | 6741 class C { |
| 6757 static int f; | 6742 static int f; |
| 6758 } | 6743 } |
| 6759 final v = (C.f = 1); | 6744 final v = (C.f = 1); |
| 6760 '''); | 6745 '''); |
| 6761 assertUnlinkedConst(variable.initializer.bodyExpr, | 6746 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 6762 isValidConst: false, | 6747 isValidConst: false, |
| 6763 operators: [ | 6748 operators: [ |
| 6764 UnlinkedExprOperation.pushInt, | 6749 UnlinkedExprOperation.pushInt, |
| 6765 UnlinkedExprOperation.assignToRef, | 6750 UnlinkedExprOperation.assignToRef, |
| 6766 ], | 6751 ], |
| 6767 assignmentOperators: [ | 6752 assignmentOperators: [ |
| 6768 (UnlinkedExprAssignOperator.assign) | 6753 (UnlinkedExprAssignOperator.assign) |
| 6769 ], | 6754 ], |
| 6770 ints: [ | 6755 ints: [ |
| 6771 1, | 6756 1, |
| 6772 ], | 6757 ], |
| 6773 strings: [], | 6758 strings: [], |
| 6774 referenceValidators: [ | 6759 referenceValidators: [ |
| 6775 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6760 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 6776 expectedKind: ReferenceKind.unresolved, | 6761 expectedKind: ReferenceKind.unresolved, |
| 6777 prefixExpectations: [ | 6762 prefixExpectations: [ |
| 6778 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 6763 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 6779 ]) | 6764 ]) |
| 6780 ]); | 6765 ]); |
| 6781 } | 6766 } |
| 6782 | 6767 |
| 6783 test_expr_assignToRef_fieldSequence() { | 6768 test_expr_assignToRef_fieldSequence() { |
| 6784 if (skipNonConstInitializers) { | 6769 if (skipNonConstInitializers) { |
| 6785 return; | 6770 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6804 UnlinkedExprOperation.assignToRef, | 6789 UnlinkedExprOperation.assignToRef, |
| 6805 ], | 6790 ], |
| 6806 assignmentOperators: [ | 6791 assignmentOperators: [ |
| 6807 (UnlinkedExprAssignOperator.assign) | 6792 (UnlinkedExprAssignOperator.assign) |
| 6808 ], | 6793 ], |
| 6809 ints: [ | 6794 ints: [ |
| 6810 1, | 6795 1, |
| 6811 ], | 6796 ], |
| 6812 strings: [], | 6797 strings: [], |
| 6813 referenceValidators: [ | 6798 referenceValidators: [ |
| 6814 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6799 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 6815 expectedKind: ReferenceKind.unresolved, | 6800 expectedKind: ReferenceKind.unresolved, |
| 6816 prefixExpectations: [ | 6801 prefixExpectations: [ |
| 6817 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), | 6802 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), |
| 6818 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), | 6803 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), |
| 6819 new _PrefixExpectation( | 6804 new _PrefixExpectation( |
| 6820 ReferenceKind.topLevelPropertyAccessor, 'a') | 6805 ReferenceKind.topLevelPropertyAccessor, 'a') |
| 6821 ]) | 6806 ]) |
| 6822 ]); | 6807 ]); |
| 6823 } | 6808 } |
| 6824 | 6809 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6857 UnlinkedExprOperation.assignToRef, | 6842 UnlinkedExprOperation.assignToRef, |
| 6858 ], | 6843 ], |
| 6859 assignmentOperators: [ | 6844 assignmentOperators: [ |
| 6860 (UnlinkedExprAssignOperator.assign) | 6845 (UnlinkedExprAssignOperator.assign) |
| 6861 ], | 6846 ], |
| 6862 ints: [ | 6847 ints: [ |
| 6863 1, | 6848 1, |
| 6864 ], | 6849 ], |
| 6865 strings: [], | 6850 strings: [], |
| 6866 referenceValidators: [ | 6851 referenceValidators: [ |
| 6867 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6852 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 6868 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6853 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6869 ]); | 6854 ]); |
| 6870 } | 6855 } |
| 6871 | 6856 |
| 6872 test_expr_assignToRef_topLevelVariable_imported() { | 6857 test_expr_assignToRef_topLevelVariable_imported() { |
| 6873 if (skipNonConstInitializers) { | 6858 if (skipNonConstInitializers) { |
| 6874 return; | 6859 return; |
| 6875 } | 6860 } |
| 6876 addNamedSource( | 6861 addNamedSource( |
| 6877 '/a.dart', | 6862 '/a.dart', |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6889 UnlinkedExprOperation.assignToRef, | 6874 UnlinkedExprOperation.assignToRef, |
| 6890 ], | 6875 ], |
| 6891 assignmentOperators: [ | 6876 assignmentOperators: [ |
| 6892 (UnlinkedExprAssignOperator.assign) | 6877 (UnlinkedExprAssignOperator.assign) |
| 6893 ], | 6878 ], |
| 6894 ints: [ | 6879 ints: [ |
| 6895 1, | 6880 1, |
| 6896 ], | 6881 ], |
| 6897 strings: [], | 6882 strings: [], |
| 6898 referenceValidators: [ | 6883 referenceValidators: [ |
| 6899 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 6884 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a', |
| 6900 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6885 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6901 ]); | 6886 ]); |
| 6902 } | 6887 } |
| 6903 | 6888 |
| 6904 test_expr_assignToRef_topLevelVariable_imported_withPrefix() { | 6889 test_expr_assignToRef_topLevelVariable_imported_withPrefix() { |
| 6905 if (skipNonConstInitializers) { | 6890 if (skipNonConstInitializers) { |
| 6906 return; | 6891 return; |
| 6907 } | 6892 } |
| 6908 addNamedSource( | 6893 addNamedSource( |
| 6909 '/a.dart', | 6894 '/a.dart', |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6922 ], | 6907 ], |
| 6923 assignmentOperators: [ | 6908 assignmentOperators: [ |
| 6924 (UnlinkedExprAssignOperator.assign) | 6909 (UnlinkedExprAssignOperator.assign) |
| 6925 ], | 6910 ], |
| 6926 ints: [ | 6911 ints: [ |
| 6927 1, | 6912 1, |
| 6928 ], | 6913 ], |
| 6929 strings: [], | 6914 strings: [], |
| 6930 referenceValidators: [ | 6915 referenceValidators: [ |
| 6931 (EntityRef r) { | 6916 (EntityRef r) { |
| 6932 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 6917 return checkTypeRef(r, absUri('/a.dart'), 'a', |
| 6933 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 6918 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 6934 expectedPrefix: 'p'); | 6919 expectedPrefix: 'p'); |
| 6935 } | 6920 } |
| 6936 ]); | 6921 ]); |
| 6937 } | 6922 } |
| 6938 | 6923 |
| 6939 test_expr_cascadeSection_assignToIndex() { | 6924 test_expr_cascadeSection_assignToIndex() { |
| 6940 if (skipNonConstInitializers) { | 6925 if (skipNonConstInitializers) { |
| 6941 return; | 6926 return; |
| 6942 } | 6927 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6961 ], | 6946 ], |
| 6962 assignmentOperators: [ | 6947 assignmentOperators: [ |
| 6963 UnlinkedExprAssignOperator.assign, | 6948 UnlinkedExprAssignOperator.assign, |
| 6964 ], | 6949 ], |
| 6965 ints: [ | 6950 ints: [ |
| 6966 2, | 6951 2, |
| 6967 1 | 6952 1 |
| 6968 ], | 6953 ], |
| 6969 strings: [], | 6954 strings: [], |
| 6970 referenceValidators: [ | 6955 referenceValidators: [ |
| 6971 (EntityRef r) => checkTypeRef(r, null, null, 'items', | 6956 (EntityRef r) => checkTypeRef(r, null, 'items', |
| 6972 expectedKind: ReferenceKind.unresolved, | 6957 expectedKind: ReferenceKind.unresolved, |
| 6973 prefixExpectations: [ | 6958 prefixExpectations: [ |
| 6974 new _PrefixExpectation( | 6959 new _PrefixExpectation( |
| 6975 ReferenceKind.topLevelPropertyAccessor, 'c'), | 6960 ReferenceKind.topLevelPropertyAccessor, 'c'), |
| 6976 ]) | 6961 ]) |
| 6977 ]); | 6962 ]); |
| 6978 } | 6963 } |
| 6979 | 6964 |
| 6980 test_expr_cascadeSection_assignToProperty() { | 6965 test_expr_cascadeSection_assignToProperty() { |
| 6981 if (skipNonConstInitializers) { | 6966 if (skipNonConstInitializers) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7013 ints: [ | 6998 ints: [ |
| 7014 0, 0, // new C() | 6999 0, 0, // new C() |
| 7015 1, // f1 = 1 | 7000 1, // f1 = 1 |
| 7016 2, // f2 += 2 | 7001 2, // f2 += 2 |
| 7017 ], | 7002 ], |
| 7018 strings: [ | 7003 strings: [ |
| 7019 'f1', | 7004 'f1', |
| 7020 'f2', | 7005 'f2', |
| 7021 ], | 7006 ], |
| 7022 referenceValidators: [ | 7007 referenceValidators: [ |
| 7023 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 7008 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 7024 expectedKind: ReferenceKind.classOrEnum) | 7009 expectedKind: ReferenceKind.classOrEnum) |
| 7025 ]); | 7010 ]); |
| 7026 } | 7011 } |
| 7027 | 7012 |
| 7028 test_expr_cascadeSection_embedded() { | 7013 test_expr_cascadeSection_embedded() { |
| 7029 if (skipNonConstInitializers) { | 7014 if (skipNonConstInitializers) { |
| 7030 return; | 7015 return; |
| 7031 } | 7016 } |
| 7032 UnlinkedVariable variable = serializeVariableText(''' | 7017 UnlinkedVariable variable = serializeVariableText(''' |
| 7033 class A { | 7018 class A { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7086 2, | 7071 2, |
| 7087 3, | 7072 3, |
| 7088 ], | 7073 ], |
| 7089 strings: [ | 7074 strings: [ |
| 7090 'fa1', | 7075 'fa1', |
| 7091 'fb', | 7076 'fb', |
| 7092 'b', | 7077 'b', |
| 7093 'fa2', | 7078 'fa2', |
| 7094 ], | 7079 ], |
| 7095 referenceValidators: [ | 7080 referenceValidators: [ |
| 7096 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 7081 (EntityRef r) => checkTypeRef(r, null, 'A', |
| 7097 expectedKind: ReferenceKind.classOrEnum), | 7082 expectedKind: ReferenceKind.classOrEnum), |
| 7098 (EntityRef r) => checkTypeRef(r, null, null, 'B', | 7083 (EntityRef r) => checkTypeRef(r, null, 'B', |
| 7099 expectedKind: ReferenceKind.classOrEnum), | 7084 expectedKind: ReferenceKind.classOrEnum), |
| 7100 ]); | 7085 ]); |
| 7101 } | 7086 } |
| 7102 | 7087 |
| 7103 test_expr_cascadeSection_invokeMethod() { | 7088 test_expr_cascadeSection_invokeMethod() { |
| 7104 if (skipNonConstInitializers) { | 7089 if (skipNonConstInitializers) { |
| 7105 return; | 7090 return; |
| 7106 } | 7091 } |
| 7107 UnlinkedVariable variable = serializeVariableText(''' | 7092 UnlinkedVariable variable = serializeVariableText(''' |
| 7108 class A { | 7093 class A { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 7135 5, 0, 1, 0, // m(5) | 7120 5, 0, 1, 0, // m(5) |
| 7136 0, 0, 0, // abs() | 7121 0, 0, 0, // abs() |
| 7137 6, 0, 1, 0, // m(5) | 7122 6, 0, 1, 0, // m(5) |
| 7138 ], | 7123 ], |
| 7139 strings: [ | 7124 strings: [ |
| 7140 'm', | 7125 'm', |
| 7141 'abs', | 7126 'abs', |
| 7142 'm', | 7127 'm', |
| 7143 ], | 7128 ], |
| 7144 referenceValidators: [ | 7129 referenceValidators: [ |
| 7145 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 7130 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 7146 expectedKind: ReferenceKind.topLevelPropertyAccessor), | 7131 expectedKind: ReferenceKind.topLevelPropertyAccessor), |
| 7147 ]); | 7132 ]); |
| 7148 } | 7133 } |
| 7149 | 7134 |
| 7150 test_expr_extractIndex_ofClassField() { | 7135 test_expr_extractIndex_ofClassField() { |
| 7151 if (skipNonConstInitializers) { | 7136 if (skipNonConstInitializers) { |
| 7152 return; | 7137 return; |
| 7153 } | 7138 } |
| 7154 UnlinkedVariable variable = serializeVariableText(''' | 7139 UnlinkedVariable variable = serializeVariableText(''' |
| 7155 class C { | 7140 class C { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7167 ], | 7152 ], |
| 7168 ints: [ | 7153 ints: [ |
| 7169 0, | 7154 0, |
| 7170 0, | 7155 0, |
| 7171 5 | 7156 5 |
| 7172 ], | 7157 ], |
| 7173 strings: [ | 7158 strings: [ |
| 7174 'items' | 7159 'items' |
| 7175 ], | 7160 ], |
| 7176 referenceValidators: [ | 7161 referenceValidators: [ |
| 7177 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 7162 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 7178 expectedKind: ReferenceKind.classOrEnum) | 7163 expectedKind: ReferenceKind.classOrEnum) |
| 7179 ]); | 7164 ]); |
| 7180 } | 7165 } |
| 7181 | 7166 |
| 7182 test_expr_extractProperty_ofInvokeConstructor() { | 7167 test_expr_extractProperty_ofInvokeConstructor() { |
| 7183 if (skipNonConstInitializers) { | 7168 if (skipNonConstInitializers) { |
| 7184 return; | 7169 return; |
| 7185 } | 7170 } |
| 7186 UnlinkedVariable variable = serializeVariableText(''' | 7171 UnlinkedVariable variable = serializeVariableText(''' |
| 7187 class C { | 7172 class C { |
| 7188 int f = 0; | 7173 int f = 0; |
| 7189 } | 7174 } |
| 7190 final v = new C().f; | 7175 final v = new C().f; |
| 7191 '''); | 7176 '''); |
| 7192 assertUnlinkedConst(variable.initializer.bodyExpr, | 7177 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7193 isValidConst: false, | 7178 isValidConst: false, |
| 7194 operators: [ | 7179 operators: [ |
| 7195 UnlinkedExprOperation.invokeConstructor, | 7180 UnlinkedExprOperation.invokeConstructor, |
| 7196 UnlinkedExprOperation.extractProperty, | 7181 UnlinkedExprOperation.extractProperty, |
| 7197 ], | 7182 ], |
| 7198 ints: [ | 7183 ints: [ |
| 7199 0, | 7184 0, |
| 7200 0 | 7185 0 |
| 7201 ], | 7186 ], |
| 7202 strings: [ | 7187 strings: [ |
| 7203 'f' | 7188 'f' |
| 7204 ], | 7189 ], |
| 7205 referenceValidators: [ | 7190 referenceValidators: [ |
| 7206 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 7191 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 7207 expectedKind: ReferenceKind.classOrEnum) | 7192 expectedKind: ReferenceKind.classOrEnum) |
| 7208 ]); | 7193 ]); |
| 7209 } | 7194 } |
| 7210 | 7195 |
| 7211 test_expr_functionExpression_asArgument() { | 7196 test_expr_functionExpression_asArgument() { |
| 7212 if (skipNonConstInitializers) { | 7197 if (skipNonConstInitializers) { |
| 7213 return; | 7198 return; |
| 7214 } | 7199 } |
| 7215 UnlinkedVariable variable = serializeVariableText(''' | 7200 UnlinkedVariable variable = serializeVariableText(''' |
| 7216 final v = foo(5, () => 42); | 7201 final v = foo(5, () => 42); |
| 7217 foo(a, b) {} | 7202 foo(a, b) {} |
| 7218 '''); | 7203 '''); |
| 7219 assertUnlinkedConst(variable.initializer.bodyExpr, | 7204 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7220 isValidConst: false, | 7205 isValidConst: false, |
| 7221 operators: [ | 7206 operators: [ |
| 7222 UnlinkedExprOperation.pushInt, | 7207 UnlinkedExprOperation.pushInt, |
| 7223 UnlinkedExprOperation.pushLocalFunctionReference, | 7208 UnlinkedExprOperation.pushLocalFunctionReference, |
| 7224 UnlinkedExprOperation.invokeMethodRef | 7209 UnlinkedExprOperation.invokeMethodRef |
| 7225 ], | 7210 ], |
| 7226 ints: [ | 7211 ints: [ |
| 7227 5, | 7212 5, |
| 7228 0, | 7213 0, |
| 7229 0, | 7214 0, |
| 7230 0, | 7215 0, |
| 7231 2, | 7216 2, |
| 7232 0 | 7217 0 |
| 7233 ], | 7218 ], |
| 7234 referenceValidators: [ | 7219 referenceValidators: [ |
| 7235 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 7220 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 7236 expectedKind: ReferenceKind.topLevelFunction) | 7221 expectedKind: ReferenceKind.topLevelFunction) |
| 7237 ]); | 7222 ]); |
| 7238 } | 7223 } |
| 7239 | 7224 |
| 7240 test_expr_functionExpression_asArgument_multiple() { | 7225 test_expr_functionExpression_asArgument_multiple() { |
| 7241 if (skipNonConstInitializers) { | 7226 if (skipNonConstInitializers) { |
| 7242 return; | 7227 return; |
| 7243 } | 7228 } |
| 7244 UnlinkedVariable variable = serializeVariableText(''' | 7229 UnlinkedVariable variable = serializeVariableText(''' |
| 7245 final v = foo(5, () => 42, () => 43); | 7230 final v = foo(5, () => 42, () => 43); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7257 5, | 7242 5, |
| 7258 0, | 7243 0, |
| 7259 0, | 7244 0, |
| 7260 0, | 7245 0, |
| 7261 1, | 7246 1, |
| 7262 0, | 7247 0, |
| 7263 3, | 7248 3, |
| 7264 0 | 7249 0 |
| 7265 ], | 7250 ], |
| 7266 referenceValidators: [ | 7251 referenceValidators: [ |
| 7267 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 7252 (EntityRef r) => checkTypeRef(r, null, 'foo', |
| 7268 expectedKind: ReferenceKind.topLevelFunction) | 7253 expectedKind: ReferenceKind.topLevelFunction) |
| 7269 ]); | 7254 ]); |
| 7270 } | 7255 } |
| 7271 | 7256 |
| 7272 test_expr_functionExpression_withBlockBody() { | 7257 test_expr_functionExpression_withBlockBody() { |
| 7273 if (skipNonConstInitializers) { | 7258 if (skipNonConstInitializers) { |
| 7274 return; | 7259 return; |
| 7275 } | 7260 } |
| 7276 UnlinkedVariable variable = serializeVariableText(''' | 7261 UnlinkedVariable variable = serializeVariableText(''' |
| 7277 final v = () { return 42; }; | 7262 final v = () { return 42; }; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7416 UnlinkedExprOperation.conditional, | 7401 UnlinkedExprOperation.conditional, |
| 7417 ], | 7402 ], |
| 7418 strings: [ | 7403 strings: [ |
| 7419 'b' | 7404 'b' |
| 7420 ], | 7405 ], |
| 7421 ints: [ | 7406 ints: [ |
| 7422 0, | 7407 0, |
| 7423 0 | 7408 0 |
| 7424 ], | 7409 ], |
| 7425 referenceValidators: [ | 7410 referenceValidators: [ |
| 7426 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 7411 (EntityRef r) => checkTypeRef(r, null, 'x', |
| 7427 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 7412 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 7428 ]); | 7413 ]); |
| 7429 } | 7414 } |
| 7430 | 7415 |
| 7431 test_expr_inClosure_refersToParam_prefixedIdentifier() { | 7416 test_expr_inClosure_refersToParam_prefixedIdentifier() { |
| 7432 if (skipNonConstInitializers) { | 7417 if (skipNonConstInitializers) { |
| 7433 return; | 7418 return; |
| 7434 } | 7419 } |
| 7435 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y;'); | 7420 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y;'); |
| 7436 assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7421 assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7549 2, | 7534 2, |
| 7550 1, | 7535 1, |
| 7551 0 | 7536 0 |
| 7552 ], | 7537 ], |
| 7553 strings: [ | 7538 strings: [ |
| 7554 'b', | 7539 'b', |
| 7555 'c', | 7540 'c', |
| 7556 'm' | 7541 'm' |
| 7557 ], | 7542 ], |
| 7558 referenceValidators: [ | 7543 referenceValidators: [ |
| 7559 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 7544 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 7560 expectedKind: ReferenceKind.classOrEnum) | 7545 expectedKind: ReferenceKind.classOrEnum) |
| 7561 ]); | 7546 ]); |
| 7562 } | 7547 } |
| 7563 | 7548 |
| 7564 test_expr_invokeMethod_withTypeParameters() { | 7549 test_expr_invokeMethod_withTypeParameters() { |
| 7565 if (skipNonConstInitializers) { | 7550 if (skipNonConstInitializers) { |
| 7566 return; | 7551 return; |
| 7567 } | 7552 } |
| 7568 UnlinkedVariable variable = serializeVariableText(''' | 7553 UnlinkedVariable variable = serializeVariableText(''' |
| 7569 class C { | 7554 class C { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7581 0, | 7566 0, |
| 7582 0, | 7567 0, |
| 7583 0, | 7568 0, |
| 7584 0, | 7569 0, |
| 7585 2 | 7570 2 |
| 7586 ], | 7571 ], |
| 7587 strings: [ | 7572 strings: [ |
| 7588 'f' | 7573 'f' |
| 7589 ], | 7574 ], |
| 7590 referenceValidators: [ | 7575 referenceValidators: [ |
| 7591 (EntityRef r) => checkTypeRef(r, null, null, 'C'), | 7576 (EntityRef r) => checkTypeRef(r, null, 'C'), |
| 7592 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'), | 7577 (EntityRef r) => checkTypeRef(r, 'dart:core', 'int'), |
| 7593 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String') | 7578 (EntityRef r) => checkTypeRef(r, 'dart:core', 'String') |
| 7594 ]); | 7579 ]); |
| 7595 } | 7580 } |
| 7596 | 7581 |
| 7597 test_expr_invokeMethodRef_instance() { | 7582 test_expr_invokeMethodRef_instance() { |
| 7598 if (skipNonConstInitializers) { | 7583 if (skipNonConstInitializers) { |
| 7599 return; | 7584 return; |
| 7600 } | 7585 } |
| 7601 UnlinkedVariable variable = serializeVariableText(''' | 7586 UnlinkedVariable variable = serializeVariableText(''' |
| 7602 class A { | 7587 class A { |
| 7603 B b; | 7588 B b; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7620 ], | 7605 ], |
| 7621 ints: [ | 7606 ints: [ |
| 7622 10, | 7607 10, |
| 7623 20, | 7608 20, |
| 7624 0, | 7609 0, |
| 7625 2, | 7610 2, |
| 7626 0 | 7611 0 |
| 7627 ], | 7612 ], |
| 7628 strings: [], | 7613 strings: [], |
| 7629 referenceValidators: [ | 7614 referenceValidators: [ |
| 7630 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 7615 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 7631 expectedKind: ReferenceKind.unresolved, | 7616 expectedKind: ReferenceKind.unresolved, |
| 7632 prefixExpectations: [ | 7617 prefixExpectations: [ |
| 7633 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), | 7618 new _PrefixExpectation(ReferenceKind.unresolved, 'c'), |
| 7634 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), | 7619 new _PrefixExpectation(ReferenceKind.unresolved, 'b'), |
| 7635 new _PrefixExpectation( | 7620 new _PrefixExpectation( |
| 7636 ReferenceKind.topLevelPropertyAccessor, 'a') | 7621 ReferenceKind.topLevelPropertyAccessor, 'a') |
| 7637 ]) | 7622 ]) |
| 7638 ]); | 7623 ]); |
| 7639 } | 7624 } |
| 7640 | 7625 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7658 operators: [ | 7643 operators: [ |
| 7659 UnlinkedExprOperation.invokeMethodRef, | 7644 UnlinkedExprOperation.invokeMethodRef, |
| 7660 ], | 7645 ], |
| 7661 ints: [ | 7646 ints: [ |
| 7662 0, | 7647 0, |
| 7663 0, | 7648 0, |
| 7664 0 | 7649 0 |
| 7665 ], | 7650 ], |
| 7666 strings: [], | 7651 strings: [], |
| 7667 referenceValidators: [ | 7652 referenceValidators: [ |
| 7668 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 7653 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 7669 expectedKind: ReferenceKind.method, | 7654 expectedKind: ReferenceKind.method, |
| 7670 prefixExpectations: [ | 7655 prefixExpectations: [ |
| 7671 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 7656 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 7672 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 7657 absoluteUri: absUri('/a.dart')), |
| 7673 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 7658 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 7674 ]) | 7659 ]) |
| 7675 ]); | 7660 ]); |
| 7676 } | 7661 } |
| 7677 | 7662 |
| 7678 test_expr_invokeMethodRef_with_reference_arg() { | 7663 test_expr_invokeMethodRef_with_reference_arg() { |
| 7679 if (skipNonConstInitializers) { | 7664 if (skipNonConstInitializers) { |
| 7680 return; | 7665 return; |
| 7681 } | 7666 } |
| 7682 UnlinkedVariable variable = serializeVariableText(''' | 7667 UnlinkedVariable variable = serializeVariableText(''' |
| 7683 f(x) => null; | 7668 f(x) => null; |
| 7684 final u = null; | 7669 final u = null; |
| 7685 final v = f(u); | 7670 final v = f(u); |
| 7686 '''); | 7671 '''); |
| 7687 assertUnlinkedConst(variable.initializer.bodyExpr, | 7672 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7688 isValidConst: false, | 7673 isValidConst: false, |
| 7689 operators: [ | 7674 operators: [ |
| 7690 UnlinkedExprOperation.pushReference, | 7675 UnlinkedExprOperation.pushReference, |
| 7691 UnlinkedExprOperation.invokeMethodRef | 7676 UnlinkedExprOperation.invokeMethodRef |
| 7692 ], | 7677 ], |
| 7693 ints: [ | 7678 ints: [ |
| 7694 0, | 7679 0, |
| 7695 1, | 7680 1, |
| 7696 0 | 7681 0 |
| 7697 ], | 7682 ], |
| 7698 referenceValidators: [ | 7683 referenceValidators: [ |
| 7699 (EntityRef r) => checkTypeRef(r, null, null, 'u', | 7684 (EntityRef r) => checkTypeRef(r, null, 'u', |
| 7700 expectedKind: ReferenceKind.topLevelPropertyAccessor), | 7685 expectedKind: ReferenceKind.topLevelPropertyAccessor), |
| 7701 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 7686 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 7702 expectedKind: ReferenceKind.topLevelFunction) | 7687 expectedKind: ReferenceKind.topLevelFunction) |
| 7703 ]); | 7688 ]); |
| 7704 } | 7689 } |
| 7705 | 7690 |
| 7706 test_expr_invokeMethodRef_withTypeParameters() { | 7691 test_expr_invokeMethodRef_withTypeParameters() { |
| 7707 if (skipNonConstInitializers) { | 7692 if (skipNonConstInitializers) { |
| 7708 return; | 7693 return; |
| 7709 } | 7694 } |
| 7710 UnlinkedVariable variable = serializeVariableText(''' | 7695 UnlinkedVariable variable = serializeVariableText(''' |
| 7711 f<T, U>() => null; | 7696 f<T, U>() => null; |
| 7712 final v = f<int, String>(); | 7697 final v = f<int, String>(); |
| 7713 '''); | 7698 '''); |
| 7714 assertUnlinkedConst(variable.initializer.bodyExpr, | 7699 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7715 isValidConst: false, | 7700 isValidConst: false, |
| 7716 operators: [ | 7701 operators: [ |
| 7717 UnlinkedExprOperation.invokeMethodRef | 7702 UnlinkedExprOperation.invokeMethodRef |
| 7718 ], | 7703 ], |
| 7719 ints: [ | 7704 ints: [ |
| 7720 0, | 7705 0, |
| 7721 0, | 7706 0, |
| 7722 2 | 7707 2 |
| 7723 ], | 7708 ], |
| 7724 referenceValidators: [ | 7709 referenceValidators: [ |
| 7725 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 7710 (EntityRef r) => checkTypeRef(r, null, 'f', |
| 7726 expectedKind: ReferenceKind.topLevelFunction, | 7711 expectedKind: ReferenceKind.topLevelFunction, |
| 7727 numTypeParameters: 2), | 7712 numTypeParameters: 2), |
| 7728 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int'), | 7713 (EntityRef r) => checkTypeRef(r, 'dart:core', 'int'), |
| 7729 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String') | 7714 (EntityRef r) => checkTypeRef(r, 'dart:core', 'String') |
| 7730 ]); | 7715 ]); |
| 7731 } | 7716 } |
| 7732 | 7717 |
| 7733 test_expr_super() { | 7718 test_expr_super() { |
| 7734 if (skipNonConstInitializers) { | 7719 if (skipNonConstInitializers) { |
| 7735 return; | 7720 return; |
| 7736 } | 7721 } |
| 7737 UnlinkedVariable variable = serializeVariableText(''' | 7722 UnlinkedVariable variable = serializeVariableText(''' |
| 7738 final v = super; | 7723 final v = super; |
| 7739 '''); | 7724 '''); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7785 assertUnlinkedConst(variable.initializer.bodyExpr, | 7770 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7786 isValidConst: false, | 7771 isValidConst: false, |
| 7787 operators: [ | 7772 operators: [ |
| 7788 UnlinkedExprOperation.pushInt, | 7773 UnlinkedExprOperation.pushInt, |
| 7789 UnlinkedExprOperation.typeCast, | 7774 UnlinkedExprOperation.typeCast, |
| 7790 ], | 7775 ], |
| 7791 ints: [ | 7776 ints: [ |
| 7792 42 | 7777 42 |
| 7793 ], | 7778 ], |
| 7794 referenceValidators: [ | 7779 referenceValidators: [ |
| 7795 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 7780 (EntityRef r) => checkTypeRef(r, 'dart:core', 'num', |
| 7796 expectedKind: ReferenceKind.classOrEnum) | 7781 expectedKind: ReferenceKind.classOrEnum) |
| 7797 ]); | 7782 ]); |
| 7798 } | 7783 } |
| 7799 | 7784 |
| 7800 test_expr_typeCheck() { | 7785 test_expr_typeCheck() { |
| 7801 if (skipNonConstInitializers) { | 7786 if (skipNonConstInitializers) { |
| 7802 return; | 7787 return; |
| 7803 } | 7788 } |
| 7804 UnlinkedVariable variable = serializeVariableText(''' | 7789 UnlinkedVariable variable = serializeVariableText(''' |
| 7805 final v = 42 is num; | 7790 final v = 42 is num; |
| 7806 '''); | 7791 '''); |
| 7807 assertUnlinkedConst(variable.initializer.bodyExpr, | 7792 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7808 isValidConst: false, | 7793 isValidConst: false, |
| 7809 operators: [ | 7794 operators: [ |
| 7810 UnlinkedExprOperation.pushInt, | 7795 UnlinkedExprOperation.pushInt, |
| 7811 UnlinkedExprOperation.typeCheck, | 7796 UnlinkedExprOperation.typeCheck, |
| 7812 ], | 7797 ], |
| 7813 ints: [ | 7798 ints: [ |
| 7814 42 | 7799 42 |
| 7815 ], | 7800 ], |
| 7816 referenceValidators: [ | 7801 referenceValidators: [ |
| 7817 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 7802 (EntityRef r) => checkTypeRef(r, 'dart:core', 'num', |
| 7818 expectedKind: ReferenceKind.classOrEnum) | 7803 expectedKind: ReferenceKind.classOrEnum) |
| 7819 ]); | 7804 ]); |
| 7820 } | 7805 } |
| 7821 | 7806 |
| 7822 test_field() { | 7807 test_field() { |
| 7823 UnlinkedClass cls = serializeClassText('class C { int i; }'); | 7808 UnlinkedClass cls = serializeClassText('class C { int i; }'); |
| 7824 UnlinkedVariable variable = findVariable('i', variables: cls.fields); | 7809 UnlinkedVariable variable = findVariable('i', variables: cls.fields); |
| 7825 expect(variable, isNotNull); | 7810 expect(variable, isNotNull); |
| 7826 expect(variable.isConst, isFalse); | 7811 expect(variable.isConst, isFalse); |
| 7827 expect(variable.isStatic, isFalse); | 7812 expect(variable.isStatic, isFalse); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7879 UnlinkedExprOperation.add, | 7864 UnlinkedExprOperation.add, |
| 7880 ], | 7865 ], |
| 7881 ints: [ | 7866 ints: [ |
| 7882 1, | 7867 1, |
| 7883 0, | 7868 0, |
| 7884 0, | 7869 0, |
| 7885 0 | 7870 0 |
| 7886 ], | 7871 ], |
| 7887 strings: [], | 7872 strings: [], |
| 7888 referenceValidators: [ | 7873 referenceValidators: [ |
| 7889 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 7874 (EntityRef r) => checkTypeRef(r, null, 'm', |
| 7890 expectedKind: ReferenceKind.method, | 7875 expectedKind: ReferenceKind.method, |
| 7891 prefixExpectations: [ | 7876 prefixExpectations: [ |
| 7892 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 7877 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 7893 ]) | 7878 ]) |
| 7894 ]); | 7879 ]); |
| 7895 } | 7880 } |
| 7896 | 7881 |
| 7897 test_field_final_typeParameter() { | 7882 test_field_final_typeParameter() { |
| 7898 UnlinkedVariable variable = serializeClassText(r''' | 7883 UnlinkedVariable variable = serializeClassText(r''' |
| 7899 class C<T> { | 7884 class C<T> { |
| 7900 final f = <T>[]; | 7885 final f = <T>[]; |
| 7901 }''').fields[0]; | 7886 }''').fields[0]; |
| 7902 expect(variable.isFinal, isTrue); | 7887 expect(variable.isFinal, isTrue); |
| 7903 assertUnlinkedConst(variable.initializer.bodyExpr, | 7888 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7904 operators: [UnlinkedExprOperation.makeTypedList], | 7889 operators: [UnlinkedExprOperation.makeTypedList], |
| 7905 ints: [0], | 7890 ints: [0], |
| 7906 referenceValidators: [(EntityRef r) => checkParamTypeRef(r, 1)]); | 7891 referenceValidators: [(EntityRef r) => checkParamTypeRef(r, 1)]); |
| 7907 } | 7892 } |
| 7908 | 7893 |
| 7909 test_field_formal_param_inferred_type_explicit() { | 7894 test_field_formal_param_inferred_type_explicit() { |
| 7910 UnlinkedClass cls = serializeClassText( | 7895 UnlinkedClass cls = serializeClassText( |
| 7911 'class C extends D { var v; C(int this.v); }' | 7896 'class C extends D { var v; C(int this.v); }' |
| 7912 ' abstract class D { num get v; }', | 7897 ' abstract class D { num get v; }', |
| 7913 className: 'C'); | 7898 className: 'C'); |
| 7914 checkInferredTypeSlot( | 7899 checkInferredTypeSlot(cls.fields[0].inferredTypeSlot, 'dart:core', 'num'); |
| 7915 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'num'); | |
| 7916 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor); | 7900 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor); |
| 7917 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); | 7901 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); |
| 7918 } | 7902 } |
| 7919 | 7903 |
| 7920 test_field_formal_param_inferred_type_implicit() { | 7904 test_field_formal_param_inferred_type_implicit() { |
| 7921 // Both the field `v` and the constructor argument `this.v` will have their | 7905 // Both the field `v` and the constructor argument `this.v` will have their |
| 7922 // type inferred by strong mode. But only the field should have its | 7906 // type inferred by strong mode. But only the field should have its |
| 7923 // inferred type stored in the summary, since the standard rules for field | 7907 // inferred type stored in the summary, since the standard rules for field |
| 7924 // formal parameters will take care of the rest (they implicitly inherit | 7908 // formal parameters will take care of the rest (they implicitly inherit |
| 7925 // the type of the associated field). | 7909 // the type of the associated field). |
| 7926 UnlinkedClass cls = serializeClassText( | 7910 UnlinkedClass cls = serializeClassText( |
| 7927 'class C extends D { var v; C(this.v); }' | 7911 'class C extends D { var v; C(this.v); }' |
| 7928 ' abstract class D { int get v; }', | 7912 ' abstract class D { int get v; }', |
| 7929 className: 'C'); | 7913 className: 'C'); |
| 7930 checkInferredTypeSlot( | 7914 checkInferredTypeSlot(cls.fields[0].inferredTypeSlot, 'dart:core', 'int'); |
| 7931 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | |
| 7932 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor); | 7915 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor); |
| 7933 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); | 7916 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); |
| 7934 } | 7917 } |
| 7935 | 7918 |
| 7936 test_field_inferred_type_nonstatic_explicit_initialized() { | 7919 test_field_inferred_type_nonstatic_explicit_initialized() { |
| 7937 UnlinkedVariable v = serializeClassText('class C { num v = 0; }').fields[0]; | 7920 UnlinkedVariable v = serializeClassText('class C { num v = 0; }').fields[0]; |
| 7938 expect(v.inferredTypeSlot, 0); | 7921 expect(v.inferredTypeSlot, 0); |
| 7939 } | 7922 } |
| 7940 | 7923 |
| 7941 test_field_inferred_type_nonstatic_explicit_uninitialized() { | 7924 test_field_inferred_type_nonstatic_explicit_uninitialized() { |
| 7942 UnlinkedVariable v = serializeClassText( | 7925 UnlinkedVariable v = serializeClassText( |
| 7943 'class C extends D { num v; } abstract class D { int get v; }', | 7926 'class C extends D { num v; } abstract class D { int get v; }', |
| 7944 className: 'C', | 7927 className: 'C', |
| 7945 allowErrors: true) | 7928 allowErrors: true) |
| 7946 .fields[0]; | 7929 .fields[0]; |
| 7947 expect(v.inferredTypeSlot, 0); | 7930 expect(v.inferredTypeSlot, 0); |
| 7948 } | 7931 } |
| 7949 | 7932 |
| 7950 test_field_inferred_type_nonstatic_implicit_initialized() { | 7933 test_field_inferred_type_nonstatic_implicit_initialized() { |
| 7951 UnlinkedVariable v = serializeClassText('class C { var v = 0; }').fields[0]; | 7934 UnlinkedVariable v = serializeClassText('class C { var v = 0; }').fields[0]; |
| 7952 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | 7935 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'int'); |
| 7953 } | 7936 } |
| 7954 | 7937 |
| 7955 test_field_inferred_type_nonstatic_implicit_uninitialized() { | 7938 test_field_inferred_type_nonstatic_implicit_uninitialized() { |
| 7956 UnlinkedVariable v = serializeClassText( | 7939 UnlinkedVariable v = serializeClassText( |
| 7957 'class C extends D { var v; } abstract class D { int get v; }', | 7940 'class C extends D { var v; } abstract class D { int get v; }', |
| 7958 className: 'C') | 7941 className: 'C') |
| 7959 .fields[0]; | 7942 .fields[0]; |
| 7960 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | 7943 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'int'); |
| 7961 } | 7944 } |
| 7962 | 7945 |
| 7963 test_field_inferred_type_static_explicit_initialized() { | 7946 test_field_inferred_type_static_explicit_initialized() { |
| 7964 UnlinkedVariable v = | 7947 UnlinkedVariable v = |
| 7965 serializeClassText('class C { static int v = 0; }').fields[0]; | 7948 serializeClassText('class C { static int v = 0; }').fields[0]; |
| 7966 expect(v.inferredTypeSlot, 0); | 7949 expect(v.inferredTypeSlot, 0); |
| 7967 } | 7950 } |
| 7968 | 7951 |
| 7969 test_field_inferred_type_static_implicit_initialized() { | 7952 test_field_inferred_type_static_implicit_initialized() { |
| 7970 UnlinkedVariable v = | 7953 UnlinkedVariable v = |
| 7971 serializeClassText('class C { static var v = 0; }').fields[0]; | 7954 serializeClassText('class C { static var v = 0; }').fields[0]; |
| 7972 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | 7955 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'int'); |
| 7973 } | 7956 } |
| 7974 | 7957 |
| 7975 test_field_inferred_type_static_implicit_uninitialized() { | 7958 test_field_inferred_type_static_implicit_uninitialized() { |
| 7976 UnlinkedVariable v = | 7959 UnlinkedVariable v = |
| 7977 serializeClassText('class C { static var v; }').fields[0]; | 7960 serializeClassText('class C { static var v; }').fields[0]; |
| 7978 expect(v.inferredTypeSlot, 0); | 7961 expect(v.inferredTypeSlot, 0); |
| 7979 } | 7962 } |
| 7980 | 7963 |
| 7981 test_field_static() { | 7964 test_field_static() { |
| 7982 UnlinkedVariable variable = | 7965 UnlinkedVariable variable = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8014 UnlinkedVariable variable = | 7997 UnlinkedVariable variable = |
| 8015 serializeClassText('class C { var x = 0; }').fields[0]; | 7998 serializeClassText('class C { var x = 0; }').fields[0]; |
| 8016 expect(variable.initializer.bodyExpr, isNotNull); | 7999 expect(variable.initializer.bodyExpr, isNotNull); |
| 8017 } | 8000 } |
| 8018 | 8001 |
| 8019 test_fully_linked_references_follow_other_references() { | 8002 test_fully_linked_references_follow_other_references() { |
| 8020 if (!strongMode || skipFullyLinkedData) { | 8003 if (!strongMode || skipFullyLinkedData) { |
| 8021 return; | 8004 return; |
| 8022 } | 8005 } |
| 8023 serializeLibraryText('final x = 0; String y;'); | 8006 serializeLibraryText('final x = 0; String y;'); |
| 8024 checkLinkedTypeSlot(unlinkedUnits[0].variables[0].inferredTypeSlot, | 8007 checkLinkedTypeSlot( |
| 8025 'dart:core', 'dart:core', 'int'); | 8008 unlinkedUnits[0].variables[0].inferredTypeSlot, 'dart:core', 'int'); |
| 8026 checkTypeRef( | 8009 checkTypeRef(unlinkedUnits[0].variables[1].type, 'dart:core', 'String'); |
| 8027 unlinkedUnits[0].variables[1].type, 'dart:core', 'dart:core', 'String'); | |
| 8028 // Even though the definition of y follows the definition of x, the linked | 8010 // Even though the definition of y follows the definition of x, the linked |
| 8029 // type reference for x should use a higher numbered reference than the | 8011 // type reference for x should use a higher numbered reference than the |
| 8030 // unlinked type reference for y. | 8012 // unlinked type reference for y. |
| 8031 EntityRef propagatedType = | 8013 EntityRef propagatedType = |
| 8032 getTypeRefForSlot(unlinkedUnits[0].variables[0].inferredTypeSlot); | 8014 getTypeRefForSlot(unlinkedUnits[0].variables[0].inferredTypeSlot); |
| 8033 expect(unlinkedUnits[0].variables[1].type.reference, | 8015 expect(unlinkedUnits[0].variables[1].type.reference, |
| 8034 lessThan(propagatedType.reference)); | 8016 lessThan(propagatedType.reference)); |
| 8035 } | 8017 } |
| 8036 | 8018 |
| 8037 test_function_documented() { | 8019 test_function_documented() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8088 allowErrors: true) | 8070 allowErrors: true) |
| 8089 .executables[0]; | 8071 .executables[0]; |
| 8090 expect(f.inferredReturnTypeSlot, 0); | 8072 expect(f.inferredReturnTypeSlot, 0); |
| 8091 } | 8073 } |
| 8092 | 8074 |
| 8093 test_getter_inferred_type_nonstatic_implicit_return() { | 8075 test_getter_inferred_type_nonstatic_implicit_return() { |
| 8094 UnlinkedExecutable f = serializeClassText( | 8076 UnlinkedExecutable f = serializeClassText( |
| 8095 'class C extends D { get f => null; } abstract class D { int get f;
}', | 8077 'class C extends D { get f => null; } abstract class D { int get f;
}', |
| 8096 className: 'C') | 8078 className: 'C') |
| 8097 .executables[0]; | 8079 .executables[0]; |
| 8098 checkInferredTypeSlot( | 8080 checkInferredTypeSlot(f.inferredReturnTypeSlot, 'dart:core', 'int'); |
| 8099 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int'); | |
| 8100 } | 8081 } |
| 8101 | 8082 |
| 8102 test_getter_inferred_type_static_implicit_return() { | 8083 test_getter_inferred_type_static_implicit_return() { |
| 8103 UnlinkedExecutable f = serializeClassText( | 8084 UnlinkedExecutable f = serializeClassText( |
| 8104 'class C extends D { static get f => null; }' | 8085 'class C extends D { static get f => null; }' |
| 8105 ' class D { static int get f => null; }', | 8086 ' class D { static int get f => null; }', |
| 8106 className: 'C') | 8087 className: 'C') |
| 8107 .executables[0]; | 8088 .executables[0]; |
| 8108 expect(f.inferredReturnTypeSlot, 0); | 8089 expect(f.inferredReturnTypeSlot, 0); |
| 8109 } | 8090 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8152 test_import_deferred() { | 8133 test_import_deferred() { |
| 8153 serializeLibraryText( | 8134 serializeLibraryText( |
| 8154 'import "dart:async" deferred as a; main() { print(a.Future); }'); | 8135 'import "dart:async" deferred as a; main() { print(a.Future); }'); |
| 8155 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue); | 8136 expect(unlinkedUnits[0].imports[0].isDeferred, isTrue); |
| 8156 } | 8137 } |
| 8157 | 8138 |
| 8158 test_import_dependency() { | 8139 test_import_dependency() { |
| 8159 serializeLibraryText('import "dart:async"; Future x;'); | 8140 serializeLibraryText('import "dart:async"; Future x;'); |
| 8160 // Second import is the implicit import of dart:core | 8141 // Second import is the implicit import of dart:core |
| 8161 expect(unlinkedUnits[0].imports, hasLength(2)); | 8142 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 8162 checkDependency(linked.importDependencies[0], 'dart:async', 'dart:async'); | 8143 checkDependency(linked.importDependencies[0], 'dart:async'); |
| 8163 } | 8144 } |
| 8164 | 8145 |
| 8165 test_import_explicit() { | 8146 test_import_explicit() { |
| 8166 serializeLibraryText('import "dart:core"; int i;'); | 8147 serializeLibraryText('import "dart:core"; int i;'); |
| 8167 expect(unlinkedUnits[0].imports, hasLength(1)); | 8148 expect(unlinkedUnits[0].imports, hasLength(1)); |
| 8168 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); | 8149 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); |
| 8169 } | 8150 } |
| 8170 | 8151 |
| 8171 test_import_hide_order() { | 8152 test_import_hide_order() { |
| 8172 serializeLibraryText( | 8153 serializeLibraryText( |
| 8173 'import "dart:async" hide Future, Stream; Completer c;'); | 8154 'import "dart:async" hide Future, Stream; Completer c;'); |
| 8174 // Second import is the implicit import of dart:core | 8155 // Second import is the implicit import of dart:core |
| 8175 expect(unlinkedUnits[0].imports, hasLength(2)); | 8156 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 8176 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); | 8157 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); |
| 8177 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty); | 8158 expect(unlinkedUnits[0].imports[0].combinators[0].shows, isEmpty); |
| 8178 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2)); | 8159 expect(unlinkedUnits[0].imports[0].combinators[0].hides, hasLength(2)); |
| 8179 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); | 8160 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); |
| 8180 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); | 8161 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); |
| 8181 if (includeInformative) { | 8162 if (includeInformative) { |
| 8182 expect(unlinkedUnits[0].imports[0].combinators[0].offset, 0); | 8163 expect(unlinkedUnits[0].imports[0].combinators[0].offset, 0); |
| 8183 expect(unlinkedUnits[0].imports[0].combinators[0].end, 0); | 8164 expect(unlinkedUnits[0].imports[0].combinators[0].end, 0); |
| 8184 } | 8165 } |
| 8185 } | 8166 } |
| 8186 | 8167 |
| 8187 test_import_implicit() { | 8168 test_import_implicit() { |
| 8188 // The implicit import of dart:core is represented in the model. | 8169 // The implicit import of dart:core is represented in the model. |
| 8189 serializeLibraryText(''); | 8170 serializeLibraryText(''); |
| 8190 expect(unlinkedUnits[0].imports, hasLength(1)); | 8171 expect(unlinkedUnits[0].imports, hasLength(1)); |
| 8191 checkDependency(linked.importDependencies[0], 'dart:core', 'dart:core'); | 8172 checkDependency(linked.importDependencies[0], 'dart:core'); |
| 8192 expect(unlinkedUnits[0].imports[0].uri, isEmpty); | 8173 expect(unlinkedUnits[0].imports[0].uri, isEmpty); |
| 8193 if (includeInformative) { | 8174 if (includeInformative) { |
| 8194 expect(unlinkedUnits[0].imports[0].uriOffset, 0); | 8175 expect(unlinkedUnits[0].imports[0].uriOffset, 0); |
| 8195 expect(unlinkedUnits[0].imports[0].uriEnd, 0); | 8176 expect(unlinkedUnits[0].imports[0].uriEnd, 0); |
| 8196 } | 8177 } |
| 8197 expect(unlinkedUnits[0].imports[0].prefixReference, 0); | 8178 expect(unlinkedUnits[0].imports[0].prefixReference, 0); |
| 8198 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); | 8179 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); |
| 8199 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue); | 8180 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue); |
| 8200 } | 8181 } |
| 8201 | 8182 |
| 8202 test_import_missing() { | 8183 test_import_missing() { |
| 8203 // Unresolved imports are included since this is necessary for proper | 8184 // Unresolved imports are included since this is necessary for proper |
| 8204 // dependency tracking. | 8185 // dependency tracking. |
| 8205 allowMissingFiles = true; | 8186 allowMissingFiles = true; |
| 8206 serializeLibraryText('import "foo.dart";', allowErrors: true); | 8187 serializeLibraryText('import "foo.dart";', allowErrors: true); |
| 8207 // Second import is the implicit import of dart:core | 8188 // Second import is the implicit import of dart:core |
| 8208 expect(unlinkedUnits[0].imports, hasLength(2)); | 8189 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 8209 checkDependency( | 8190 checkDependency(linked.importDependencies[0], absUri('/foo.dart')); |
| 8210 linked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 8211 } | 8191 } |
| 8212 | 8192 |
| 8213 test_import_no_combinators() { | 8193 test_import_no_combinators() { |
| 8214 serializeLibraryText('import "dart:async"; Future x;'); | 8194 serializeLibraryText('import "dart:async"; Future x;'); |
| 8215 // Second import is the implicit import of dart:core | 8195 // Second import is the implicit import of dart:core |
| 8216 expect(unlinkedUnits[0].imports, hasLength(2)); | 8196 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 8217 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); | 8197 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); |
| 8218 } | 8198 } |
| 8219 | 8199 |
| 8220 test_import_no_flags() { | 8200 test_import_no_flags() { |
| 8221 serializeLibraryText('import "dart:async"; Future x;'); | 8201 serializeLibraryText('import "dart:async"; Future x;'); |
| 8222 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); | 8202 expect(unlinkedUnits[0].imports[0].isImplicit, isFalse); |
| 8223 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse); | 8203 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse); |
| 8224 } | 8204 } |
| 8225 | 8205 |
| 8226 test_import_non_deferred() { | 8206 test_import_non_deferred() { |
| 8227 serializeLibraryText( | 8207 serializeLibraryText( |
| 8228 'import "dart:async" as a; main() { print(a.Future); }'); | 8208 'import "dart:async" as a; main() { print(a.Future); }'); |
| 8229 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse); | 8209 expect(unlinkedUnits[0].imports[0].isDeferred, isFalse); |
| 8230 } | 8210 } |
| 8231 | 8211 |
| 8232 test_import_of_file_with_missing_part() { | 8212 test_import_of_file_with_missing_part() { |
| 8233 // Other references in foo.dart should be resolved even though foo.dart's | 8213 // Other references in foo.dart should be resolved even though foo.dart's |
| 8234 // part declaration for bar.dart refers to a non-existent file. | 8214 // part declaration for bar.dart refers to a non-existent file. |
| 8235 allowMissingFiles = true; | 8215 allowMissingFiles = true; |
| 8236 addNamedSource('/foo.dart', 'part "bar.dart"; class C {}'); | 8216 addNamedSource('/foo.dart', 'part "bar.dart"; class C {}'); |
| 8237 serializeLibraryText('import "foo.dart"; C x;'); | 8217 serializeLibraryText('import "foo.dart"; C x;'); |
| 8238 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C'); | 8218 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'C'); |
| 8239 } | 8219 } |
| 8240 | 8220 |
| 8241 test_import_of_missing_export() { | 8221 test_import_of_missing_export() { |
| 8242 // Other references in foo.dart should be resolved even though foo.dart's | 8222 // Other references in foo.dart should be resolved even though foo.dart's |
| 8243 // re-export of bar.dart refers to a non-existent file. | 8223 // re-export of bar.dart refers to a non-existent file. |
| 8244 allowMissingFiles = true; | 8224 allowMissingFiles = true; |
| 8245 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}'); | 8225 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}'); |
| 8246 serializeLibraryText('import "foo.dart"; C x;'); | 8226 serializeLibraryText('import "foo.dart"; C x;'); |
| 8247 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C'); | 8227 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'C'); |
| 8248 } | 8228 } |
| 8249 | 8229 |
| 8250 test_import_offset() { | 8230 test_import_offset() { |
| 8251 String libraryText = ' import "dart:async"; Future x;'; | 8231 String libraryText = ' import "dart:async"; Future x;'; |
| 8252 serializeLibraryText(libraryText); | 8232 serializeLibraryText(libraryText); |
| 8253 expect(unlinkedUnits[0].imports[0].offset, libraryText.indexOf('import')); | 8233 expect(unlinkedUnits[0].imports[0].offset, libraryText.indexOf('import')); |
| 8254 expect(unlinkedUnits[0].imports[0].uriOffset, | 8234 expect(unlinkedUnits[0].imports[0].uriOffset, |
| 8255 libraryText.indexOf('"dart:async"')); | 8235 libraryText.indexOf('"dart:async"')); |
| 8256 expect(unlinkedUnits[0].imports[0].uriEnd, libraryText.indexOf('; Future')); | 8236 expect(unlinkedUnits[0].imports[0].uriEnd, libraryText.indexOf('; Future')); |
| 8257 } | 8237 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8275 test_import_prefix_not_in_public_namespace() { | 8255 test_import_prefix_not_in_public_namespace() { |
| 8276 serializeLibraryText('import "dart:async" as a; a.Future v;'); | 8256 serializeLibraryText('import "dart:async" as a; a.Future v;'); |
| 8277 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); | 8257 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); |
| 8278 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); | 8258 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); |
| 8279 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); | 8259 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); |
| 8280 } | 8260 } |
| 8281 | 8261 |
| 8282 test_import_prefix_reference() { | 8262 test_import_prefix_reference() { |
| 8283 UnlinkedVariable variable = | 8263 UnlinkedVariable variable = |
| 8284 serializeVariableText('import "dart:async" as a; a.Future v;'); | 8264 serializeVariableText('import "dart:async" as a; a.Future v;'); |
| 8285 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 8265 checkTypeRef(variable.type, 'dart:async', 'Future', |
| 8286 expectedPrefix: 'a', numTypeParameters: 1); | 8266 expectedPrefix: 'a', numTypeParameters: 1); |
| 8287 } | 8267 } |
| 8288 | 8268 |
| 8289 test_import_prefixes_take_precedence_over_imported_names() { | 8269 test_import_prefixes_take_precedence_over_imported_names() { |
| 8290 addNamedSource('/a.dart', 'class b {} class A'); | 8270 addNamedSource('/a.dart', 'class b {} class A'); |
| 8291 addNamedSource('/b.dart', 'class Cls {}'); | 8271 addNamedSource('/b.dart', 'class Cls {}'); |
| 8292 addNamedSource('/c.dart', 'class Cls {}'); | 8272 addNamedSource('/c.dart', 'class Cls {}'); |
| 8293 addNamedSource('/d.dart', 'class c {} class D'); | 8273 addNamedSource('/d.dart', 'class c {} class D'); |
| 8294 serializeLibraryText(''' | 8274 serializeLibraryText(''' |
| 8295 import 'a.dart'; | 8275 import 'a.dart'; |
| 8296 import 'b.dart' as b; | 8276 import 'b.dart' as b; |
| 8297 import 'c.dart' as c; | 8277 import 'c.dart' as c; |
| 8298 import 'd.dart'; | 8278 import 'd.dart'; |
| 8299 A aCls; | 8279 A aCls; |
| 8300 b.Cls bCls; | 8280 b.Cls bCls; |
| 8301 c.Cls cCls; | 8281 c.Cls cCls; |
| 8302 D dCls; | 8282 D dCls; |
| 8303 '''); | 8283 '''); |
| 8304 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'a.dart', 'A'); | 8284 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'A'); |
| 8305 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'b.dart', 'Cls', | 8285 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'Cls', |
| 8306 expectedPrefix: 'b'); | 8286 expectedPrefix: 'b'); |
| 8307 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'c.dart', 'Cls', | 8287 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'Cls', |
| 8308 expectedPrefix: 'c'); | 8288 expectedPrefix: 'c'); |
| 8309 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'd.dart', 'D'); | 8289 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'D'); |
| 8310 } | 8290 } |
| 8311 | 8291 |
| 8312 test_import_reference() { | 8292 test_import_reference() { |
| 8313 UnlinkedVariable variable = | 8293 UnlinkedVariable variable = |
| 8314 serializeVariableText('import "dart:async"; Future v;'); | 8294 serializeVariableText('import "dart:async"; Future v;'); |
| 8315 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 8295 checkTypeRef(variable.type, 'dart:async', 'Future', numTypeParameters: 1); |
| 8316 numTypeParameters: 1); | |
| 8317 } | 8296 } |
| 8318 | 8297 |
| 8319 test_import_reference_merged_no_prefix() { | 8298 test_import_reference_merged_no_prefix() { |
| 8320 serializeLibraryText(''' | 8299 serializeLibraryText(''' |
| 8321 import "dart:async" show Future; | 8300 import "dart:async" show Future; |
| 8322 import "dart:async" show Stream; | 8301 import "dart:async" show Stream; |
| 8323 | 8302 |
| 8324 Future f; | 8303 Future f; |
| 8325 Stream s; | 8304 Stream s; |
| 8326 '''); | 8305 '''); |
| 8327 { | 8306 { |
| 8328 EntityRef typeRef = findVariable('f').type; | 8307 EntityRef typeRef = findVariable('f').type; |
| 8329 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', | 8308 checkTypeRef(typeRef, 'dart:async', 'Future', numTypeParameters: 1); |
| 8330 numTypeParameters: 1); | |
| 8331 } | 8309 } |
| 8332 { | 8310 { |
| 8333 EntityRef typeRef = findVariable('s').type; | 8311 EntityRef typeRef = findVariable('s').type; |
| 8334 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', | 8312 checkTypeRef(typeRef, 'dart:async', 'Stream', |
| 8335 expectedTargetUnit: 1, numTypeParameters: 1); | 8313 expectedTargetUnit: 1, numTypeParameters: 1); |
| 8336 } | 8314 } |
| 8337 } | 8315 } |
| 8338 | 8316 |
| 8339 test_import_reference_merged_prefixed() { | 8317 test_import_reference_merged_prefixed() { |
| 8340 serializeLibraryText(''' | 8318 serializeLibraryText(''' |
| 8341 import "dart:async" as a show Future; | 8319 import "dart:async" as a show Future; |
| 8342 import "dart:async" as a show Stream; | 8320 import "dart:async" as a show Stream; |
| 8343 | 8321 |
| 8344 a.Future f; | 8322 a.Future f; |
| 8345 a.Stream s; | 8323 a.Stream s; |
| 8346 '''); | 8324 '''); |
| 8347 { | 8325 { |
| 8348 EntityRef typeRef = findVariable('f').type; | 8326 EntityRef typeRef = findVariable('f').type; |
| 8349 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', | 8327 checkTypeRef(typeRef, 'dart:async', 'Future', |
| 8350 expectedPrefix: 'a', numTypeParameters: 1); | 8328 expectedPrefix: 'a', numTypeParameters: 1); |
| 8351 } | 8329 } |
| 8352 { | 8330 { |
| 8353 EntityRef typeRef = findVariable('s').type; | 8331 EntityRef typeRef = findVariable('s').type; |
| 8354 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', | 8332 checkTypeRef(typeRef, 'dart:async', 'Stream', |
| 8355 expectedTargetUnit: 1, expectedPrefix: 'a', numTypeParameters: 1); | 8333 expectedTargetUnit: 1, expectedPrefix: 'a', numTypeParameters: 1); |
| 8356 } | 8334 } |
| 8357 } | 8335 } |
| 8358 | 8336 |
| 8359 test_import_reference_merged_prefixed_separate_libraries() { | 8337 test_import_reference_merged_prefixed_separate_libraries() { |
| 8360 addNamedSource('/a.dart', 'class A {}'); | 8338 addNamedSource('/a.dart', 'class A {}'); |
| 8361 addNamedSource('/b.dart', 'class B {}'); | 8339 addNamedSource('/b.dart', 'class B {}'); |
| 8362 serializeLibraryText(''' | 8340 serializeLibraryText(''' |
| 8363 import 'a.dart' as p; | 8341 import 'a.dart' as p; |
| 8364 import 'b.dart' as p; | 8342 import 'b.dart' as p; |
| 8365 | 8343 |
| 8366 p.A a; | 8344 p.A a; |
| 8367 p.B b; | 8345 p.B b; |
| 8368 '''); | 8346 '''); |
| 8369 checkTypeRef(findVariable('a').type, absUri('/a.dart'), 'a.dart', 'A', | 8347 checkTypeRef(findVariable('a').type, absUri('/a.dart'), 'A', |
| 8370 expectedPrefix: 'p'); | 8348 expectedPrefix: 'p'); |
| 8371 checkTypeRef(findVariable('b').type, absUri('/b.dart'), 'b.dart', 'B', | 8349 checkTypeRef(findVariable('b').type, absUri('/b.dart'), 'B', |
| 8372 expectedPrefix: 'p'); | 8350 expectedPrefix: 'p'); |
| 8373 } | 8351 } |
| 8374 | 8352 |
| 8375 test_import_self() { | 8353 test_import_self() { |
| 8376 serializeLibraryText(''' | 8354 serializeLibraryText(''' |
| 8377 import 'test.dart' as p; | 8355 import 'test.dart' as p; |
| 8378 class C {} | 8356 class C {} |
| 8379 class D extends p.C {} // Prevent "unused import" warning | 8357 class D extends p.C {} // Prevent "unused import" warning |
| 8380 '''); | 8358 '''); |
| 8381 expect(unlinkedUnits[0].imports[0].uri, 'test.dart'); | 8359 expect(unlinkedUnits[0].imports[0].uri, 'test.dart'); |
| 8382 checkDependency( | 8360 checkDependency(linked.importDependencies[0], absUri('/test.dart')); |
| 8383 linked.importDependencies[0], absUri('/test.dart'), 'test.dart'); | 8361 checkTypeRef( |
| 8384 checkTypeRef(unlinkedUnits[0].classes[1].supertype, absUri('/test.dart'), | 8362 unlinkedUnits[0].classes[1].supertype, absUri('/test.dart'), 'C', |
| 8385 'test.dart', 'C', | |
| 8386 expectedPrefix: 'p'); | 8363 expectedPrefix: 'p'); |
| 8387 } | 8364 } |
| 8388 | 8365 |
| 8389 test_import_show_order() { | 8366 test_import_show_order() { |
| 8390 String libraryText = | 8367 String libraryText = |
| 8391 'import "dart:async" show Future, Stream; Future x; Stream y;'; | 8368 'import "dart:async" show Future, Stream; Future x; Stream y;'; |
| 8392 serializeLibraryText(libraryText); | 8369 serializeLibraryText(libraryText); |
| 8393 // Second import is the implicit import of dart:core | 8370 // Second import is the implicit import of dart:core |
| 8394 expect(unlinkedUnits[0].imports, hasLength(2)); | 8371 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 8395 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); | 8372 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8446 class C<T> extends B<T> { | 8423 class C<T> extends B<T> { |
| 8447 void f(g) {} | 8424 void f(g) {} |
| 8448 } | 8425 } |
| 8449 '''); | 8426 '''); |
| 8450 expect(c.executables, hasLength(1)); | 8427 expect(c.executables, hasLength(1)); |
| 8451 UnlinkedExecutable f = c.executables[0]; | 8428 UnlinkedExecutable f = c.executables[0]; |
| 8452 expect(f.parameters, hasLength(1)); | 8429 expect(f.parameters, hasLength(1)); |
| 8453 UnlinkedParam g = f.parameters[0]; | 8430 UnlinkedParam g = f.parameters[0]; |
| 8454 expect(g.name, 'g'); | 8431 expect(g.name, 'g'); |
| 8455 EntityRef typeRef = getTypeRefForSlot(g.inferredTypeSlot); | 8432 EntityRef typeRef = getTypeRefForSlot(g.inferredTypeSlot); |
| 8456 checkLinkedTypeRef(typeRef, null, null, 'f', | 8433 checkLinkedTypeRef(typeRef, null, 'f', |
| 8457 expectedKind: ReferenceKind.method, numTypeArguments: 1); | 8434 expectedKind: ReferenceKind.method, numTypeArguments: 1); |
| 8458 checkParamTypeRef(typeRef.typeArguments[0], 1); | 8435 checkParamTypeRef(typeRef.typeArguments[0], 1); |
| 8459 } | 8436 } |
| 8460 | 8437 |
| 8461 test_inferred_type_keeps_leading_dynamic() { | 8438 test_inferred_type_keeps_leading_dynamic() { |
| 8462 if (!strongMode || skipFullyLinkedData) { | 8439 if (!strongMode || skipFullyLinkedData) { |
| 8463 return; | 8440 return; |
| 8464 } | 8441 } |
| 8465 UnlinkedClass cls = | 8442 UnlinkedClass cls = |
| 8466 serializeClassText('class C { final x = <dynamic, int>{}; }'); | 8443 serializeClassText('class C { final x = <dynamic, int>{}; }'); |
| 8467 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 8444 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 8468 // Check that x has inferred type `Map<dynamic, int>`. | 8445 // Check that x has inferred type `Map<dynamic, int>`. |
| 8469 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 8446 checkLinkedTypeRef(type, 'dart:core', 'Map', |
| 8470 numTypeParameters: 2, numTypeArguments: 2); | 8447 numTypeParameters: 2, numTypeArguments: 2); |
| 8471 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); | 8448 checkLinkedTypeRef(type.typeArguments[0], null, 'dynamic'); |
| 8472 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8449 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'int'); |
| 8473 } | 8450 } |
| 8474 | 8451 |
| 8475 test_inferred_type_reference_shared_prefixed() { | 8452 test_inferred_type_reference_shared_prefixed() { |
| 8476 if (!strongMode || skipFullyLinkedData) { | 8453 if (!strongMode || skipFullyLinkedData) { |
| 8477 return; | 8454 return; |
| 8478 } | 8455 } |
| 8479 // Variable `y` has an inferred type of `p.C`. Verify that the reference | 8456 // Variable `y` has an inferred type of `p.C`. Verify that the reference |
| 8480 // used by the explicit type of `x` is re-used for the inferred type. | 8457 // used by the explicit type of `x` is re-used for the inferred type. |
| 8481 addNamedSource('/a.dart', 'class C {}'); | 8458 addNamedSource('/a.dart', 'class C {}'); |
| 8482 serializeLibraryText('import "a.dart" as p; p.C x; var y = new p.C();'); | 8459 serializeLibraryText('import "a.dart" as p; p.C x; var y = new p.C();'); |
| 8483 EntityRef xType = findVariable('x').type; | 8460 EntityRef xType = findVariable('x').type; |
| 8484 EntityRef yType = getTypeRefForSlot(findVariable('y').inferredTypeSlot); | 8461 EntityRef yType = getTypeRefForSlot(findVariable('y').inferredTypeSlot); |
| 8485 expect(yType.reference, xType.reference); | 8462 expect(yType.reference, xType.reference); |
| 8486 } | 8463 } |
| 8487 | 8464 |
| 8488 test_inferred_type_refers_to_bound_type_param() { | 8465 test_inferred_type_refers_to_bound_type_param() { |
| 8489 if (!strongMode || skipFullyLinkedData) { | 8466 if (!strongMode || skipFullyLinkedData) { |
| 8490 return; | 8467 return; |
| 8491 } | 8468 } |
| 8492 UnlinkedClass cls = serializeClassText( | 8469 UnlinkedClass cls = serializeClassText( |
| 8493 'class C<T> extends D<int, T> { var v; }' | 8470 'class C<T> extends D<int, T> { var v; }' |
| 8494 ' abstract class D<U, V> { Map<V, U> get v; }', | 8471 ' abstract class D<U, V> { Map<V, U> get v; }', |
| 8495 className: 'C'); | 8472 className: 'C'); |
| 8496 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 8473 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 8497 // Check that v has inferred type Map<T, int>. | 8474 // Check that v has inferred type Map<T, int>. |
| 8498 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 8475 checkLinkedTypeRef(type, 'dart:core', 'Map', |
| 8499 numTypeParameters: 2, numTypeArguments: 2); | 8476 numTypeParameters: 2, numTypeArguments: 2); |
| 8500 checkParamTypeRef(type.typeArguments[0], 1); | 8477 checkParamTypeRef(type.typeArguments[0], 1); |
| 8501 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8478 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'int'); |
| 8502 } | 8479 } |
| 8503 | 8480 |
| 8504 test_inferred_type_refers_to_function_typed_param_of_typedef() { | 8481 test_inferred_type_refers_to_function_typed_param_of_typedef() { |
| 8505 if (!strongMode || skipFullyLinkedData) { | 8482 if (!strongMode || skipFullyLinkedData) { |
| 8506 return; | 8483 return; |
| 8507 } | 8484 } |
| 8508 UnlinkedVariable v = serializeVariableText(''' | 8485 UnlinkedVariable v = serializeVariableText(''' |
| 8509 typedef void F(int g(String s)); | 8486 typedef void F(int g(String s)); |
| 8510 h(F f) => null; | 8487 h(F f) => null; |
| 8511 var v = h((y) {}); | 8488 var v = h((y) {}); |
| 8512 '''); | 8489 '''); |
| 8513 expect(v.initializer.localFunctions, hasLength(1)); | 8490 expect(v.initializer.localFunctions, hasLength(1)); |
| 8514 UnlinkedExecutable closure = v.initializer.localFunctions[0]; | 8491 UnlinkedExecutable closure = v.initializer.localFunctions[0]; |
| 8515 expect(closure.parameters, hasLength(1)); | 8492 expect(closure.parameters, hasLength(1)); |
| 8516 UnlinkedParam y = closure.parameters[0]; | 8493 UnlinkedParam y = closure.parameters[0]; |
| 8517 expect(y.name, 'y'); | 8494 expect(y.name, 'y'); |
| 8518 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); | 8495 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); |
| 8519 checkLinkedTypeRef(typeRef, null, null, 'F', | 8496 checkLinkedTypeRef(typeRef, null, 'F', expectedKind: ReferenceKind.typedef); |
| 8520 expectedKind: ReferenceKind.typedef); | |
| 8521 expect(typeRef.implicitFunctionTypeIndices, [0]); | 8497 expect(typeRef.implicitFunctionTypeIndices, [0]); |
| 8522 } | 8498 } |
| 8523 | 8499 |
| 8524 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { | 8500 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { |
| 8525 if (!strongMode || skipFullyLinkedData) { | 8501 if (!strongMode || skipFullyLinkedData) { |
| 8526 return; | 8502 return; |
| 8527 } | 8503 } |
| 8528 UnlinkedClass cls = serializeClassText( | 8504 UnlinkedClass cls = serializeClassText( |
| 8529 'class C<T, U> extends D<U, int> { void f(int x, g) {} }' | 8505 'class C<T, U> extends D<U, int> { void f(int x, g) {} }' |
| 8530 ' abstract class D<V, W> { void f(int x, W g(V s)); }', | 8506 ' abstract class D<V, W> { void f(int x, W g(V s)); }', |
| 8531 className: 'C'); | 8507 className: 'C'); |
| 8532 EntityRef type = | 8508 EntityRef type = |
| 8533 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); | 8509 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); |
| 8534 // Check that parameter g's inferred type is the type implied by D.f's 1st | 8510 // Check that parameter g's inferred type is the type implied by D.f's 1st |
| 8535 // (zero-based) parameter. | 8511 // (zero-based) parameter. |
| 8536 expect(type.implicitFunctionTypeIndices, [1]); | 8512 expect(type.implicitFunctionTypeIndices, [1]); |
| 8537 expect(type.paramReference, 0); | 8513 expect(type.paramReference, 0); |
| 8538 expect(type.typeArguments, hasLength(2)); | 8514 expect(type.typeArguments, hasLength(2)); |
| 8539 checkParamTypeRef(type.typeArguments[0], 1); | 8515 checkParamTypeRef(type.typeArguments[0], 1); |
| 8540 checkTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8516 checkTypeRef(type.typeArguments[1], 'dart:core', 'int'); |
| 8541 expect(type.reference, | 8517 expect(type.reference, |
| 8542 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 8518 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 8543 LinkedReference linkedReference = | 8519 LinkedReference linkedReference = |
| 8544 linked.units[0].references[type.reference]; | 8520 linked.units[0].references[type.reference]; |
| 8545 expect(linkedReference.dependency, 0); | 8521 expect(linkedReference.dependency, 0); |
| 8546 expect(linkedReference.kind, ReferenceKind.method); | 8522 expect(linkedReference.kind, ReferenceKind.method); |
| 8547 expect(linkedReference.name, 'f'); | 8523 expect(linkedReference.name, 'f'); |
| 8548 expect(linkedReference.numTypeParameters, 0); | 8524 expect(linkedReference.numTypeParameters, 0); |
| 8549 expect(linkedReference.unit, 0); | 8525 expect(linkedReference.unit, 0); |
| 8550 expect(linkedReference.containingReference, isNot(0)); | 8526 expect(linkedReference.containingReference, isNot(0)); |
| 8551 expect(linkedReference.containingReference, lessThan(type.reference)); | 8527 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 8552 checkReferenceIndex(linkedReference.containingReference, null, null, 'D', | 8528 checkReferenceIndex(linkedReference.containingReference, null, 'D', |
| 8553 numTypeParameters: 2); | 8529 numTypeParameters: 2); |
| 8554 } | 8530 } |
| 8555 | 8531 |
| 8556 test_inferred_type_refers_to_function_typed_parameter_type_other_lib() { | 8532 test_inferred_type_refers_to_function_typed_parameter_type_other_lib() { |
| 8557 if (!strongMode || skipFullyLinkedData) { | 8533 if (!strongMode || skipFullyLinkedData) { |
| 8558 return; | 8534 return; |
| 8559 } | 8535 } |
| 8560 addNamedSource('/a.dart', 'import "b.dart"; abstract class D extends E {}'); | 8536 addNamedSource('/a.dart', 'import "b.dart"; abstract class D extends E {}'); |
| 8561 addNamedSource( | 8537 addNamedSource( |
| 8562 '/b.dart', 'abstract class E { void f(int x, int g(String s)); }'); | 8538 '/b.dart', 'abstract class E { void f(int x, int g(String s)); }'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8574 LinkedReference linkedReference = | 8550 LinkedReference linkedReference = |
| 8575 linked.units[0].references[type.reference]; | 8551 linked.units[0].references[type.reference]; |
| 8576 expect(linkedReference.dependency, 0); | 8552 expect(linkedReference.dependency, 0); |
| 8577 expect(linkedReference.kind, ReferenceKind.method); | 8553 expect(linkedReference.kind, ReferenceKind.method); |
| 8578 expect(linkedReference.name, 'f'); | 8554 expect(linkedReference.name, 'f'); |
| 8579 expect(linkedReference.numTypeParameters, 0); | 8555 expect(linkedReference.numTypeParameters, 0); |
| 8580 expect(linkedReference.unit, 0); | 8556 expect(linkedReference.unit, 0); |
| 8581 expect(linkedReference.containingReference, isNot(0)); | 8557 expect(linkedReference.containingReference, isNot(0)); |
| 8582 expect(linkedReference.containingReference, lessThan(type.reference)); | 8558 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 8583 checkReferenceIndex( | 8559 checkReferenceIndex( |
| 8584 linkedReference.containingReference, absUri('/b.dart'), 'b.dart', 'E'); | 8560 linkedReference.containingReference, absUri('/b.dart'), 'E'); |
| 8585 } | 8561 } |
| 8586 | 8562 |
| 8587 test_inferred_type_refers_to_method_function_typed_parameter_type() { | 8563 test_inferred_type_refers_to_method_function_typed_parameter_type() { |
| 8588 if (!strongMode || skipFullyLinkedData) { | 8564 if (!strongMode || skipFullyLinkedData) { |
| 8589 return; | 8565 return; |
| 8590 } | 8566 } |
| 8591 UnlinkedClass cls = serializeClassText( | 8567 UnlinkedClass cls = serializeClassText( |
| 8592 'class C extends D { void f(int x, g) {} }' | 8568 'class C extends D { void f(int x, g) {} }' |
| 8593 ' abstract class D { void f(int x, int g(String s)); }', | 8569 ' abstract class D { void f(int x, int g(String s)); }', |
| 8594 className: 'C'); | 8570 className: 'C'); |
| 8595 EntityRef type = | 8571 EntityRef type = |
| 8596 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); | 8572 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); |
| 8597 // Check that parameter g's inferred type is the type implied by D.f's 1st | 8573 // Check that parameter g's inferred type is the type implied by D.f's 1st |
| 8598 // (zero-based) parameter. | 8574 // (zero-based) parameter. |
| 8599 expect(type.implicitFunctionTypeIndices, [1]); | 8575 expect(type.implicitFunctionTypeIndices, [1]); |
| 8600 expect(type.paramReference, 0); | 8576 expect(type.paramReference, 0); |
| 8601 expect(type.typeArguments, isEmpty); | 8577 expect(type.typeArguments, isEmpty); |
| 8602 expect(type.reference, | 8578 expect(type.reference, |
| 8603 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 8579 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 8604 LinkedReference linkedReference = | 8580 LinkedReference linkedReference = |
| 8605 linked.units[0].references[type.reference]; | 8581 linked.units[0].references[type.reference]; |
| 8606 expect(linkedReference.dependency, 0); | 8582 expect(linkedReference.dependency, 0); |
| 8607 expect(linkedReference.kind, ReferenceKind.method); | 8583 expect(linkedReference.kind, ReferenceKind.method); |
| 8608 expect(linkedReference.name, 'f'); | 8584 expect(linkedReference.name, 'f'); |
| 8609 expect(linkedReference.numTypeParameters, 0); | 8585 expect(linkedReference.numTypeParameters, 0); |
| 8610 expect(linkedReference.unit, 0); | 8586 expect(linkedReference.unit, 0); |
| 8611 expect(linkedReference.containingReference, isNot(0)); | 8587 expect(linkedReference.containingReference, isNot(0)); |
| 8612 expect(linkedReference.containingReference, lessThan(type.reference)); | 8588 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 8613 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); | 8589 checkReferenceIndex(linkedReference.containingReference, null, 'D'); |
| 8614 } | 8590 } |
| 8615 | 8591 |
| 8616 test_inferred_type_refers_to_nested_function_typed_param() { | 8592 test_inferred_type_refers_to_nested_function_typed_param() { |
| 8617 if (!strongMode || skipFullyLinkedData) { | 8593 if (!strongMode || skipFullyLinkedData) { |
| 8618 return; | 8594 return; |
| 8619 } | 8595 } |
| 8620 UnlinkedVariable v = serializeVariableText(''' | 8596 UnlinkedVariable v = serializeVariableText(''' |
| 8621 f(void g(int x, void h())) => null; | 8597 f(void g(int x, void h())) => null; |
| 8622 var v = f((x, y) {}); | 8598 var v = f((x, y) {}); |
| 8623 '''); | 8599 '''); |
| 8624 expect(v.initializer.localFunctions, hasLength(1)); | 8600 expect(v.initializer.localFunctions, hasLength(1)); |
| 8625 UnlinkedExecutable closure = v.initializer.localFunctions[0]; | 8601 UnlinkedExecutable closure = v.initializer.localFunctions[0]; |
| 8626 expect(closure.parameters, hasLength(2)); | 8602 expect(closure.parameters, hasLength(2)); |
| 8627 UnlinkedParam y = closure.parameters[1]; | 8603 UnlinkedParam y = closure.parameters[1]; |
| 8628 expect(y.name, 'y'); | 8604 expect(y.name, 'y'); |
| 8629 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); | 8605 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); |
| 8630 checkLinkedTypeRef(typeRef, null, null, 'f', | 8606 checkLinkedTypeRef(typeRef, null, 'f', |
| 8631 expectedKind: ReferenceKind.topLevelFunction); | 8607 expectedKind: ReferenceKind.topLevelFunction); |
| 8632 expect(typeRef.implicitFunctionTypeIndices, [0, 1]); | 8608 expect(typeRef.implicitFunctionTypeIndices, [0, 1]); |
| 8633 } | 8609 } |
| 8634 | 8610 |
| 8635 test_inferred_type_refers_to_nested_function_typed_param_named() { | 8611 test_inferred_type_refers_to_nested_function_typed_param_named() { |
| 8636 if (!strongMode || skipFullyLinkedData) { | 8612 if (!strongMode || skipFullyLinkedData) { |
| 8637 return; | 8613 return; |
| 8638 } | 8614 } |
| 8639 UnlinkedVariable v = serializeVariableText(''' | 8615 UnlinkedVariable v = serializeVariableText(''' |
| 8640 f({void g(int x, void h())}) => null; | 8616 f({void g(int x, void h())}) => null; |
| 8641 var v = f(g: (x, y) {}); | 8617 var v = f(g: (x, y) {}); |
| 8642 '''); | 8618 '''); |
| 8643 expect(v.initializer.localFunctions, hasLength(1)); | 8619 expect(v.initializer.localFunctions, hasLength(1)); |
| 8644 UnlinkedExecutable closure = v.initializer.localFunctions[0]; | 8620 UnlinkedExecutable closure = v.initializer.localFunctions[0]; |
| 8645 expect(closure.parameters, hasLength(2)); | 8621 expect(closure.parameters, hasLength(2)); |
| 8646 UnlinkedParam y = closure.parameters[1]; | 8622 UnlinkedParam y = closure.parameters[1]; |
| 8647 expect(y.name, 'y'); | 8623 expect(y.name, 'y'); |
| 8648 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); | 8624 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); |
| 8649 checkLinkedTypeRef(typeRef, null, null, 'f', | 8625 checkLinkedTypeRef(typeRef, null, 'f', |
| 8650 expectedKind: ReferenceKind.topLevelFunction); | 8626 expectedKind: ReferenceKind.topLevelFunction); |
| 8651 expect(typeRef.implicitFunctionTypeIndices, [0, 1]); | 8627 expect(typeRef.implicitFunctionTypeIndices, [0, 1]); |
| 8652 } | 8628 } |
| 8653 | 8629 |
| 8654 test_inferred_type_refers_to_setter_function_typed_parameter_type() { | 8630 test_inferred_type_refers_to_setter_function_typed_parameter_type() { |
| 8655 if (!strongMode || skipFullyLinkedData) { | 8631 if (!strongMode || skipFullyLinkedData) { |
| 8656 return; | 8632 return; |
| 8657 } | 8633 } |
| 8658 UnlinkedClass cls = serializeClassText( | 8634 UnlinkedClass cls = serializeClassText( |
| 8659 'class C extends D { void set f(g) {} }' | 8635 'class C extends D { void set f(g) {} }' |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8670 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 8646 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 8671 LinkedReference linkedReference = | 8647 LinkedReference linkedReference = |
| 8672 linked.units[0].references[type.reference]; | 8648 linked.units[0].references[type.reference]; |
| 8673 expect(linkedReference.dependency, 0); | 8649 expect(linkedReference.dependency, 0); |
| 8674 expect(linkedReference.kind, ReferenceKind.propertyAccessor); | 8650 expect(linkedReference.kind, ReferenceKind.propertyAccessor); |
| 8675 expect(linkedReference.name, 'f='); | 8651 expect(linkedReference.name, 'f='); |
| 8676 expect(linkedReference.numTypeParameters, 0); | 8652 expect(linkedReference.numTypeParameters, 0); |
| 8677 expect(linkedReference.unit, 0); | 8653 expect(linkedReference.unit, 0); |
| 8678 expect(linkedReference.containingReference, isNot(0)); | 8654 expect(linkedReference.containingReference, isNot(0)); |
| 8679 expect(linkedReference.containingReference, lessThan(type.reference)); | 8655 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 8680 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); | 8656 checkReferenceIndex(linkedReference.containingReference, null, 'D'); |
| 8681 } | 8657 } |
| 8682 | 8658 |
| 8683 test_inferred_type_skips_trailing_dynamic() { | 8659 test_inferred_type_skips_trailing_dynamic() { |
| 8684 if (!strongMode || skipFullyLinkedData) { | 8660 if (!strongMode || skipFullyLinkedData) { |
| 8685 return; | 8661 return; |
| 8686 } | 8662 } |
| 8687 UnlinkedClass cls = | 8663 UnlinkedClass cls = |
| 8688 serializeClassText('class C { final x = <int, dynamic>{}; }'); | 8664 serializeClassText('class C { final x = <int, dynamic>{}; }'); |
| 8689 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 8665 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 8690 // Check that x has inferred type `Map<int, dynamic>`. | 8666 // Check that x has inferred type `Map<int, dynamic>`. |
| 8691 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 8667 checkLinkedTypeRef(type, 'dart:core', 'Map', |
| 8692 numTypeParameters: 2, numTypeArguments: 2); | 8668 numTypeParameters: 2, numTypeArguments: 2); |
| 8693 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 8669 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'int'); |
| 8694 checkLinkedDynamicTypeRef(type.typeArguments[1]); | 8670 checkLinkedDynamicTypeRef(type.typeArguments[1]); |
| 8695 } | 8671 } |
| 8696 | 8672 |
| 8697 test_inferred_type_skips_unnecessary_dynamic() { | 8673 test_inferred_type_skips_unnecessary_dynamic() { |
| 8698 if (!strongMode || skipFullyLinkedData) { | 8674 if (!strongMode || skipFullyLinkedData) { |
| 8699 return; | 8675 return; |
| 8700 } | 8676 } |
| 8701 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); | 8677 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); |
| 8702 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 8678 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 8703 // Check that x has inferred type `List<dynamic>`. | 8679 // Check that x has inferred type `List<dynamic>`. |
| 8704 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', | 8680 checkLinkedTypeRef(type, 'dart:core', 'List', |
| 8705 numTypeParameters: 1, numTypeArguments: 1); | 8681 numTypeParameters: 1, numTypeArguments: 1); |
| 8706 } | 8682 } |
| 8707 | 8683 |
| 8708 test_initializer_executable_with_bottom_return_type() { | 8684 test_initializer_executable_with_bottom_return_type() { |
| 8709 // The synthetic executable for `v` has type `() => Bottom`. | 8685 // The synthetic executable for `v` has type `() => Bottom`. |
| 8710 UnlinkedVariable variable = serializeVariableText('int v = null;'); | 8686 UnlinkedVariable variable = serializeVariableText('int v = null;'); |
| 8711 expect(variable.initializer.returnType, isNull); | 8687 expect(variable.initializer.returnType, isNull); |
| 8712 checkInferredTypeSlot( | 8688 checkInferredTypeSlot( |
| 8713 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', | 8689 variable.initializer.inferredReturnTypeSlot, null, '*bottom*', |
| 8714 onlyInStrongMode: false); | 8690 onlyInStrongMode: false); |
| 8715 } | 8691 } |
| 8716 | 8692 |
| 8717 test_initializer_executable_with_imported_return_type() { | 8693 test_initializer_executable_with_imported_return_type() { |
| 8718 addNamedSource('/a.dart', 'class C { D d; } class D {}'); | 8694 addNamedSource('/a.dart', 'class C { D d; } class D {}'); |
| 8719 // The synthetic executable for `v` has type `() => D`; `D` is defined in | 8695 // The synthetic executable for `v` has type `() => D`; `D` is defined in |
| 8720 // a library that is imported. Note: `v` is mis-typed as `int` to prevent | 8696 // a library that is imported. Note: `v` is mis-typed as `int` to prevent |
| 8721 // type propagation, which would complicate the test. | 8697 // type propagation, which would complicate the test. |
| 8722 UnlinkedVariable variable = serializeVariableText( | 8698 UnlinkedVariable variable = serializeVariableText( |
| 8723 'import "a.dart"; int v = new C().d;', | 8699 'import "a.dart"; int v = new C().d;', |
| 8724 allowErrors: true); | 8700 allowErrors: true); |
| 8725 expect(variable.initializer.returnType, isNull); | 8701 expect(variable.initializer.returnType, isNull); |
| 8726 checkInferredTypeSlot(variable.initializer.inferredReturnTypeSlot, | 8702 checkInferredTypeSlot( |
| 8727 absUri('/a.dart'), 'a.dart', 'D', | 8703 variable.initializer.inferredReturnTypeSlot, absUri('/a.dart'), 'D', |
| 8728 onlyInStrongMode: false); | 8704 onlyInStrongMode: false); |
| 8729 checkHasDependency('a.dart', fullyLinked: false); | 8705 checkHasDependency(absUri('/a.dart'), fullyLinked: false); |
| 8730 } | 8706 } |
| 8731 | 8707 |
| 8732 test_initializer_executable_with_return_type_from_closure() { | 8708 test_initializer_executable_with_return_type_from_closure() { |
| 8733 if (skipFullyLinkedData) { | 8709 if (skipFullyLinkedData) { |
| 8734 return; | 8710 return; |
| 8735 } | 8711 } |
| 8736 // The synthetic executable for `v` has type `() => () => int`, where the | 8712 // The synthetic executable for `v` has type `() => () => int`, where the |
| 8737 // `() => int` part refers to the closure declared inside the initializer | 8713 // `() => int` part refers to the closure declared inside the initializer |
| 8738 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, | 8714 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, |
| 8739 // which would complicate the test. | 8715 // which would complicate the test. |
| 8740 UnlinkedVariable variable = | 8716 UnlinkedVariable variable = |
| 8741 serializeVariableText('int v = () => 0;', allowErrors: true); | 8717 serializeVariableText('int v = () => 0;', allowErrors: true); |
| 8742 EntityRef closureType = | 8718 EntityRef closureType = |
| 8743 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 8719 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 8744 checkLinkedTypeRef(closureType, null, null, '', | 8720 checkLinkedTypeRef(closureType, null, '', |
| 8745 expectedKind: ReferenceKind.function); | 8721 expectedKind: ReferenceKind.function); |
| 8746 int initializerIndex = | 8722 int initializerIndex = |
| 8747 definingUnit.references[closureType.reference].containingReference; | 8723 definingUnit.references[closureType.reference].containingReference; |
| 8748 checkReferenceIndex(initializerIndex, null, null, '', | 8724 checkReferenceIndex(initializerIndex, null, '', |
| 8749 expectedKind: ReferenceKind.function); | 8725 expectedKind: ReferenceKind.function); |
| 8750 int variableIndex = | 8726 int variableIndex = |
| 8751 definingUnit.references[initializerIndex].containingReference; | 8727 definingUnit.references[initializerIndex].containingReference; |
| 8752 checkReferenceIndex(variableIndex, null, null, 'v', | 8728 checkReferenceIndex(variableIndex, null, 'v', |
| 8753 expectedKind: ReferenceKind.topLevelPropertyAccessor); | 8729 expectedKind: ReferenceKind.topLevelPropertyAccessor); |
| 8754 expect(definingUnit.references[variableIndex].containingReference, 0); | 8730 expect(definingUnit.references[variableIndex].containingReference, 0); |
| 8755 } | 8731 } |
| 8756 | 8732 |
| 8757 test_initializer_executable_with_return_type_from_closure_field() { | 8733 test_initializer_executable_with_return_type_from_closure_field() { |
| 8758 if (skipFullyLinkedData) { | 8734 if (skipFullyLinkedData) { |
| 8759 return; | 8735 return; |
| 8760 } | 8736 } |
| 8761 // The synthetic executable for `v` has type `() => () => int`, where the | 8737 // The synthetic executable for `v` has type `() => () => int`, where the |
| 8762 // `() => int` part refers to the closure declared inside the initializer | 8738 // `() => int` part refers to the closure declared inside the initializer |
| 8763 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, | 8739 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, |
| 8764 // which would complicate the test. | 8740 // which would complicate the test. |
| 8765 UnlinkedClass cls = serializeClassText( | 8741 UnlinkedClass cls = serializeClassText( |
| 8766 ''' | 8742 ''' |
| 8767 class C { | 8743 class C { |
| 8768 int v = () => 0; | 8744 int v = () => 0; |
| 8769 } | 8745 } |
| 8770 ''', | 8746 ''', |
| 8771 allowErrors: true); | 8747 allowErrors: true); |
| 8772 UnlinkedVariable variable = cls.fields[0]; | 8748 UnlinkedVariable variable = cls.fields[0]; |
| 8773 EntityRef closureType = | 8749 EntityRef closureType = |
| 8774 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 8750 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 8775 checkLinkedTypeRef(closureType, null, null, '', | 8751 checkLinkedTypeRef(closureType, null, '', |
| 8776 expectedKind: ReferenceKind.function); | 8752 expectedKind: ReferenceKind.function); |
| 8777 int initializerIndex = | 8753 int initializerIndex = |
| 8778 definingUnit.references[closureType.reference].containingReference; | 8754 definingUnit.references[closureType.reference].containingReference; |
| 8779 checkReferenceIndex(initializerIndex, null, null, '', | 8755 checkReferenceIndex(initializerIndex, null, '', |
| 8780 expectedKind: ReferenceKind.function); | 8756 expectedKind: ReferenceKind.function); |
| 8781 int variableIndex = | 8757 int variableIndex = |
| 8782 definingUnit.references[initializerIndex].containingReference; | 8758 definingUnit.references[initializerIndex].containingReference; |
| 8783 checkReferenceIndex(variableIndex, null, null, 'v', | 8759 checkReferenceIndex(variableIndex, null, 'v', |
| 8784 expectedKind: ReferenceKind.propertyAccessor); | 8760 expectedKind: ReferenceKind.propertyAccessor); |
| 8785 int classIndex = definingUnit.references[variableIndex].containingReference; | 8761 int classIndex = definingUnit.references[variableIndex].containingReference; |
| 8786 checkReferenceIndex(classIndex, null, null, 'C'); | 8762 checkReferenceIndex(classIndex, null, 'C'); |
| 8787 expect(definingUnit.references[classIndex].containingReference, 0); | 8763 expect(definingUnit.references[classIndex].containingReference, 0); |
| 8788 } | 8764 } |
| 8789 | 8765 |
| 8790 test_initializer_executable_with_return_type_from_closure_local() { | 8766 test_initializer_executable_with_return_type_from_closure_local() { |
| 8791 if (skipFullyLinkedData) { | 8767 if (skipFullyLinkedData) { |
| 8792 return; | 8768 return; |
| 8793 } | 8769 } |
| 8794 // The synthetic executable for `v` has type `() => () => int`, where the | 8770 // The synthetic executable for `v` has type `() => () => int`, where the |
| 8795 // `() => int` part refers to the closure declared inside the initializer | 8771 // `() => int` part refers to the closure declared inside the initializer |
| 8796 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, | 8772 // for v. Note: `v` is mis-typed as `int` to prevent type propagation, |
| 8797 // which would complicate the test. | 8773 // which would complicate the test. |
| 8798 UnlinkedExecutable executable = serializeExecutableText( | 8774 UnlinkedExecutable executable = serializeExecutableText( |
| 8799 ''' | 8775 ''' |
| 8800 void f() { | 8776 void f() { |
| 8801 int u = 0; // force the variable below to have index 1 | 8777 int u = 0; // force the variable below to have index 1 |
| 8802 int v = () => 0; | 8778 int v = () => 0; |
| 8803 }''', | 8779 }''', |
| 8804 allowErrors: true); | 8780 allowErrors: true); |
| 8805 UnlinkedVariable variable = executable.localVariables[1]; | 8781 UnlinkedVariable variable = executable.localVariables[1]; |
| 8806 EntityRef closureType = | 8782 EntityRef closureType = |
| 8807 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 8783 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 8808 checkLinkedTypeRef(closureType, null, null, '', | 8784 checkLinkedTypeRef(closureType, null, '', |
| 8809 expectedKind: ReferenceKind.function); | 8785 expectedKind: ReferenceKind.function); |
| 8810 int initializerIndex = | 8786 int initializerIndex = |
| 8811 definingUnit.references[closureType.reference].containingReference; | 8787 definingUnit.references[closureType.reference].containingReference; |
| 8812 checkReferenceIndex(initializerIndex, null, null, '', | 8788 checkReferenceIndex(initializerIndex, null, '', |
| 8813 expectedKind: ReferenceKind.function); | 8789 expectedKind: ReferenceKind.function); |
| 8814 int variableIndex = | 8790 int variableIndex = |
| 8815 definingUnit.references[initializerIndex].containingReference; | 8791 definingUnit.references[initializerIndex].containingReference; |
| 8816 checkReferenceIndex(variableIndex, null, null, 'v', | 8792 checkReferenceIndex(variableIndex, null, 'v', |
| 8817 expectedKind: ReferenceKind.variable, localIndex: 1); | 8793 expectedKind: ReferenceKind.variable, localIndex: 1); |
| 8818 int topLevelFunctionIndex = | 8794 int topLevelFunctionIndex = |
| 8819 definingUnit.references[variableIndex].containingReference; | 8795 definingUnit.references[variableIndex].containingReference; |
| 8820 checkReferenceIndex(topLevelFunctionIndex, null, null, 'f', | 8796 checkReferenceIndex(topLevelFunctionIndex, null, 'f', |
| 8821 expectedKind: ReferenceKind.topLevelFunction); | 8797 expectedKind: ReferenceKind.topLevelFunction); |
| 8822 expect( | 8798 expect( |
| 8823 definingUnit.references[topLevelFunctionIndex].containingReference, 0); | 8799 definingUnit.references[topLevelFunctionIndex].containingReference, 0); |
| 8824 } | 8800 } |
| 8825 | 8801 |
| 8826 test_initializer_executable_with_unimported_return_type() { | 8802 test_initializer_executable_with_unimported_return_type() { |
| 8827 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); | 8803 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); |
| 8828 addNamedSource('/b.dart', 'class D {}'); | 8804 addNamedSource('/b.dart', 'class D {}'); |
| 8829 // The synthetic executable for `v` has type `() => D`; `D` is defined in | 8805 // The synthetic executable for `v` has type `() => D`; `D` is defined in |
| 8830 // a library that is not imported. Note: `v` is mis-typed as `int` to | 8806 // a library that is not imported. Note: `v` is mis-typed as `int` to |
| 8831 // prevent type propagation, which would complicate the test. | 8807 // prevent type propagation, which would complicate the test. |
| 8832 UnlinkedVariable variable = serializeVariableText( | 8808 UnlinkedVariable variable = serializeVariableText( |
| 8833 'import "a.dart"; int v = new C().d;', | 8809 'import "a.dart"; int v = new C().d;', |
| 8834 allowErrors: true); | 8810 allowErrors: true); |
| 8835 expect(variable.initializer.returnType, isNull); | 8811 expect(variable.initializer.returnType, isNull); |
| 8836 checkInferredTypeSlot(variable.initializer.inferredReturnTypeSlot, | 8812 checkInferredTypeSlot( |
| 8837 absUri('/b.dart'), 'b.dart', 'D', | 8813 variable.initializer.inferredReturnTypeSlot, absUri('/b.dart'), 'D', |
| 8838 onlyInStrongMode: false); | 8814 onlyInStrongMode: false); |
| 8839 if (!skipFullyLinkedData) { | 8815 if (!skipFullyLinkedData) { |
| 8840 checkHasDependency('b.dart', fullyLinked: true); | 8816 checkHasDependency('b.dart', fullyLinked: true); |
| 8841 } | 8817 } |
| 8842 } | 8818 } |
| 8843 | 8819 |
| 8844 test_library_documented() { | 8820 test_library_documented() { |
| 8845 if (!includeInformative) return; | 8821 if (!includeInformative) return; |
| 8846 String text = ''' | 8822 String text = ''' |
| 8847 // Extra comment so doc comment offset != 0 | 8823 // Extra comment so doc comment offset != 0 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 8878 expect(unlinkedUnits[0].libraryNameLength, 0); | 8854 expect(unlinkedUnits[0].libraryNameLength, 0); |
| 8879 } | 8855 } |
| 8880 | 8856 |
| 8881 test_library_with_missing_part() { | 8857 test_library_with_missing_part() { |
| 8882 // References to other parts should still be resolved. | 8858 // References to other parts should still be resolved. |
| 8883 allowMissingFiles = true; | 8859 allowMissingFiles = true; |
| 8884 addNamedSource('/bar.dart', 'part of my.lib; class C {}'); | 8860 addNamedSource('/bar.dart', 'part of my.lib; class C {}'); |
| 8885 serializeLibraryText( | 8861 serializeLibraryText( |
| 8886 'library my.lib; part "foo.dart"; part "bar.dart"; C c;', | 8862 'library my.lib; part "foo.dart"; part "bar.dart"; C c;', |
| 8887 allowErrors: true); | 8863 allowErrors: true); |
| 8888 checkTypeRef(findVariable('c').type, null, null, 'C', | 8864 checkTypeRef(findVariable('c').type, null, 'C', expectedTargetUnit: 2); |
| 8889 expectedTargetUnit: 2); | |
| 8890 } | 8865 } |
| 8891 | 8866 |
| 8892 test_lineStarts() { | 8867 test_lineStarts() { |
| 8893 String text = ''' | 8868 String text = ''' |
| 8894 int foo; | 8869 int foo; |
| 8895 class Test {} | 8870 class Test {} |
| 8896 | 8871 |
| 8897 int bar;''' | 8872 int bar;''' |
| 8898 .replaceAll('\r\n', '\n'); | 8873 .replaceAll('\r\n', '\n'); |
| 8899 serializeLibraryText(text); | 8874 serializeLibraryText(text); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8933 linked.units[0].references[dReference].dependency, explicitDependency); | 8908 linked.units[0].references[dReference].dependency, explicitDependency); |
| 8934 } | 8909 } |
| 8935 | 8910 |
| 8936 test_local_names_take_precedence_over_imported_names() { | 8911 test_local_names_take_precedence_over_imported_names() { |
| 8937 addNamedSource('/a.dart', 'class C {} class D {}'); | 8912 addNamedSource('/a.dart', 'class C {} class D {}'); |
| 8938 serializeLibraryText(''' | 8913 serializeLibraryText(''' |
| 8939 import 'a.dart'; | 8914 import 'a.dart'; |
| 8940 class C {} | 8915 class C {} |
| 8941 C c; | 8916 C c; |
| 8942 D d;'''); | 8917 D d;'''); |
| 8943 checkTypeRef(findVariable('c').type, null, null, 'C'); | 8918 checkTypeRef(findVariable('c').type, null, 'C'); |
| 8944 checkTypeRef(findVariable('d').type, absUri('/a.dart'), 'a.dart', 'D'); | 8919 checkTypeRef(findVariable('d').type, absUri('/a.dart'), 'D'); |
| 8945 } | 8920 } |
| 8946 | 8921 |
| 8947 test_localNameShadowsImportPrefix() { | 8922 test_localNameShadowsImportPrefix() { |
| 8948 serializeLibraryText('import "dart:async" as a; class a {}; a x;'); | 8923 serializeLibraryText('import "dart:async" as a; class a {}; a x;'); |
| 8949 checkTypeRef(findVariable('x').type, null, null, 'a'); | 8924 checkTypeRef(findVariable('x').type, null, 'a'); |
| 8950 } | 8925 } |
| 8951 | 8926 |
| 8952 test_metadata_classDeclaration() { | 8927 test_metadata_classDeclaration() { |
| 8953 checkAnnotationA( | 8928 checkAnnotationA( |
| 8954 serializeClassText('const a = null; @a class C {}').annotations); | 8929 serializeClassText('const a = null; @a class C {}').annotations); |
| 8955 } | 8930 } |
| 8956 | 8931 |
| 8957 test_metadata_classTypeAlias() { | 8932 test_metadata_classTypeAlias() { |
| 8958 checkAnnotationA(serializeClassText( | 8933 checkAnnotationA(serializeClassText( |
| 8959 'const a = null; @a class C = D with E; class D {} class E {}', | 8934 'const a = null; @a class C = D with E; class D {} class E {}', |
| 8960 className: 'C') | 8935 className: 'C') |
| 8961 .annotations); | 8936 .annotations); |
| 8962 } | 8937 } |
| 8963 | 8938 |
| 8964 test_metadata_constructor_call_named() { | 8939 test_metadata_constructor_call_named() { |
| 8965 UnlinkedClass cls = serializeClassText( | 8940 UnlinkedClass cls = serializeClassText( |
| 8966 'class A { const A.named(); } @A.named() class C {}'); | 8941 'class A { const A.named(); } @A.named() class C {}'); |
| 8967 expect(cls.annotations, hasLength(1)); | 8942 expect(cls.annotations, hasLength(1)); |
| 8968 assertUnlinkedConst(cls.annotations[0], operators: [ | 8943 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 8969 UnlinkedExprOperation.invokeConstructor, | 8944 UnlinkedExprOperation.invokeConstructor, |
| 8970 ], ints: [ | 8945 ], ints: [ |
| 8971 0, | 8946 0, |
| 8972 0 | 8947 0 |
| 8973 ], referenceValidators: [ | 8948 ], referenceValidators: [ |
| 8974 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8949 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 8975 expectedKind: ReferenceKind.constructor, | 8950 expectedKind: ReferenceKind.constructor, |
| 8976 prefixExpectations: [ | 8951 prefixExpectations: [ |
| 8977 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') | 8952 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') |
| 8978 ]) | 8953 ]) |
| 8979 ]); | 8954 ]); |
| 8980 } | 8955 } |
| 8981 | 8956 |
| 8982 test_metadata_constructor_call_named_prefixed() { | 8957 test_metadata_constructor_call_named_prefixed() { |
| 8983 addNamedSource('/foo.dart', 'class A { const A.named(); }'); | 8958 addNamedSource('/foo.dart', 'class A { const A.named(); }'); |
| 8984 UnlinkedClass cls = serializeClassText( | 8959 UnlinkedClass cls = serializeClassText( |
| 8985 'import "foo.dart" as foo; @foo.A.named() class C {}'); | 8960 'import "foo.dart" as foo; @foo.A.named() class C {}'); |
| 8986 expect(cls.annotations, hasLength(1)); | 8961 expect(cls.annotations, hasLength(1)); |
| 8987 assertUnlinkedConst(cls.annotations[0], operators: [ | 8962 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 8988 UnlinkedExprOperation.invokeConstructor, | 8963 UnlinkedExprOperation.invokeConstructor, |
| 8989 ], ints: [ | 8964 ], ints: [ |
| 8990 0, | 8965 0, |
| 8991 0 | 8966 0 |
| 8992 ], referenceValidators: [ | 8967 ], referenceValidators: [ |
| 8993 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8968 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 8994 expectedKind: ReferenceKind.constructor, | 8969 expectedKind: ReferenceKind.constructor, |
| 8995 prefixExpectations: [ | 8970 prefixExpectations: [ |
| 8996 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', | 8971 new _PrefixExpectation( |
| 8997 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), | 8972 ReferenceKind.classOrEnum, |
| 8973 'A', |
| 8974 absoluteUri: absUri('/foo.dart'), |
| 8975 ), |
| 8998 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 8976 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
| 8999 ]) | 8977 ]) |
| 9000 ]); | 8978 ]); |
| 9001 } | 8979 } |
| 9002 | 8980 |
| 9003 test_metadata_constructor_call_named_prefixed_unresolved_class() { | 8981 test_metadata_constructor_call_named_prefixed_unresolved_class() { |
| 9004 addNamedSource('/foo.dart', ''); | 8982 addNamedSource('/foo.dart', ''); |
| 9005 UnlinkedClass cls = serializeClassText( | 8983 UnlinkedClass cls = serializeClassText( |
| 9006 'import "foo.dart" as foo; @foo.A.named() class C {}', | 8984 'import "foo.dart" as foo; @foo.A.named() class C {}', |
| 9007 allowErrors: true); | 8985 allowErrors: true); |
| 9008 expect(cls.annotations, hasLength(1)); | 8986 expect(cls.annotations, hasLength(1)); |
| 9009 assertUnlinkedConst(cls.annotations[0], operators: [ | 8987 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9010 UnlinkedExprOperation.invokeConstructor, | 8988 UnlinkedExprOperation.invokeConstructor, |
| 9011 ], ints: [ | 8989 ], ints: [ |
| 9012 0, | 8990 0, |
| 9013 0 | 8991 0 |
| 9014 ], referenceValidators: [ | 8992 ], referenceValidators: [ |
| 9015 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 8993 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 9016 expectedKind: ReferenceKind.unresolved, | 8994 expectedKind: ReferenceKind.unresolved, |
| 9017 prefixExpectations: [ | 8995 prefixExpectations: [ |
| 9018 new _PrefixExpectation(ReferenceKind.unresolved, 'A'), | 8996 new _PrefixExpectation(ReferenceKind.unresolved, 'A'), |
| 9019 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 8997 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
| 9020 ]) | 8998 ]) |
| 9021 ]); | 8999 ]); |
| 9022 } | 9000 } |
| 9023 | 9001 |
| 9024 test_metadata_constructor_call_named_prefixed_unresolved_constructor() { | 9002 test_metadata_constructor_call_named_prefixed_unresolved_constructor() { |
| 9025 addNamedSource('/foo.dart', 'class A {}'); | 9003 addNamedSource('/foo.dart', 'class A {}'); |
| 9026 UnlinkedClass cls = serializeClassText( | 9004 UnlinkedClass cls = serializeClassText( |
| 9027 'import "foo.dart" as foo; @foo.A.named() class C {}', | 9005 'import "foo.dart" as foo; @foo.A.named() class C {}', |
| 9028 allowErrors: true); | 9006 allowErrors: true); |
| 9029 expect(cls.annotations, hasLength(1)); | 9007 expect(cls.annotations, hasLength(1)); |
| 9030 assertUnlinkedConst(cls.annotations[0], operators: [ | 9008 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9031 UnlinkedExprOperation.invokeConstructor, | 9009 UnlinkedExprOperation.invokeConstructor, |
| 9032 ], ints: [ | 9010 ], ints: [ |
| 9033 0, | 9011 0, |
| 9034 0 | 9012 0 |
| 9035 ], referenceValidators: [ | 9013 ], referenceValidators: [ |
| 9036 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 9014 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 9037 expectedKind: ReferenceKind.unresolved, | 9015 expectedKind: ReferenceKind.unresolved, |
| 9038 prefixExpectations: [ | 9016 prefixExpectations: [ |
| 9039 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A', | 9017 new _PrefixExpectation( |
| 9040 absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'), | 9018 ReferenceKind.classOrEnum, |
| 9019 'A', |
| 9020 absoluteUri: absUri('/foo.dart'), |
| 9021 ), |
| 9041 new _PrefixExpectation(ReferenceKind.prefix, 'foo') | 9022 new _PrefixExpectation(ReferenceKind.prefix, 'foo') |
| 9042 ]) | 9023 ]) |
| 9043 ]); | 9024 ]); |
| 9044 } | 9025 } |
| 9045 | 9026 |
| 9046 test_metadata_constructor_call_named_unresolved_class() { | 9027 test_metadata_constructor_call_named_unresolved_class() { |
| 9047 UnlinkedClass cls = | 9028 UnlinkedClass cls = |
| 9048 serializeClassText('@A.named() class C {}', allowErrors: true); | 9029 serializeClassText('@A.named() class C {}', allowErrors: true); |
| 9049 expect(cls.annotations, hasLength(1)); | 9030 expect(cls.annotations, hasLength(1)); |
| 9050 assertUnlinkedConst(cls.annotations[0], operators: [ | 9031 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9051 UnlinkedExprOperation.invokeConstructor, | 9032 UnlinkedExprOperation.invokeConstructor, |
| 9052 ], ints: [ | 9033 ], ints: [ |
| 9053 0, | 9034 0, |
| 9054 0 | 9035 0 |
| 9055 ], referenceValidators: [ | 9036 ], referenceValidators: [ |
| 9056 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 9037 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 9057 expectedKind: ReferenceKind.unresolved, | 9038 expectedKind: ReferenceKind.unresolved, |
| 9058 prefixExpectations: [ | 9039 prefixExpectations: [ |
| 9059 new _PrefixExpectation(ReferenceKind.unresolved, 'A') | 9040 new _PrefixExpectation(ReferenceKind.unresolved, 'A') |
| 9060 ]) | 9041 ]) |
| 9061 ]); | 9042 ]); |
| 9062 } | 9043 } |
| 9063 | 9044 |
| 9064 test_metadata_constructor_call_named_unresolved_constructor() { | 9045 test_metadata_constructor_call_named_unresolved_constructor() { |
| 9065 UnlinkedClass cls = serializeClassText('class A {} @A.named() class C {}', | 9046 UnlinkedClass cls = serializeClassText('class A {} @A.named() class C {}', |
| 9066 allowErrors: true); | 9047 allowErrors: true); |
| 9067 expect(cls.annotations, hasLength(1)); | 9048 expect(cls.annotations, hasLength(1)); |
| 9068 assertUnlinkedConst(cls.annotations[0], operators: [ | 9049 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9069 UnlinkedExprOperation.invokeConstructor, | 9050 UnlinkedExprOperation.invokeConstructor, |
| 9070 ], ints: [ | 9051 ], ints: [ |
| 9071 0, | 9052 0, |
| 9072 0 | 9053 0 |
| 9073 ], referenceValidators: [ | 9054 ], referenceValidators: [ |
| 9074 (EntityRef r) => checkTypeRef(r, null, null, 'named', | 9055 (EntityRef r) => checkTypeRef(r, null, 'named', |
| 9075 expectedKind: ReferenceKind.unresolved, | 9056 expectedKind: ReferenceKind.unresolved, |
| 9076 prefixExpectations: [ | 9057 prefixExpectations: [ |
| 9077 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') | 9058 new _PrefixExpectation(ReferenceKind.classOrEnum, 'A') |
| 9078 ]) | 9059 ]) |
| 9079 ]); | 9060 ]); |
| 9080 } | 9061 } |
| 9081 | 9062 |
| 9082 test_metadata_constructor_call_unnamed() { | 9063 test_metadata_constructor_call_unnamed() { |
| 9083 UnlinkedClass cls = | 9064 UnlinkedClass cls = |
| 9084 serializeClassText('class A { const A(); } @A() class C {}'); | 9065 serializeClassText('class A { const A(); } @A() class C {}'); |
| 9085 expect(cls.annotations, hasLength(1)); | 9066 expect(cls.annotations, hasLength(1)); |
| 9086 assertUnlinkedConst(cls.annotations[0], operators: [ | 9067 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9087 UnlinkedExprOperation.invokeConstructor, | 9068 UnlinkedExprOperation.invokeConstructor, |
| 9088 ], ints: [ | 9069 ], ints: [ |
| 9089 0, | 9070 0, |
| 9090 0 | 9071 0 |
| 9091 ], referenceValidators: [ | 9072 ], referenceValidators: [ |
| 9092 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9073 (EntityRef r) => |
| 9093 expectedKind: ReferenceKind.classOrEnum) | 9074 checkTypeRef(r, null, 'A', expectedKind: ReferenceKind.classOrEnum) |
| 9094 ]); | 9075 ]); |
| 9095 } | 9076 } |
| 9096 | 9077 |
| 9097 test_metadata_constructor_call_unnamed_prefixed() { | 9078 test_metadata_constructor_call_unnamed_prefixed() { |
| 9098 addNamedSource('/foo.dart', 'class A { const A(); }'); | 9079 addNamedSource('/foo.dart', 'class A { const A(); }'); |
| 9099 UnlinkedClass cls = | 9080 UnlinkedClass cls = |
| 9100 serializeClassText('import "foo.dart" as foo; @foo.A() class C {}'); | 9081 serializeClassText('import "foo.dart" as foo; @foo.A() class C {}'); |
| 9101 expect(cls.annotations, hasLength(1)); | 9082 expect(cls.annotations, hasLength(1)); |
| 9102 assertUnlinkedConst(cls.annotations[0], operators: [ | 9083 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9103 UnlinkedExprOperation.invokeConstructor, | 9084 UnlinkedExprOperation.invokeConstructor, |
| 9104 ], ints: [ | 9085 ], ints: [ |
| 9105 0, | 9086 0, |
| 9106 0 | 9087 0 |
| 9107 ], referenceValidators: [ | 9088 ], referenceValidators: [ |
| 9108 (EntityRef r) => checkTypeRef(r, absUri('/foo.dart'), 'foo.dart', 'A', | 9089 (EntityRef r) => checkTypeRef(r, absUri('/foo.dart'), 'A', |
| 9109 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'foo') | 9090 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'foo') |
| 9110 ]); | 9091 ]); |
| 9111 } | 9092 } |
| 9112 | 9093 |
| 9113 test_metadata_constructor_call_unnamed_prefixed_unresolved() { | 9094 test_metadata_constructor_call_unnamed_prefixed_unresolved() { |
| 9114 addNamedSource('/foo.dart', ''); | 9095 addNamedSource('/foo.dart', ''); |
| 9115 UnlinkedClass cls = serializeClassText( | 9096 UnlinkedClass cls = serializeClassText( |
| 9116 'import "foo.dart" as foo; @foo.A() class C {}', | 9097 'import "foo.dart" as foo; @foo.A() class C {}', |
| 9117 allowErrors: true); | 9098 allowErrors: true); |
| 9118 expect(cls.annotations, hasLength(1)); | 9099 expect(cls.annotations, hasLength(1)); |
| 9119 assertUnlinkedConst(cls.annotations[0], operators: [ | 9100 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9120 UnlinkedExprOperation.invokeConstructor, | 9101 UnlinkedExprOperation.invokeConstructor, |
| 9121 ], ints: [ | 9102 ], ints: [ |
| 9122 0, | 9103 0, |
| 9123 0 | 9104 0 |
| 9124 ], referenceValidators: [ | 9105 ], referenceValidators: [ |
| 9125 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9106 (EntityRef r) => checkTypeRef(r, null, 'A', |
| 9126 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'foo') | 9107 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'foo') |
| 9127 ]); | 9108 ]); |
| 9128 } | 9109 } |
| 9129 | 9110 |
| 9130 test_metadata_constructor_call_unnamed_unresolved() { | 9111 test_metadata_constructor_call_unnamed_unresolved() { |
| 9131 UnlinkedClass cls = | 9112 UnlinkedClass cls = |
| 9132 serializeClassText('@A() class C {}', allowErrors: true); | 9113 serializeClassText('@A() class C {}', allowErrors: true); |
| 9133 expect(cls.annotations, hasLength(1)); | 9114 expect(cls.annotations, hasLength(1)); |
| 9134 assertUnlinkedConst(cls.annotations[0], operators: [ | 9115 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9135 UnlinkedExprOperation.invokeConstructor, | 9116 UnlinkedExprOperation.invokeConstructor, |
| 9136 ], ints: [ | 9117 ], ints: [ |
| 9137 0, | 9118 0, |
| 9138 0 | 9119 0 |
| 9139 ], referenceValidators: [ | 9120 ], referenceValidators: [ |
| 9140 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9121 (EntityRef r) => |
| 9141 expectedKind: ReferenceKind.unresolved) | 9122 checkTypeRef(r, null, 'A', expectedKind: ReferenceKind.unresolved) |
| 9142 ]); | 9123 ]); |
| 9143 } | 9124 } |
| 9144 | 9125 |
| 9145 test_metadata_constructor_call_with_args() { | 9126 test_metadata_constructor_call_with_args() { |
| 9146 UnlinkedClass cls = | 9127 UnlinkedClass cls = |
| 9147 serializeClassText('class A { const A(x); } @A(null) class C {}'); | 9128 serializeClassText('class A { const A(x); } @A(null) class C {}'); |
| 9148 expect(cls.annotations, hasLength(1)); | 9129 expect(cls.annotations, hasLength(1)); |
| 9149 assertUnlinkedConst(cls.annotations[0], operators: [ | 9130 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9150 UnlinkedExprOperation.pushNull, | 9131 UnlinkedExprOperation.pushNull, |
| 9151 UnlinkedExprOperation.invokeConstructor, | 9132 UnlinkedExprOperation.invokeConstructor, |
| 9152 ], ints: [ | 9133 ], ints: [ |
| 9153 0, | 9134 0, |
| 9154 1 | 9135 1 |
| 9155 ], referenceValidators: [ | 9136 ], referenceValidators: [ |
| 9156 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9137 (EntityRef r) => |
| 9157 expectedKind: ReferenceKind.classOrEnum) | 9138 checkTypeRef(r, null, 'A', expectedKind: ReferenceKind.classOrEnum) |
| 9158 ]); | 9139 ]); |
| 9159 } | 9140 } |
| 9160 | 9141 |
| 9161 test_metadata_constructorDeclaration_named() { | 9142 test_metadata_constructorDeclaration_named() { |
| 9162 checkAnnotationA( | 9143 checkAnnotationA( |
| 9163 serializeClassText('const a = null; class C { @a C.named(); }') | 9144 serializeClassText('const a = null; class C { @a C.named(); }') |
| 9164 .executables[0] | 9145 .executables[0] |
| 9165 .annotations); | 9146 .annotations); |
| 9166 } | 9147 } |
| 9167 | 9148 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9256 class C {} | 9237 class C {} |
| 9257 ''').annotations; | 9238 ''').annotations; |
| 9258 expect(annotations, hasLength(1)); | 9239 expect(annotations, hasLength(1)); |
| 9259 assertUnlinkedConst(annotations[0], operators: [ | 9240 assertUnlinkedConst(annotations[0], operators: [ |
| 9260 UnlinkedExprOperation.pushSuper, | 9241 UnlinkedExprOperation.pushSuper, |
| 9261 UnlinkedExprOperation.invokeConstructor, | 9242 UnlinkedExprOperation.invokeConstructor, |
| 9262 ], ints: [ | 9243 ], ints: [ |
| 9263 0, | 9244 0, |
| 9264 1 | 9245 1 |
| 9265 ], referenceValidators: [ | 9246 ], referenceValidators: [ |
| 9266 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9247 (EntityRef r) => |
| 9267 expectedKind: ReferenceKind.classOrEnum) | 9248 checkTypeRef(r, null, 'A', expectedKind: ReferenceKind.classOrEnum) |
| 9268 ]); | 9249 ]); |
| 9269 } | 9250 } |
| 9270 | 9251 |
| 9271 test_metadata_invalid_instanceCreation_argument_this() { | 9252 test_metadata_invalid_instanceCreation_argument_this() { |
| 9272 List<UnlinkedExpr> annotations = serializeClassText(''' | 9253 List<UnlinkedExpr> annotations = serializeClassText(''' |
| 9273 class A { | 9254 class A { |
| 9274 const A(_); | 9255 const A(_); |
| 9275 } | 9256 } |
| 9276 | 9257 |
| 9277 @A(this) | 9258 @A(this) |
| 9278 class C {} | 9259 class C {} |
| 9279 ''').annotations; | 9260 ''').annotations; |
| 9280 expect(annotations, hasLength(1)); | 9261 expect(annotations, hasLength(1)); |
| 9281 assertUnlinkedConst(annotations[0], operators: [ | 9262 assertUnlinkedConst(annotations[0], operators: [ |
| 9282 UnlinkedExprOperation.pushThis, | 9263 UnlinkedExprOperation.pushThis, |
| 9283 UnlinkedExprOperation.invokeConstructor, | 9264 UnlinkedExprOperation.invokeConstructor, |
| 9284 ], ints: [ | 9265 ], ints: [ |
| 9285 0, | 9266 0, |
| 9286 1 | 9267 1 |
| 9287 ], referenceValidators: [ | 9268 ], referenceValidators: [ |
| 9288 (EntityRef r) => checkTypeRef(r, null, null, 'A', | 9269 (EntityRef r) => |
| 9289 expectedKind: ReferenceKind.classOrEnum) | 9270 checkTypeRef(r, null, 'A', expectedKind: ReferenceKind.classOrEnum) |
| 9290 ]); | 9271 ]); |
| 9291 } | 9272 } |
| 9292 | 9273 |
| 9293 test_metadata_libraryDirective() { | 9274 test_metadata_libraryDirective() { |
| 9294 serializeLibraryText('@a library L; const a = null;'); | 9275 serializeLibraryText('@a library L; const a = null;'); |
| 9295 checkAnnotationA(unlinkedUnits[0].libraryAnnotations); | 9276 checkAnnotationA(unlinkedUnits[0].libraryAnnotations); |
| 9296 } | 9277 } |
| 9297 | 9278 |
| 9298 test_metadata_methodDeclaration_getter() { | 9279 test_metadata_methodDeclaration_getter() { |
| 9299 checkAnnotationA( | 9280 checkAnnotationA( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 9316 } | 9297 } |
| 9317 | 9298 |
| 9318 test_metadata_multiple_annotations() { | 9299 test_metadata_multiple_annotations() { |
| 9319 UnlinkedClass cls = | 9300 UnlinkedClass cls = |
| 9320 serializeClassText('const a = null, b = null; @a @b class C {}'); | 9301 serializeClassText('const a = null, b = null; @a @b class C {}'); |
| 9321 List<UnlinkedExpr> annotations = cls.annotations; | 9302 List<UnlinkedExpr> annotations = cls.annotations; |
| 9322 expect(annotations, hasLength(2)); | 9303 expect(annotations, hasLength(2)); |
| 9323 assertUnlinkedConst(annotations[0], operators: [ | 9304 assertUnlinkedConst(annotations[0], operators: [ |
| 9324 UnlinkedExprOperation.pushReference | 9305 UnlinkedExprOperation.pushReference |
| 9325 ], referenceValidators: [ | 9306 ], referenceValidators: [ |
| 9326 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9307 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 9327 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9308 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 9328 ]); | 9309 ]); |
| 9329 assertUnlinkedConst(annotations[1], operators: [ | 9310 assertUnlinkedConst(annotations[1], operators: [ |
| 9330 UnlinkedExprOperation.pushReference | 9311 UnlinkedExprOperation.pushReference |
| 9331 ], referenceValidators: [ | 9312 ], referenceValidators: [ |
| 9332 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 9313 (EntityRef r) => checkTypeRef(r, null, 'b', |
| 9333 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9314 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 9334 ]); | 9315 ]); |
| 9335 } | 9316 } |
| 9336 | 9317 |
| 9337 test_metadata_partDirective() { | 9318 test_metadata_partDirective() { |
| 9338 addNamedSource('/foo.dart', 'part of L;'); | 9319 addNamedSource('/foo.dart', 'part of L;'); |
| 9339 serializeLibraryText('library L; @a part "foo.dart"; const a = null;'); | 9320 serializeLibraryText('library L; @a part "foo.dart"; const a = null;'); |
| 9340 checkAnnotationA(unlinkedUnits[0].parts[0].annotations); | 9321 checkAnnotationA(unlinkedUnits[0].parts[0].annotations); |
| 9341 } | 9322 } |
| 9342 | 9323 |
| 9343 test_metadata_prefixed_variable() { | 9324 test_metadata_prefixed_variable() { |
| 9344 addNamedSource('/a.dart', 'const b = null;'); | 9325 addNamedSource('/a.dart', 'const b = null;'); |
| 9345 UnlinkedClass cls = | 9326 UnlinkedClass cls = |
| 9346 serializeClassText('import "a.dart" as a; @a.b class C {}'); | 9327 serializeClassText('import "a.dart" as a; @a.b class C {}'); |
| 9347 expect(cls.annotations, hasLength(1)); | 9328 expect(cls.annotations, hasLength(1)); |
| 9348 assertUnlinkedConst(cls.annotations[0], operators: [ | 9329 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9349 UnlinkedExprOperation.pushReference | 9330 UnlinkedExprOperation.pushReference |
| 9350 ], referenceValidators: [ | 9331 ], referenceValidators: [ |
| 9351 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'b', | 9332 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'b', |
| 9352 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 9333 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 9353 expectedPrefix: 'a') | 9334 expectedPrefix: 'a') |
| 9354 ]); | 9335 ]); |
| 9355 } | 9336 } |
| 9356 | 9337 |
| 9357 test_metadata_prefixed_variable_unresolved() { | 9338 test_metadata_prefixed_variable_unresolved() { |
| 9358 addNamedSource('/a.dart', ''); | 9339 addNamedSource('/a.dart', ''); |
| 9359 UnlinkedClass cls = serializeClassText( | 9340 UnlinkedClass cls = serializeClassText( |
| 9360 'import "a.dart" as a; @a.b class C {}', | 9341 'import "a.dart" as a; @a.b class C {}', |
| 9361 allowErrors: true); | 9342 allowErrors: true); |
| 9362 expect(cls.annotations, hasLength(1)); | 9343 expect(cls.annotations, hasLength(1)); |
| 9363 assertUnlinkedConst(cls.annotations[0], operators: [ | 9344 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9364 UnlinkedExprOperation.pushReference | 9345 UnlinkedExprOperation.pushReference |
| 9365 ], referenceValidators: [ | 9346 ], referenceValidators: [ |
| 9366 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 9347 (EntityRef r) => checkTypeRef(r, null, 'b', |
| 9367 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'a') | 9348 expectedKind: ReferenceKind.unresolved, expectedPrefix: 'a') |
| 9368 ]); | 9349 ]); |
| 9369 } | 9350 } |
| 9370 | 9351 |
| 9371 test_metadata_simpleFormalParameter() { | 9352 test_metadata_simpleFormalParameter() { |
| 9372 checkAnnotationA(serializeExecutableText('const a = null; f(@a x) {}') | 9353 checkAnnotationA(serializeExecutableText('const a = null; f(@a x) {}') |
| 9373 .parameters[0] | 9354 .parameters[0] |
| 9374 .annotations); | 9355 .annotations); |
| 9375 } | 9356 } |
| 9376 | 9357 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9411 .typeParameters[0] | 9392 .typeParameters[0] |
| 9412 .annotations); | 9393 .annotations); |
| 9413 } | 9394 } |
| 9414 | 9395 |
| 9415 test_metadata_variable_unresolved() { | 9396 test_metadata_variable_unresolved() { |
| 9416 UnlinkedClass cls = serializeClassText('@a class C {}', allowErrors: true); | 9397 UnlinkedClass cls = serializeClassText('@a class C {}', allowErrors: true); |
| 9417 expect(cls.annotations, hasLength(1)); | 9398 expect(cls.annotations, hasLength(1)); |
| 9418 assertUnlinkedConst(cls.annotations[0], operators: [ | 9399 assertUnlinkedConst(cls.annotations[0], operators: [ |
| 9419 UnlinkedExprOperation.pushReference | 9400 UnlinkedExprOperation.pushReference |
| 9420 ], referenceValidators: [ | 9401 ], referenceValidators: [ |
| 9421 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9402 (EntityRef r) => |
| 9422 expectedKind: ReferenceKind.unresolved) | 9403 checkTypeRef(r, null, 'a', expectedKind: ReferenceKind.unresolved) |
| 9423 ]); | 9404 ]); |
| 9424 } | 9405 } |
| 9425 | 9406 |
| 9426 test_method_documented() { | 9407 test_method_documented() { |
| 9427 if (!includeInformative) return; | 9408 if (!includeInformative) return; |
| 9428 String text = ''' | 9409 String text = ''' |
| 9429 class C { | 9410 class C { |
| 9430 /** | 9411 /** |
| 9431 * Docs | 9412 * Docs |
| 9432 */ | 9413 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 9454 .executables[0]; | 9435 .executables[0]; |
| 9455 expect(f.inferredReturnTypeSlot, 0); | 9436 expect(f.inferredReturnTypeSlot, 0); |
| 9456 } | 9437 } |
| 9457 | 9438 |
| 9458 test_method_inferred_type_nonstatic_implicit_param() { | 9439 test_method_inferred_type_nonstatic_implicit_param() { |
| 9459 UnlinkedExecutable f = serializeClassText( | 9440 UnlinkedExecutable f = serializeClassText( |
| 9460 'class C extends D { void f(value) {} }' | 9441 'class C extends D { void f(value) {} }' |
| 9461 ' abstract class D { void f(int value); }', | 9442 ' abstract class D { void f(int value); }', |
| 9462 className: 'C') | 9443 className: 'C') |
| 9463 .executables[0]; | 9444 .executables[0]; |
| 9464 checkInferredTypeSlot( | 9445 checkInferredTypeSlot(f.parameters[0].inferredTypeSlot, 'dart:core', 'int'); |
| 9465 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | |
| 9466 } | 9446 } |
| 9467 | 9447 |
| 9468 test_method_inferred_type_nonstatic_implicit_return() { | 9448 test_method_inferred_type_nonstatic_implicit_return() { |
| 9469 UnlinkedExecutable f = serializeClassText( | 9449 UnlinkedExecutable f = serializeClassText( |
| 9470 'class C extends D { f() => null; } abstract class D { int f(); }', | 9450 'class C extends D { f() => null; } abstract class D { int f(); }', |
| 9471 className: 'C') | 9451 className: 'C') |
| 9472 .executables[0]; | 9452 .executables[0]; |
| 9473 checkInferredTypeSlot( | 9453 checkInferredTypeSlot(f.inferredReturnTypeSlot, 'dart:core', 'int'); |
| 9474 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int'); | |
| 9475 } | 9454 } |
| 9476 | 9455 |
| 9477 test_method_inferred_type_static_implicit_param() { | 9456 test_method_inferred_type_static_implicit_param() { |
| 9478 UnlinkedExecutable f = serializeClassText( | 9457 UnlinkedExecutable f = serializeClassText( |
| 9479 'class C extends D { static void f(value) {} }' | 9458 'class C extends D { static void f(value) {} }' |
| 9480 ' class D { static void f(int value) {} }', | 9459 ' class D { static void f(int value) {} }', |
| 9481 className: 'C') | 9460 className: 'C') |
| 9482 .executables[0]; | 9461 .executables[0]; |
| 9483 expect(f.parameters[0].inferredTypeSlot, 0); | 9462 expect(f.parameters[0].inferredTypeSlot, 0); |
| 9484 } | 9463 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9697 .executables[0]; | 9676 .executables[0]; |
| 9698 expect(f.inferredReturnTypeSlot, 0); | 9677 expect(f.inferredReturnTypeSlot, 0); |
| 9699 } | 9678 } |
| 9700 | 9679 |
| 9701 test_setter_inferred_type_nonstatic_implicit_param() { | 9680 test_setter_inferred_type_nonstatic_implicit_param() { |
| 9702 UnlinkedExecutable f = serializeClassText( | 9681 UnlinkedExecutable f = serializeClassText( |
| 9703 'class C extends D { void set f(value) {} }' | 9682 'class C extends D { void set f(value) {} }' |
| 9704 ' abstract class D { void set f(int value); }', | 9683 ' abstract class D { void set f(int value); }', |
| 9705 className: 'C') | 9684 className: 'C') |
| 9706 .executables[0]; | 9685 .executables[0]; |
| 9707 checkInferredTypeSlot( | 9686 checkInferredTypeSlot(f.parameters[0].inferredTypeSlot, 'dart:core', 'int'); |
| 9708 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | |
| 9709 } | 9687 } |
| 9710 | 9688 |
| 9711 test_setter_inferred_type_nonstatic_implicit_return() { | 9689 test_setter_inferred_type_nonstatic_implicit_return() { |
| 9712 UnlinkedExecutable f = | 9690 UnlinkedExecutable f = |
| 9713 serializeClassText('class C { set f(int value) {} }').executables[0]; | 9691 serializeClassText('class C { set f(int value) {} }').executables[0]; |
| 9714 checkInferredTypeSlot(f.inferredReturnTypeSlot, null, null, 'void'); | 9692 checkInferredTypeSlot(f.inferredReturnTypeSlot, null, 'void'); |
| 9715 } | 9693 } |
| 9716 | 9694 |
| 9717 test_setter_inferred_type_static_implicit_param() { | 9695 test_setter_inferred_type_static_implicit_param() { |
| 9718 UnlinkedExecutable f = serializeClassText( | 9696 UnlinkedExecutable f = serializeClassText( |
| 9719 'class C extends D { static void set f(value) {} }' | 9697 'class C extends D { static void set f(value) {} }' |
| 9720 ' class D { static void set f(int value) {} }', | 9698 ' class D { static void set f(int value) {} }', |
| 9721 className: 'C') | 9699 className: 'C') |
| 9722 .executables[0]; | 9700 .executables[0]; |
| 9723 expect(f.parameters[0].inferredTypeSlot, 0); | 9701 expect(f.parameters[0].inferredTypeSlot, 0); |
| 9724 } | 9702 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9762 // TODO(paulberry): once proper generic method syntax supports generic | 9740 // TODO(paulberry): once proper generic method syntax supports generic |
| 9763 // closures, rewrite the test below without using generic comment syntax, | 9741 // closures, rewrite the test below without using generic comment syntax, |
| 9764 // and remove this hack. See dartbug.com/25819 | 9742 // and remove this hack. See dartbug.com/25819 |
| 9765 return; | 9743 return; |
| 9766 } | 9744 } |
| 9767 UnlinkedVariable variable = serializeVariableText(''' | 9745 UnlinkedVariable variable = serializeVariableText(''' |
| 9768 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; | 9746 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; |
| 9769 bool f() => true; | 9747 bool f() => true; |
| 9770 '''); | 9748 '''); |
| 9771 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); | 9749 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); |
| 9772 checkLinkedTypeRef( | 9750 checkLinkedTypeRef(inferredType.syntheticReturnType, 'dart:core', 'int'); |
| 9773 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | |
| 9774 expect(inferredType.syntheticParams, hasLength(1)); | 9751 expect(inferredType.syntheticParams, hasLength(1)); |
| 9775 checkLinkedTypeRef( | 9752 checkLinkedTypeRef(inferredType.syntheticParams[0].type, null, '*bottom*'); |
| 9776 inferredType.syntheticParams[0].type, null, null, '*bottom*'); | |
| 9777 } | 9753 } |
| 9778 | 9754 |
| 9779 test_syntheticFunctionType_genericClosure_inGenericFunction() { | 9755 test_syntheticFunctionType_genericClosure_inGenericFunction() { |
| 9780 if (skipFullyLinkedData) { | 9756 if (skipFullyLinkedData) { |
| 9781 return; | 9757 return; |
| 9782 } | 9758 } |
| 9783 if (!strongMode) { | 9759 if (!strongMode) { |
| 9784 // The test below uses generic comment syntax because proper generic | 9760 // The test below uses generic comment syntax because proper generic |
| 9785 // method syntax doesn't support generic closures. So it can only run in | 9761 // method syntax doesn't support generic closures. So it can only run in |
| 9786 // strong mode. | 9762 // strong mode. |
| 9787 // TODO(paulberry): once proper generic method syntax supports generic | 9763 // TODO(paulberry): once proper generic method syntax supports generic |
| 9788 // closures, rewrite the test below without using generic comment syntax, | 9764 // closures, rewrite the test below without using generic comment syntax, |
| 9789 // and remove this hack. See dartbug.com/25819 | 9765 // and remove this hack. See dartbug.com/25819 |
| 9790 return; | 9766 return; |
| 9791 } | 9767 } |
| 9792 UnlinkedVariable variable = serializeExecutableText(''' | 9768 UnlinkedVariable variable = serializeExecutableText(''' |
| 9793 void f<T, U>(bool b) { | 9769 void f<T, U>(bool b) { |
| 9794 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; | 9770 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; |
| 9795 } | 9771 } |
| 9796 ''').localVariables[0]; | 9772 ''').localVariables[0]; |
| 9797 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); | 9773 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); |
| 9798 checkLinkedTypeRef( | 9774 checkLinkedTypeRef(inferredType.syntheticReturnType, 'dart:core', 'int'); |
| 9799 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | |
| 9800 expect(inferredType.syntheticParams, hasLength(3)); | 9775 expect(inferredType.syntheticParams, hasLength(3)); |
| 9801 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); | 9776 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); |
| 9802 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); | 9777 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); |
| 9803 checkLinkedTypeRef( | 9778 checkLinkedTypeRef(inferredType.syntheticParams[2].type, null, '*bottom*'); |
| 9804 inferredType.syntheticParams[2].type, null, null, '*bottom*'); | |
| 9805 } | 9779 } |
| 9806 | 9780 |
| 9807 test_syntheticFunctionType_inGenericClass() { | 9781 test_syntheticFunctionType_inGenericClass() { |
| 9808 if (skipFullyLinkedData) { | 9782 if (skipFullyLinkedData) { |
| 9809 return; | 9783 return; |
| 9810 } | 9784 } |
| 9811 UnlinkedVariable variable = serializeClassText(''' | 9785 UnlinkedVariable variable = serializeClassText(''' |
| 9812 class C<T, U> { | 9786 class C<T, U> { |
| 9813 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; | 9787 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; |
| 9814 } | 9788 } |
| 9815 bool f() => false; | 9789 bool f() => false; |
| 9816 ''').fields[0]; | 9790 ''').fields[0]; |
| 9817 EntityRef inferredType = | 9791 EntityRef inferredType = |
| 9818 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 9792 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 9819 checkLinkedTypeRef( | 9793 checkLinkedTypeRef(inferredType.syntheticReturnType, 'dart:core', 'int'); |
| 9820 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | |
| 9821 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); | 9794 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); |
| 9822 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); | 9795 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); |
| 9823 } | 9796 } |
| 9824 | 9797 |
| 9825 test_syntheticFunctionType_inGenericFunction() { | 9798 test_syntheticFunctionType_inGenericFunction() { |
| 9826 if (skipFullyLinkedData) { | 9799 if (skipFullyLinkedData) { |
| 9827 return; | 9800 return; |
| 9828 } | 9801 } |
| 9829 UnlinkedVariable variable = serializeExecutableText(''' | 9802 UnlinkedVariable variable = serializeExecutableText(''' |
| 9830 void f<T, U>(bool b) { | 9803 void f<T, U>(bool b) { |
| 9831 var v = b ? (T t, U u) => 0 : (T t, U u) => 1; | 9804 var v = b ? (T t, U u) => 0 : (T t, U u) => 1; |
| 9832 } | 9805 } |
| 9833 ''').localVariables[0]; | 9806 ''').localVariables[0]; |
| 9834 EntityRef inferredType = | 9807 EntityRef inferredType = |
| 9835 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 9808 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 9836 checkLinkedTypeRef( | 9809 checkLinkedTypeRef(inferredType.syntheticReturnType, 'dart:core', 'int'); |
| 9837 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | |
| 9838 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); | 9810 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); |
| 9839 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); | 9811 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); |
| 9840 } | 9812 } |
| 9841 | 9813 |
| 9842 test_type_arguments_explicit() { | 9814 test_type_arguments_explicit() { |
| 9843 EntityRef typeRef = serializeTypeText('List<int>'); | 9815 EntityRef typeRef = serializeTypeText('List<int>'); |
| 9844 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9816 checkTypeRef(typeRef, 'dart:core', 'List', |
| 9845 numTypeParameters: 1, numTypeArguments: 1); | 9817 numTypeParameters: 1, numTypeArguments: 1); |
| 9846 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9818 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'int'); |
| 9847 } | 9819 } |
| 9848 | 9820 |
| 9849 test_type_arguments_explicit_dynamic() { | 9821 test_type_arguments_explicit_dynamic() { |
| 9850 EntityRef typeRef = serializeTypeText('List<dynamic>'); | 9822 EntityRef typeRef = serializeTypeText('List<dynamic>'); |
| 9851 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9823 checkTypeRef(typeRef, 'dart:core', 'List', |
| 9852 numTypeParameters: 1, numTypeArguments: 1); | 9824 numTypeParameters: 1, numTypeArguments: 1); |
| 9853 checkDynamicTypeRef(typeRef.typeArguments[0]); | 9825 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9854 } | 9826 } |
| 9855 | 9827 |
| 9856 test_type_arguments_explicit_dynamic_dynamic() { | 9828 test_type_arguments_explicit_dynamic_dynamic() { |
| 9857 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); | 9829 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); |
| 9858 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9830 checkTypeRef(typeRef, 'dart:core', 'Map', |
| 9859 numTypeParameters: 2, numTypeArguments: 2); | 9831 numTypeParameters: 2, numTypeArguments: 2); |
| 9860 checkDynamicTypeRef(typeRef.typeArguments[0]); | 9832 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9861 checkDynamicTypeRef(typeRef.typeArguments[1]); | 9833 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 9862 } | 9834 } |
| 9863 | 9835 |
| 9864 test_type_arguments_explicit_dynamic_int() { | 9836 test_type_arguments_explicit_dynamic_int() { |
| 9865 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); | 9837 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); |
| 9866 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9838 checkTypeRef(typeRef, 'dart:core', 'Map', |
| 9867 numTypeParameters: 2, numTypeArguments: 2); | 9839 numTypeParameters: 2, numTypeArguments: 2); |
| 9868 checkDynamicTypeRef(typeRef.typeArguments[0]); | 9840 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9869 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 9841 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'int'); |
| 9870 } | 9842 } |
| 9871 | 9843 |
| 9872 test_type_arguments_explicit_dynamic_typedef() { | 9844 test_type_arguments_explicit_dynamic_typedef() { |
| 9873 EntityRef typeRef = | 9845 EntityRef typeRef = |
| 9874 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); | 9846 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); |
| 9875 checkTypeRef(typeRef, null, null, 'F', | 9847 checkTypeRef(typeRef, null, 'F', |
| 9876 expectedKind: ReferenceKind.typedef, | 9848 expectedKind: ReferenceKind.typedef, |
| 9877 numTypeParameters: 1, | 9849 numTypeParameters: 1, |
| 9878 numTypeArguments: 1); | 9850 numTypeArguments: 1); |
| 9879 checkDynamicTypeRef(typeRef.typeArguments[0]); | 9851 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9880 } | 9852 } |
| 9881 | 9853 |
| 9882 test_type_arguments_explicit_String_dynamic() { | 9854 test_type_arguments_explicit_String_dynamic() { |
| 9883 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); | 9855 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); |
| 9884 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9856 checkTypeRef(typeRef, 'dart:core', 'Map', |
| 9885 numTypeParameters: 2, numTypeArguments: 2); | 9857 numTypeParameters: 2, numTypeArguments: 2); |
| 9886 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 9858 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'String'); |
| 9887 checkDynamicTypeRef(typeRef.typeArguments[1]); | 9859 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 9888 } | 9860 } |
| 9889 | 9861 |
| 9890 test_type_arguments_explicit_String_int() { | 9862 test_type_arguments_explicit_String_int() { |
| 9891 EntityRef typeRef = serializeTypeText('Map<String, int>'); | 9863 EntityRef typeRef = serializeTypeText('Map<String, int>'); |
| 9892 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9864 checkTypeRef(typeRef, 'dart:core', 'Map', |
| 9893 numTypeParameters: 2, numTypeArguments: 2); | 9865 numTypeParameters: 2, numTypeArguments: 2); |
| 9894 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 9866 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'String'); |
| 9895 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 9867 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'int'); |
| 9896 } | 9868 } |
| 9897 | 9869 |
| 9898 test_type_arguments_explicit_typedef() { | 9870 test_type_arguments_explicit_typedef() { |
| 9899 EntityRef typeRef = | 9871 EntityRef typeRef = |
| 9900 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); | 9872 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); |
| 9901 checkTypeRef(typeRef, null, null, 'F', | 9873 checkTypeRef(typeRef, null, 'F', |
| 9902 expectedKind: ReferenceKind.typedef, | 9874 expectedKind: ReferenceKind.typedef, |
| 9903 numTypeParameters: 1, | 9875 numTypeParameters: 1, |
| 9904 numTypeArguments: 1); | 9876 numTypeArguments: 1); |
| 9905 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9877 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'int'); |
| 9906 } | 9878 } |
| 9907 | 9879 |
| 9908 test_type_arguments_implicit() { | 9880 test_type_arguments_implicit() { |
| 9909 EntityRef typeRef = serializeTypeText('List'); | 9881 EntityRef typeRef = serializeTypeText('List'); |
| 9910 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9882 checkTypeRef(typeRef, 'dart:core', 'List', numTypeParameters: 1); |
| 9911 numTypeParameters: 1); | |
| 9912 } | 9883 } |
| 9913 | 9884 |
| 9914 test_type_arguments_implicit_typedef() { | 9885 test_type_arguments_implicit_typedef() { |
| 9915 EntityRef typeRef = | 9886 EntityRef typeRef = |
| 9916 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); | 9887 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); |
| 9917 checkTypeRef(typeRef, null, null, 'F', | 9888 checkTypeRef(typeRef, null, 'F', |
| 9918 expectedKind: ReferenceKind.typedef, numTypeParameters: 1); | 9889 expectedKind: ReferenceKind.typedef, numTypeParameters: 1); |
| 9919 } | 9890 } |
| 9920 | 9891 |
| 9921 test_type_arguments_implicit_typedef_withBound() { | 9892 test_type_arguments_implicit_typedef_withBound() { |
| 9922 EntityRef typeRef = serializeTypeText('F', | 9893 EntityRef typeRef = serializeTypeText('F', |
| 9923 otherDeclarations: 'typedef T F<T extends num>();'); | 9894 otherDeclarations: 'typedef T F<T extends num>();'); |
| 9924 checkTypeRef(typeRef, null, null, 'F', | 9895 checkTypeRef(typeRef, null, 'F', |
| 9925 expectedKind: ReferenceKind.typedef, numTypeParameters: 1); | 9896 expectedKind: ReferenceKind.typedef, numTypeParameters: 1); |
| 9926 } | 9897 } |
| 9927 | 9898 |
| 9928 test_type_arguments_order() { | 9899 test_type_arguments_order() { |
| 9929 EntityRef typeRef = serializeTypeText('Map<int, Object>'); | 9900 EntityRef typeRef = serializeTypeText('Map<int, Object>'); |
| 9930 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9901 checkTypeRef(typeRef, 'dart:core', 'Map', |
| 9931 numTypeParameters: 2, numTypeArguments: 2); | 9902 numTypeParameters: 2, numTypeArguments: 2); |
| 9932 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9903 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'int'); |
| 9933 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); | 9904 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'Object'); |
| 9934 } | 9905 } |
| 9935 | 9906 |
| 9936 test_type_dynamic() { | 9907 test_type_dynamic() { |
| 9937 checkDynamicTypeRef(serializeTypeText('dynamic')); | 9908 checkDynamicTypeRef(serializeTypeText('dynamic')); |
| 9938 } | 9909 } |
| 9939 | 9910 |
| 9940 test_type_invalid_typeParameter_asPrefix() { | 9911 test_type_invalid_typeParameter_asPrefix() { |
| 9941 UnlinkedClass c = serializeClassText(''' | 9912 UnlinkedClass c = serializeClassText(''' |
| 9942 class C<T> { | 9913 class C<T> { |
| 9943 m(T.K p) {} | 9914 m(T.K p) {} |
| 9944 } | 9915 } |
| 9945 '''); | 9916 '''); |
| 9946 UnlinkedExecutable m = c.executables[0]; | 9917 UnlinkedExecutable m = c.executables[0]; |
| 9947 expect(m.name, 'm'); | 9918 expect(m.name, 'm'); |
| 9948 checkTypeRef(m.parameters[0].type, null, null, 'dynamic'); | 9919 checkTypeRef(m.parameters[0].type, null, 'dynamic'); |
| 9949 } | 9920 } |
| 9950 | 9921 |
| 9951 test_type_param_codeRange() { | 9922 test_type_param_codeRange() { |
| 9952 if (!includeInformative) return; | 9923 if (!includeInformative) return; |
| 9953 UnlinkedClass cls = | 9924 UnlinkedClass cls = |
| 9954 serializeClassText('class A {} class C<T extends A> {}'); | 9925 serializeClassText('class A {} class C<T extends A> {}'); |
| 9955 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; | 9926 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; |
| 9956 _assertCodeRange(typeParameter.codeRange, 19, 11); | 9927 _assertCodeRange(typeParameter.codeRange, 19, 11); |
| 9957 } | 9928 } |
| 9958 | 9929 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10026 UnlinkedClass cls = | 9997 UnlinkedClass cls = |
| 10027 serializeClassText('class C<T> { T f<T>(T x) => null; }'); | 9998 serializeClassText('class C<T> { T f<T>(T x) => null; }'); |
| 10028 checkParamTypeRef(cls.executables[0].returnType, 1); | 9999 checkParamTypeRef(cls.executables[0].returnType, 1); |
| 10029 checkParamTypeRef(cls.executables[0].parameters[0].type, 1); | 10000 checkParamTypeRef(cls.executables[0].parameters[0].type, 1); |
| 10030 } | 10001 } |
| 10031 | 10002 |
| 10032 test_type_reference_from_part() { | 10003 test_type_reference_from_part() { |
| 10033 addNamedSource('/a.dart', 'part of foo; C v;'); | 10004 addNamedSource('/a.dart', 'part of foo; C v;'); |
| 10034 serializeLibraryText('library foo; part "a.dart"; class C {}'); | 10005 serializeLibraryText('library foo; part "a.dart"; class C {}'); |
| 10035 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, | 10006 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, |
| 10036 null, null, 'C', | 10007 null, 'C', |
| 10037 expectedKind: ReferenceKind.classOrEnum, | 10008 expectedKind: ReferenceKind.classOrEnum, |
| 10038 linkedSourceUnit: linked.units[1], | 10009 linkedSourceUnit: linked.units[1], |
| 10039 unlinkedSourceUnit: unlinkedUnits[1]); | 10010 unlinkedSourceUnit: unlinkedUnits[1]); |
| 10040 } | 10011 } |
| 10041 | 10012 |
| 10042 test_type_reference_from_part_withPrefix() { | 10013 test_type_reference_from_part_withPrefix() { |
| 10043 addNamedSource('/a.dart', 'class C {}'); | 10014 addNamedSource('/a.dart', 'class C {}'); |
| 10044 addNamedSource('/p.dart', 'part of foo; a.C v;'); | 10015 addNamedSource('/p.dart', 'part of foo; a.C v;'); |
| 10045 serializeLibraryText( | 10016 serializeLibraryText( |
| 10046 'library foo; import "a.dart"; import "a.dart" as a; part "p.dart";', | 10017 'library foo; import "a.dart"; import "a.dart" as a; part "p.dart";', |
| 10047 allowErrors: true); | 10018 allowErrors: true); |
| 10048 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, | 10019 checkTypeRef(findVariable('v', variables: unlinkedUnits[1].variables).type, |
| 10049 absUri('/a.dart'), 'a.dart', 'C', | 10020 absUri('/a.dart'), 'C', |
| 10050 expectedPrefix: 'a', | 10021 expectedPrefix: 'a', |
| 10051 linkedSourceUnit: linked.units[1], | 10022 linkedSourceUnit: linked.units[1], |
| 10052 unlinkedSourceUnit: unlinkedUnits[1]); | 10023 unlinkedSourceUnit: unlinkedUnits[1]); |
| 10053 } | 10024 } |
| 10054 | 10025 |
| 10055 test_type_reference_to_class_argument() { | 10026 test_type_reference_to_class_argument() { |
| 10056 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); | 10027 UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }'); |
| 10057 { | 10028 { |
| 10058 EntityRef typeRef = | 10029 EntityRef typeRef = |
| 10059 findVariable('t', variables: cls.fields, failIfAbsent: true).type; | 10030 findVariable('t', variables: cls.fields, failIfAbsent: true).type; |
| 10060 checkParamTypeRef(typeRef, 2); | 10031 checkParamTypeRef(typeRef, 2); |
| 10061 } | 10032 } |
| 10062 { | 10033 { |
| 10063 EntityRef typeRef = | 10034 EntityRef typeRef = |
| 10064 findVariable('u', variables: cls.fields, failIfAbsent: true).type; | 10035 findVariable('u', variables: cls.fields, failIfAbsent: true).type; |
| 10065 checkParamTypeRef(typeRef, 1); | 10036 checkParamTypeRef(typeRef, 1); |
| 10066 } | 10037 } |
| 10067 } | 10038 } |
| 10068 | 10039 |
| 10069 test_type_reference_to_import_of_export() { | 10040 test_type_reference_to_import_of_export() { |
| 10070 addNamedSource('/a.dart', 'library a; export "b.dart";'); | 10041 addNamedSource('/a.dart', 'library a; export "b.dart";'); |
| 10071 addNamedSource('/b.dart', 'library b; class C {}'); | 10042 addNamedSource('/b.dart', 'library b; class C {}'); |
| 10072 checkTypeRef(serializeTypeText('C', otherDeclarations: 'import "a.dart";'), | 10043 checkTypeRef(serializeTypeText('C', otherDeclarations: 'import "a.dart";'), |
| 10073 absUri('/b.dart'), 'b.dart', 'C'); | 10044 absUri('/b.dart'), 'C'); |
| 10074 } | 10045 } |
| 10075 | 10046 |
| 10076 test_type_reference_to_import_of_export_via_prefix() { | 10047 test_type_reference_to_import_of_export_via_prefix() { |
| 10077 addNamedSource('/a.dart', 'library a; export "b.dart";'); | 10048 addNamedSource('/a.dart', 'library a; export "b.dart";'); |
| 10078 addNamedSource('/b.dart', 'library b; class C {}'); | 10049 addNamedSource('/b.dart', 'library b; class C {}'); |
| 10079 checkTypeRef( | 10050 checkTypeRef( |
| 10080 serializeTypeText('p.C', otherDeclarations: 'import "a.dart" as p;'), | 10051 serializeTypeText('p.C', otherDeclarations: 'import "a.dart" as p;'), |
| 10081 absUri('/b.dart'), | 10052 absUri('/b.dart'), |
| 10082 'b.dart', | |
| 10083 'C', | 10053 'C', |
| 10084 expectedPrefix: 'p'); | 10054 expectedPrefix: 'p'); |
| 10085 } | 10055 } |
| 10086 | 10056 |
| 10087 test_type_reference_to_imported_part() { | 10057 test_type_reference_to_imported_part() { |
| 10088 addNamedSource('/a.dart', 'library my.lib; part "b.dart";'); | 10058 addNamedSource('/a.dart', 'library my.lib; part "b.dart";'); |
| 10089 addNamedSource('/b.dart', 'part of my.lib; class C {}'); | 10059 addNamedSource('/b.dart', 'part of my.lib; class C {}'); |
| 10090 checkTypeRef( | 10060 checkTypeRef( |
| 10091 serializeTypeText('C', | 10061 serializeTypeText('C', |
| 10092 otherDeclarations: 'library my.lib; import "a.dart";'), | 10062 otherDeclarations: 'library my.lib; import "a.dart";'), |
| 10093 absUri('/a.dart'), | 10063 absUri('/a.dart'), |
| 10094 'a.dart', | |
| 10095 'C', | 10064 'C', |
| 10096 expectedTargetUnit: 1); | 10065 expectedTargetUnit: 1); |
| 10097 } | 10066 } |
| 10098 | 10067 |
| 10099 test_type_reference_to_imported_part_with_prefix() { | 10068 test_type_reference_to_imported_part_with_prefix() { |
| 10100 addNamedSource('/a.dart', 'library my.lib; part "b.dart";'); | 10069 addNamedSource('/a.dart', 'library my.lib; part "b.dart";'); |
| 10101 addNamedSource('/b.dart', 'part of my.lib; class C {}'); | 10070 addNamedSource('/b.dart', 'part of my.lib; class C {}'); |
| 10102 checkTypeRef( | 10071 checkTypeRef( |
| 10103 serializeTypeText('p.C', | 10072 serializeTypeText('p.C', |
| 10104 otherDeclarations: 'library my.lib; import "a.dart" as p;'), | 10073 otherDeclarations: 'library my.lib; import "a.dart" as p;'), |
| 10105 absUri('/a.dart'), | 10074 absUri('/a.dart'), |
| 10106 'a.dart', | |
| 10107 'C', | 10075 'C', |
| 10108 expectedPrefix: 'p', | 10076 expectedPrefix: 'p', |
| 10109 expectedTargetUnit: 1); | 10077 expectedTargetUnit: 1); |
| 10110 } | 10078 } |
| 10111 | 10079 |
| 10112 test_type_reference_to_internal_class() { | 10080 test_type_reference_to_internal_class() { |
| 10113 checkTypeRef(serializeTypeText('C', otherDeclarations: 'class C {}'), null, | 10081 checkTypeRef( |
| 10114 null, 'C'); | 10082 serializeTypeText('C', otherDeclarations: 'class C {}'), null, 'C'); |
| 10115 } | 10083 } |
| 10116 | 10084 |
| 10117 test_type_reference_to_internal_class_alias() { | 10085 test_type_reference_to_internal_class_alias() { |
| 10118 checkTypeRef( | 10086 checkTypeRef( |
| 10119 serializeTypeText('C', | 10087 serializeTypeText('C', |
| 10120 otherDeclarations: 'class C = D with E; class D {} class E {}'), | 10088 otherDeclarations: 'class C = D with E; class D {} class E {}'), |
| 10121 null, | 10089 null, |
| 10122 null, | |
| 10123 'C'); | 10090 'C'); |
| 10124 } | 10091 } |
| 10125 | 10092 |
| 10126 test_type_reference_to_internal_enum() { | 10093 test_type_reference_to_internal_enum() { |
| 10127 checkTypeRef(serializeTypeText('E', otherDeclarations: 'enum E { value }'), | 10094 checkTypeRef(serializeTypeText('E', otherDeclarations: 'enum E { value }'), |
| 10128 null, null, 'E'); | 10095 null, 'E'); |
| 10129 } | 10096 } |
| 10130 | 10097 |
| 10131 test_type_reference_to_local_part() { | 10098 test_type_reference_to_local_part() { |
| 10132 addNamedSource('/a.dart', 'part of my.lib; class C {}'); | 10099 addNamedSource('/a.dart', 'part of my.lib; class C {}'); |
| 10133 checkTypeRef( | 10100 checkTypeRef( |
| 10134 serializeTypeText('C', | 10101 serializeTypeText('C', |
| 10135 otherDeclarations: 'library my.lib; part "a.dart";'), | 10102 otherDeclarations: 'library my.lib; part "a.dart";'), |
| 10136 null, | 10103 null, |
| 10137 null, | |
| 10138 'C', | 10104 'C', |
| 10139 expectedTargetUnit: 1); | 10105 expectedTargetUnit: 1); |
| 10140 } | 10106 } |
| 10141 | 10107 |
| 10142 test_type_reference_to_nonexistent_file_via_prefix() { | 10108 test_type_reference_to_nonexistent_file_via_prefix() { |
| 10143 allowMissingFiles = true; | 10109 allowMissingFiles = true; |
| 10144 EntityRef typeRef = serializeTypeText('p.C', | 10110 EntityRef typeRef = serializeTypeText('p.C', |
| 10145 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true); | 10111 otherDeclarations: 'import "foo.dart" as p;', allowErrors: true); |
| 10146 checkUnresolvedTypeRef(typeRef, 'p', 'C'); | 10112 checkUnresolvedTypeRef(typeRef, 'p', 'C'); |
| 10147 } | 10113 } |
| 10148 | 10114 |
| 10149 test_type_reference_to_part() { | 10115 test_type_reference_to_part() { |
| 10150 addNamedSource('/a.dart', 'part of foo; class C { C(); }'); | 10116 addNamedSource('/a.dart', 'part of foo; class C { C(); }'); |
| 10151 serializeLibraryText('library foo; part "a.dart"; C c;'); | 10117 serializeLibraryText('library foo; part "a.dart"; C c;'); |
| 10152 checkTypeRef(unlinkedUnits[0].variables.single.type, null, null, 'C', | 10118 checkTypeRef(unlinkedUnits[0].variables.single.type, null, 'C', |
| 10153 expectedKind: ReferenceKind.classOrEnum, expectedTargetUnit: 1); | 10119 expectedKind: ReferenceKind.classOrEnum, expectedTargetUnit: 1); |
| 10154 } | 10120 } |
| 10155 | 10121 |
| 10156 test_type_reference_to_type_visible_via_multiple_import_prefixes() { | 10122 test_type_reference_to_type_visible_via_multiple_import_prefixes() { |
| 10157 addNamedSource('/lib1.dart', 'class C'); | 10123 addNamedSource('/lib1.dart', 'class C'); |
| 10158 addNamedSource('/lib2.dart', 'export "lib1.dart";'); | 10124 addNamedSource('/lib2.dart', 'export "lib1.dart";'); |
| 10159 addNamedSource('/lib3.dart', 'export "lib1.dart";'); | 10125 addNamedSource('/lib3.dart', 'export "lib1.dart";'); |
| 10160 addNamedSource('/lib4.dart', 'export "lib1.dart";'); | 10126 addNamedSource('/lib4.dart', 'export "lib1.dart";'); |
| 10161 serializeLibraryText(''' | 10127 serializeLibraryText(''' |
| 10162 import 'lib2.dart'; | 10128 import 'lib2.dart'; |
| 10163 import 'lib3.dart' as a; | 10129 import 'lib3.dart' as a; |
| 10164 import 'lib4.dart' as b; | 10130 import 'lib4.dart' as b; |
| 10165 C c2; | 10131 C c2; |
| 10166 a.C c3; | 10132 a.C c3; |
| 10167 b.C c4;'''); | 10133 b.C c4;'''); |
| 10168 // Note: it is important that each reference to class C records the prefix | 10134 // Note: it is important that each reference to class C records the prefix |
| 10169 // used to find it; otherwise it's possible that relinking might produce an | 10135 // used to find it; otherwise it's possible that relinking might produce an |
| 10170 // incorrect result after a change to lib2.dart, lib3.dart, or lib4.dart. | 10136 // incorrect result after a change to lib2.dart, lib3.dart, or lib4.dart. |
| 10171 checkTypeRef( | 10137 checkTypeRef(findVariable('c2').type, absUri('/lib1.dart'), 'C'); |
| 10172 findVariable('c2').type, absUri('/lib1.dart'), 'lib1.dart', 'C'); | 10138 checkTypeRef(findVariable('c3').type, absUri('/lib1.dart'), 'C', |
| 10173 checkTypeRef( | |
| 10174 findVariable('c3').type, absUri('/lib1.dart'), 'lib1.dart', 'C', | |
| 10175 expectedPrefix: 'a'); | 10139 expectedPrefix: 'a'); |
| 10176 checkTypeRef( | 10140 checkTypeRef(findVariable('c4').type, absUri('/lib1.dart'), 'C', |
| 10177 findVariable('c4').type, absUri('/lib1.dart'), 'lib1.dart', 'C', | |
| 10178 expectedPrefix: 'b'); | 10141 expectedPrefix: 'b'); |
| 10179 } | 10142 } |
| 10180 | 10143 |
| 10181 test_type_reference_to_typedef() { | 10144 test_type_reference_to_typedef() { |
| 10182 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'), | 10145 checkTypeRef(serializeTypeText('F', otherDeclarations: 'typedef void F();'), |
| 10183 null, null, 'F', | 10146 null, 'F', |
| 10184 expectedKind: ReferenceKind.typedef); | 10147 expectedKind: ReferenceKind.typedef); |
| 10185 } | 10148 } |
| 10186 | 10149 |
| 10187 test_type_unit_counts_unreferenced_units() { | 10150 test_type_unit_counts_unreferenced_units() { |
| 10188 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";'); | 10151 addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";'); |
| 10189 addNamedSource('/b.dart', 'part of a;'); | 10152 addNamedSource('/b.dart', 'part of a;'); |
| 10190 addNamedSource('/c.dart', 'part of a; class C {}'); | 10153 addNamedSource('/c.dart', 'part of a; class C {}'); |
| 10191 EntityRef typeRef = | 10154 EntityRef typeRef = |
| 10192 serializeTypeText('C', otherDeclarations: 'import "a.dart";'); | 10155 serializeTypeText('C', otherDeclarations: 'import "a.dart";'); |
| 10193 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is | 10156 // The referenced unit should be 2, since unit 0 is a.dart and unit 1 is |
| 10194 // b.dart. a.dart and b.dart are counted even though nothing is imported | 10157 // b.dart. a.dart and b.dart are counted even though nothing is imported |
| 10195 // from them. | 10158 // from them. |
| 10196 checkTypeRef(typeRef, absUri('/a.dart'), 'a.dart', 'C', | 10159 checkTypeRef(typeRef, absUri('/a.dart'), 'C', expectedTargetUnit: 2); |
| 10197 expectedTargetUnit: 2); | |
| 10198 } | 10160 } |
| 10199 | 10161 |
| 10200 test_type_unresolved() { | 10162 test_type_unresolved() { |
| 10201 EntityRef typeRef = serializeTypeText('Foo', allowErrors: true); | 10163 EntityRef typeRef = serializeTypeText('Foo', allowErrors: true); |
| 10202 checkUnresolvedTypeRef(typeRef, null, 'Foo'); | 10164 checkUnresolvedTypeRef(typeRef, null, 'Foo'); |
| 10203 } | 10165 } |
| 10204 | 10166 |
| 10205 test_typedef_codeRange() { | 10167 test_typedef_codeRange() { |
| 10206 if (!includeInformative) return; | 10168 if (!includeInformative) return; |
| 10207 UnlinkedTypedef type = serializeTypedefText('typedef F();'); | 10169 UnlinkedTypedef type = serializeTypedefText('typedef F();'); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10248 } | 10210 } |
| 10249 | 10211 |
| 10250 test_typedef_private() { | 10212 test_typedef_private() { |
| 10251 serializeTypedefText('typedef _F();', '_F'); | 10213 serializeTypedefText('typedef _F();', '_F'); |
| 10252 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 10214 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 10253 } | 10215 } |
| 10254 | 10216 |
| 10255 test_typedef_reference_generic() { | 10217 test_typedef_reference_generic() { |
| 10256 EntityRef typeRef = | 10218 EntityRef typeRef = |
| 10257 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); | 10219 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); |
| 10258 checkTypeRef(typeRef, null, null, 'F', | 10220 checkTypeRef(typeRef, null, 'F', |
| 10259 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 10221 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); |
| 10260 } | 10222 } |
| 10261 | 10223 |
| 10262 test_typedef_reference_generic_imported() { | 10224 test_typedef_reference_generic_imported() { |
| 10263 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); | 10225 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); |
| 10264 EntityRef typeRef = | 10226 EntityRef typeRef = |
| 10265 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); | 10227 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); |
| 10266 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', | 10228 checkTypeRef(typeRef, absUri('/lib.dart'), 'F', |
| 10267 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 10229 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); |
| 10268 } | 10230 } |
| 10269 | 10231 |
| 10270 test_typedef_return_type_explicit() { | 10232 test_typedef_return_type_explicit() { |
| 10271 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); | 10233 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); |
| 10272 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); | 10234 checkTypeRef(type.returnType, 'dart:core', 'int'); |
| 10273 } | 10235 } |
| 10274 | 10236 |
| 10275 test_typedef_type_param_in_parameter() { | 10237 test_typedef_type_param_in_parameter() { |
| 10276 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); | 10238 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); |
| 10277 checkParamTypeRef(type.parameters[0].type, 1); | 10239 checkParamTypeRef(type.parameters[0].type, 1); |
| 10278 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1); | 10240 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1); |
| 10279 } | 10241 } |
| 10280 | 10242 |
| 10281 test_typedef_type_param_in_return_type() { | 10243 test_typedef_type_param_in_return_type() { |
| 10282 UnlinkedTypedef type = serializeTypedefText('typedef T F<T>();'); | 10244 UnlinkedTypedef type = serializeTypedefText('typedef T F<T>();'); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 10301 UnlinkedUnit unit = unlinkedUnits[0]; | 10263 UnlinkedUnit unit = unlinkedUnits[0]; |
| 10302 _assertCodeRange(unit.codeRange, 0, 14); | 10264 _assertCodeRange(unit.codeRange, 0, 14); |
| 10303 } | 10265 } |
| 10304 | 10266 |
| 10305 test_unresolved_export() { | 10267 test_unresolved_export() { |
| 10306 allowMissingFiles = true; | 10268 allowMissingFiles = true; |
| 10307 serializeLibraryText("export 'foo.dart';", allowErrors: true); | 10269 serializeLibraryText("export 'foo.dart';", allowErrors: true); |
| 10308 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); | 10270 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); |
| 10309 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'foo.dart'); | 10271 expect(unlinkedUnits[0].publicNamespace.exports[0].uri, 'foo.dart'); |
| 10310 expect(linked.exportDependencies, hasLength(1)); | 10272 expect(linked.exportDependencies, hasLength(1)); |
| 10311 checkDependency( | 10273 checkDependency(linked.exportDependencies[0], absUri('/foo.dart')); |
| 10312 linked.exportDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 10313 } | 10274 } |
| 10314 | 10275 |
| 10315 test_unresolved_import() { | 10276 test_unresolved_import() { |
| 10316 allowMissingFiles = true; | 10277 allowMissingFiles = true; |
| 10317 serializeLibraryText("import 'foo.dart';", allowErrors: true); | 10278 serializeLibraryText("import 'foo.dart';", allowErrors: true); |
| 10318 expect(unlinkedUnits[0].imports, hasLength(2)); | 10279 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 10319 expect(unlinkedUnits[0].imports[0].uri, 'foo.dart'); | 10280 expect(unlinkedUnits[0].imports[0].uri, 'foo.dart'); |
| 10320 // Note: imports[1] is the implicit import of dart:core. | 10281 // Note: imports[1] is the implicit import of dart:core. |
| 10321 expect(unlinkedUnits[0].imports[1].isImplicit, true); | 10282 expect(unlinkedUnits[0].imports[1].isImplicit, true); |
| 10322 expect(linked.importDependencies, hasLength(2)); | 10283 expect(linked.importDependencies, hasLength(2)); |
| 10323 checkDependency( | 10284 checkDependency(linked.importDependencies[0], absUri('/foo.dart')); |
| 10324 linked.importDependencies[0], absUri('/foo.dart'), 'foo.dart'); | |
| 10325 } | 10285 } |
| 10326 | 10286 |
| 10327 test_unresolved_part() { | 10287 test_unresolved_part() { |
| 10328 allowMissingFiles = true; | 10288 allowMissingFiles = true; |
| 10329 serializeLibraryText("part 'foo.dart';", allowErrors: true); | 10289 serializeLibraryText("part 'foo.dart';", allowErrors: true); |
| 10330 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); | 10290 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); |
| 10331 expect(unlinkedUnits[0].publicNamespace.parts[0], 'foo.dart'); | 10291 expect(unlinkedUnits[0].publicNamespace.parts[0], 'foo.dart'); |
| 10332 } | 10292 } |
| 10333 | 10293 |
| 10334 test_unresolved_reference_in_multiple_parts() { | 10294 test_unresolved_reference_in_multiple_parts() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 10362 UnlinkedVariable variable = serializeVariableText(''' | 10322 UnlinkedVariable variable = serializeVariableText(''' |
| 10363 class C<T> { | 10323 class C<T> { |
| 10364 void f() {} | 10324 void f() {} |
| 10365 } | 10325 } |
| 10366 C<int> c; | 10326 C<int> c; |
| 10367 var v = c.f; | 10327 var v = c.f; |
| 10368 '''); | 10328 '''); |
| 10369 EntityRef type = | 10329 EntityRef type = |
| 10370 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); | 10330 getTypeRefForSlot(variable.initializer.inferredReturnTypeSlot); |
| 10371 expect(type.typeArguments, hasLength(1)); | 10331 expect(type.typeArguments, hasLength(1)); |
| 10372 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 10332 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'int'); |
| 10373 } | 10333 } |
| 10374 | 10334 |
| 10375 test_variable() { | 10335 test_variable() { |
| 10376 String text = 'int i;'; | 10336 String text = 'int i;'; |
| 10377 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); | 10337 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); |
| 10378 if (includeInformative) { | 10338 if (includeInformative) { |
| 10379 expect(v.nameOffset, text.indexOf('i;')); | 10339 expect(v.nameOffset, text.indexOf('i;')); |
| 10380 } | 10340 } |
| 10381 expect(findExecutable('i'), isNull); | 10341 expect(findExecutable('i'), isNull); |
| 10382 expect(findExecutable('i='), isNull); | 10342 expect(findExecutable('i='), isNull); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10440 expect(variable.type, isNull); | 10400 expect(variable.type, isNull); |
| 10441 } | 10401 } |
| 10442 | 10402 |
| 10443 test_variable_inferred_type_explicit_initialized() { | 10403 test_variable_inferred_type_explicit_initialized() { |
| 10444 UnlinkedVariable v = serializeVariableText('int v = 0;'); | 10404 UnlinkedVariable v = serializeVariableText('int v = 0;'); |
| 10445 expect(v.inferredTypeSlot, 0); | 10405 expect(v.inferredTypeSlot, 0); |
| 10446 } | 10406 } |
| 10447 | 10407 |
| 10448 test_variable_inferred_type_implicit_initialized() { | 10408 test_variable_inferred_type_implicit_initialized() { |
| 10449 UnlinkedVariable v = serializeVariableText('var v = 0;'); | 10409 UnlinkedVariable v = serializeVariableText('var v = 0;'); |
| 10450 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); | 10410 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'int'); |
| 10451 } | 10411 } |
| 10452 | 10412 |
| 10453 test_variable_inferred_type_implicit_uninitialized() { | 10413 test_variable_inferred_type_implicit_uninitialized() { |
| 10454 UnlinkedVariable v = serializeVariableText('var v;'); | 10414 UnlinkedVariable v = serializeVariableText('var v;'); |
| 10455 expect(v.inferredTypeSlot, 0); | 10415 expect(v.inferredTypeSlot, 0); |
| 10456 } | 10416 } |
| 10457 | 10417 |
| 10458 test_variable_initializer_literal() { | 10418 test_variable_initializer_literal() { |
| 10459 UnlinkedVariable variable = serializeVariableText('var v = 42;'); | 10419 UnlinkedVariable variable = serializeVariableText('var v = 42;'); |
| 10460 UnlinkedExecutable initializer = variable.initializer; | 10420 UnlinkedExecutable initializer = variable.initializer; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10571 | 10531 |
| 10572 test_variable_static() { | 10532 test_variable_static() { |
| 10573 UnlinkedVariable variable = | 10533 UnlinkedVariable variable = |
| 10574 serializeClassText('class C { static int i; }').fields[0]; | 10534 serializeClassText('class C { static int i; }').fields[0]; |
| 10575 expect(variable.isStatic, isTrue); | 10535 expect(variable.isStatic, isTrue); |
| 10576 } | 10536 } |
| 10577 | 10537 |
| 10578 test_variable_type() { | 10538 test_variable_type() { |
| 10579 UnlinkedVariable variable = | 10539 UnlinkedVariable variable = |
| 10580 serializeVariableText('int i;', variableName: 'i'); | 10540 serializeVariableText('int i;', variableName: 'i'); |
| 10581 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); | 10541 checkTypeRef(variable.type, 'dart:core', 'int'); |
| 10582 } | 10542 } |
| 10583 | 10543 |
| 10584 /** | 10544 /** |
| 10585 * Verify invariants of the given [linkedLibrary]. | 10545 * Verify invariants of the given [linkedLibrary]. |
| 10586 */ | 10546 */ |
| 10587 void validateLinkedLibrary(LinkedLibrary linkedLibrary) { | 10547 void validateLinkedLibrary(LinkedLibrary linkedLibrary) { |
| 10588 for (LinkedUnit unit in linkedLibrary.units) { | 10548 for (LinkedUnit unit in linkedLibrary.units) { |
| 10589 for (LinkedReference reference in unit.references) { | 10549 for (LinkedReference reference in unit.references) { |
| 10590 switch (reference.kind) { | 10550 switch (reference.kind) { |
| 10591 case ReferenceKind.classOrEnum: | 10551 case ReferenceKind.classOrEnum: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10643 assignmentOperators: [ | 10603 assignmentOperators: [ |
| 10644 expectedAssignOperator | 10604 expectedAssignOperator |
| 10645 ], | 10605 ], |
| 10646 ints: [ | 10606 ints: [ |
| 10647 1, | 10607 1, |
| 10648 2, | 10608 2, |
| 10649 3 | 10609 3 |
| 10650 ], | 10610 ], |
| 10651 strings: [], | 10611 strings: [], |
| 10652 referenceValidators: [ | 10612 referenceValidators: [ |
| 10653 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 10613 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 10654 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 10614 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 10655 ]); | 10615 ]); |
| 10656 } | 10616 } |
| 10657 | 10617 |
| 10658 void _assertCodeRange(CodeRange codeRange, int offset, int length) { | 10618 void _assertCodeRange(CodeRange codeRange, int offset, int length) { |
| 10659 expect(codeRange, isNotNull); | 10619 expect(codeRange, isNotNull); |
| 10660 expect(codeRange.offset, offset); | 10620 expect(codeRange.offset, offset); |
| 10661 expect(codeRange.length, length); | 10621 expect(codeRange.length, length); |
| 10662 } | 10622 } |
| 10663 | 10623 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10705 UnlinkedExprOperation.add, | 10665 UnlinkedExprOperation.add, |
| 10706 ], | 10666 ], |
| 10707 assignmentOperators: [ | 10667 assignmentOperators: [ |
| 10708 expectedAssignmentOperator | 10668 expectedAssignmentOperator |
| 10709 ], | 10669 ], |
| 10710 ints: [ | 10670 ints: [ |
| 10711 2 | 10671 2 |
| 10712 ], | 10672 ], |
| 10713 strings: [], | 10673 strings: [], |
| 10714 referenceValidators: [ | 10674 referenceValidators: [ |
| 10715 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 10675 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 10716 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 10676 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 10717 ]); | 10677 ]); |
| 10718 } | 10678 } |
| 10719 | 10679 |
| 10720 void _assertVariableVisible( | 10680 void _assertVariableVisible( |
| 10721 String code, UnlinkedVariable v, String visibleBegin, String visibleEnd) { | 10681 String code, UnlinkedVariable v, String visibleBegin, String visibleEnd) { |
| 10722 int expectedVisibleOffset = code.indexOf(visibleBegin); | 10682 int expectedVisibleOffset = code.indexOf(visibleBegin); |
| 10723 int expectedVisibleLength = | 10683 int expectedVisibleLength = |
| 10724 code.indexOf(visibleEnd) - expectedVisibleOffset + 1; | 10684 code.indexOf(visibleEnd) - expectedVisibleOffset + 1; |
| 10725 expect(v.visibleOffset, expectedVisibleOffset); | 10685 expect(v.visibleOffset, expectedVisibleOffset); |
| 10726 expect(v.visibleLength, expectedVisibleLength); | 10686 expect(v.visibleLength, expectedVisibleLength); |
| 10727 } | 10687 } |
| 10728 } | 10688 } |
| 10729 | 10689 |
| 10730 /** | 10690 /** |
| 10731 * Description of expectations for a prelinked prefix reference. | 10691 * Description of expectations for a prelinked prefix reference. |
| 10732 */ | 10692 */ |
| 10733 class _PrefixExpectation { | 10693 class _PrefixExpectation { |
| 10734 final ReferenceKind kind; | 10694 final ReferenceKind kind; |
| 10735 final String name; | 10695 final String name; |
| 10736 final String absoluteUri; | 10696 final String absoluteUri; |
| 10737 final String relativeUri; | |
| 10738 final int numTypeParameters; | 10697 final int numTypeParameters; |
| 10739 | 10698 |
| 10740 _PrefixExpectation(this.kind, this.name, | 10699 _PrefixExpectation(this.kind, this.name, |
| 10741 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10700 {this.absoluteUri, this.numTypeParameters: 0}); |
| 10742 } | 10701 } |
| OLD | NEW |