| 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/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return null; | 350 return null; |
| 351 } | 351 } |
| 352 | 352 |
| 353 /** | 353 /** |
| 354 * Test an inferred type. If [onlyInStrongMode] is `true` (the default) and | 354 * Test an inferred type. If [onlyInStrongMode] is `true` (the default) and |
| 355 * strong mode is disabled, verify that the given [slotId] exists and has no | 355 * strong mode is disabled, verify that the given [slotId] exists and has no |
| 356 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. | 356 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. |
| 357 */ | 357 */ |
| 358 void checkInferredTypeSlot( | 358 void checkInferredTypeSlot( |
| 359 int slotId, String absoluteUri, String relativeUri, String expectedName, | 359 int slotId, String absoluteUri, String relativeUri, String expectedName, |
| 360 {bool allowTypeParameters: false, | 360 {int numTypeArguments: 0, |
| 361 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 361 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 362 int expectedTargetUnit: 0, | 362 int expectedTargetUnit: 0, |
| 363 LinkedUnit linkedSourceUnit, | 363 LinkedUnit linkedSourceUnit, |
| 364 UnlinkedUnit unlinkedSourceUnit, | 364 UnlinkedUnit unlinkedSourceUnit, |
| 365 int numTypeParameters: 0, | 365 int numTypeParameters: 0, |
| 366 bool onlyInStrongMode: true}) { | 366 bool onlyInStrongMode: true}) { |
| 367 if (strongMode || !onlyInStrongMode) { | 367 if (strongMode || !onlyInStrongMode) { |
| 368 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName, | 368 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName, |
| 369 allowTypeArguments: allowTypeParameters, | 369 numTypeArguments: numTypeArguments, |
| 370 expectedKind: expectedKind, | 370 expectedKind: expectedKind, |
| 371 expectedTargetUnit: expectedTargetUnit, | 371 expectedTargetUnit: expectedTargetUnit, |
| 372 linkedSourceUnit: linkedSourceUnit, | 372 linkedSourceUnit: linkedSourceUnit, |
| 373 unlinkedSourceUnit: unlinkedSourceUnit, | 373 unlinkedSourceUnit: unlinkedSourceUnit, |
| 374 numTypeParameters: numTypeParameters); | 374 numTypeParameters: numTypeParameters); |
| 375 } else { | 375 } else { |
| 376 // A slot id should have been assigned but it should not be associated | 376 // A slot id should have been assigned but it should not be associated |
| 377 // with any type. | 377 // with any type. |
| 378 expect(slotId, isNot(0)); | 378 expect(slotId, isNot(0)); |
| 379 expect(getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), | 379 expect(getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 393 relativeUri = absoluteUri; | 393 relativeUri = absoluteUri; |
| 394 } | 394 } |
| 395 for (LinkedDependency dep in linked.dependencies) { | 395 for (LinkedDependency dep in linked.dependencies) { |
| 396 if (dep.uri == relativeUri) { | 396 if (dep.uri == relativeUri) { |
| 397 fail('Unexpected dependency found: $relativeUri'); | 397 fail('Unexpected dependency found: $relativeUri'); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 | 401 |
| 402 /** | 402 /** |
| 403 * Verify that the given [typeRef] represents the type `dynamic`. |
| 404 */ |
| 405 void checkLinkedDynamicTypeRef(EntityRef typeRef) { |
| 406 checkLinkedTypeRef(typeRef, null, null, 'dynamic'); |
| 407 } |
| 408 |
| 409 /** |
| 403 * Verify that the given [typeRef] represents a reference to a type declared | 410 * Verify that the given [typeRef] represents a reference to a type declared |
| 404 * in a file reachable via [absoluteUri] and [relativeUri], having name | 411 * in a file reachable via [absoluteUri] and [relativeUri], having name |
| 405 * [expectedName]. If [allowTypeArguments] is true, allow the type | 412 * [expectedName]. Verify that the number of type arguments |
| 406 * reference to supply type arguments. [expectedKind] is the kind of object | 413 * is equal to [numTypeArguments]. [expectedKind] is the kind of object |
| 407 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 414 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the |
| 408 * compilation unit within which the [typeRef] appears; if not specified they | 415 * compilation unit within which the [typeRef] appears; if not specified they |
| 409 * are assumed to refer to the defining compilation unit. | 416 * are assumed to refer to the defining compilation unit. |
| 410 * [expectedTargetUnit] is the index of the compilation unit in which the | 417 * [expectedTargetUnit] is the index of the compilation unit in which the |
| 411 * target of the [typeRef] is expected to appear; if not specified it is | 418 * target of the [typeRef] is expected to appear; if not specified it is |
| 412 * assumed to be the defining compilation unit. [numTypeParameters] is the | 419 * assumed to be the defining compilation unit. [numTypeParameters] is the |
| 413 * number of type parameters of the thing being referred to. | 420 * number of type parameters of the thing being referred to. |
| 414 */ | 421 */ |
| 415 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri, | 422 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri, |
| 416 String relativeUri, String expectedName, | 423 String relativeUri, String expectedName, |
| 417 {bool allowTypeArguments: false, | 424 {int numTypeArguments: 0, |
| 418 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 425 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 419 int expectedTargetUnit: 0, | 426 int expectedTargetUnit: 0, |
| 420 LinkedUnit linkedSourceUnit, | 427 LinkedUnit linkedSourceUnit, |
| 421 UnlinkedUnit unlinkedSourceUnit, | 428 UnlinkedUnit unlinkedSourceUnit, |
| 422 int numTypeParameters: 0}) { | 429 int numTypeParameters: 0}) { |
| 423 linkedSourceUnit ??= definingUnit; | 430 linkedSourceUnit ??= definingUnit; |
| 424 expect(typeRef, isNotNull, | 431 expect(typeRef, isNotNull, |
| 425 reason: 'No entry in linkedSourceUnit.types matching slotId'); | 432 reason: 'No entry in linkedSourceUnit.types matching slotId'); |
| 426 expect(typeRef.paramReference, 0); | 433 expect(typeRef.paramReference, 0); |
| 427 int index = typeRef.reference; | 434 int index = typeRef.reference; |
| 428 if (!allowTypeArguments) { | 435 expect(typeRef.typeArguments, hasLength(numTypeArguments)); |
| 429 expect(typeRef.typeArguments, isEmpty); | |
| 430 } | |
| 431 checkReferenceIndex(index, absoluteUri, relativeUri, expectedName, | 436 checkReferenceIndex(index, absoluteUri, relativeUri, expectedName, |
| 432 expectedKind: expectedKind, | 437 expectedKind: expectedKind, |
| 433 expectedTargetUnit: expectedTargetUnit, | 438 expectedTargetUnit: expectedTargetUnit, |
| 434 linkedSourceUnit: linkedSourceUnit, | 439 linkedSourceUnit: linkedSourceUnit, |
| 435 unlinkedSourceUnit: unlinkedSourceUnit, | 440 unlinkedSourceUnit: unlinkedSourceUnit, |
| 436 numTypeParameters: numTypeParameters); | 441 numTypeParameters: numTypeParameters); |
| 437 } | 442 } |
| 438 | 443 |
| 439 /** | 444 /** |
| 440 * Verify that the given [slotId] represents a reference to a type declared | 445 * Verify that the given [slotId] represents a reference to a type declared |
| 441 * in a file reachable via [absoluteUri] and [relativeUri], having name | 446 * in a file reachable via [absoluteUri] and [relativeUri], having name |
| 442 * [expectedName]. If [allowTypeArguments] is true, allow the type | 447 * [expectedName]. Verify that the number of type arguments |
| 443 * reference to supply type arguments. [expectedKind] is the kind of object | 448 * is equal to [numTypeArguments]. [expectedKind] is the kind of object |
| 444 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 449 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the |
| 445 * compilation unit within which the [typeRef] appears; if not specified they | 450 * compilation unit within which the [typeRef] appears; if not specified they |
| 446 * are assumed to refer to the defining compilation unit. | 451 * are assumed to refer to the defining compilation unit. |
| 447 * [expectedTargetUnit] is the index of the compilation unit in which the | 452 * [expectedTargetUnit] is the index of the compilation unit in which the |
| 448 * target of the [typeRef] is expected to appear; if not specified it is | 453 * target of the [typeRef] is expected to appear; if not specified it is |
| 449 * assumed to be the defining compilation unit. [numTypeParameters] is the | 454 * assumed to be the defining compilation unit. [numTypeParameters] is the |
| 450 * number of type parameters of the thing being referred to. | 455 * number of type parameters of the thing being referred to. |
| 451 */ | 456 */ |
| 452 void checkLinkedTypeSlot( | 457 void checkLinkedTypeSlot( |
| 453 int slotId, String absoluteUri, String relativeUri, String expectedName, | 458 int slotId, String absoluteUri, String relativeUri, String expectedName, |
| 454 {bool allowTypeArguments: false, | 459 {int numTypeArguments: 0, |
| 455 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 460 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 456 int expectedTargetUnit: 0, | 461 int expectedTargetUnit: 0, |
| 457 LinkedUnit linkedSourceUnit, | 462 LinkedUnit linkedSourceUnit, |
| 458 UnlinkedUnit unlinkedSourceUnit, | 463 UnlinkedUnit unlinkedSourceUnit, |
| 459 int numTypeParameters: 0}) { | 464 int numTypeParameters: 0}) { |
| 460 // Slot ids should be nonzero, since zero means "no associated slot". | 465 // Slot ids should be nonzero, since zero means "no associated slot". |
| 461 expect(slotId, isNot(0)); | 466 expect(slotId, isNot(0)); |
| 462 if (skipFullyLinkedData) { | 467 if (skipFullyLinkedData) { |
| 463 return; | 468 return; |
| 464 } | 469 } |
| 465 linkedSourceUnit ??= definingUnit; | 470 linkedSourceUnit ??= definingUnit; |
| 466 checkLinkedTypeRef( | 471 checkLinkedTypeRef( |
| 467 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), | 472 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), |
| 468 absoluteUri, | 473 absoluteUri, |
| 469 relativeUri, | 474 relativeUri, |
| 470 expectedName, | 475 expectedName, |
| 471 allowTypeArguments: allowTypeArguments, | 476 numTypeArguments: numTypeArguments, |
| 472 expectedKind: expectedKind, | 477 expectedKind: expectedKind, |
| 473 expectedTargetUnit: expectedTargetUnit, | 478 expectedTargetUnit: expectedTargetUnit, |
| 474 linkedSourceUnit: linkedSourceUnit, | 479 linkedSourceUnit: linkedSourceUnit, |
| 475 unlinkedSourceUnit: unlinkedSourceUnit, | 480 unlinkedSourceUnit: unlinkedSourceUnit, |
| 476 numTypeParameters: numTypeParameters); | 481 numTypeParameters: numTypeParameters); |
| 477 } | 482 } |
| 478 | 483 |
| 479 /** | 484 /** |
| 480 * Verify that the given [typeRef] represents a reference to a type parameter | 485 * Verify that the given [typeRef] represents a reference to a type parameter |
| 481 * having the given [deBruijnIndex]. | 486 * having the given [deBruijnIndex]. |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1094 |
| 1090 test_class_alias_private() { | 1095 test_class_alias_private() { |
| 1091 serializeClassText('class _C = _D with _E; class _D {} class _E {}', | 1096 serializeClassText('class _C = _D with _E; class _D {} class _E {}', |
| 1092 className: '_C'); | 1097 className: '_C'); |
| 1093 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1098 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1094 } | 1099 } |
| 1095 | 1100 |
| 1096 test_class_alias_reference_generic() { | 1101 test_class_alias_reference_generic() { |
| 1097 EntityRef typeRef = serializeTypeText('C', | 1102 EntityRef typeRef = serializeTypeText('C', |
| 1098 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); | 1103 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); |
| 1099 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1104 checkTypeRef(typeRef, null, null, 'C', |
| 1105 numTypeParameters: 2, numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 1106 if (!checkAstDerivedData) { |
| 1107 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 1108 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 1109 } |
| 1100 } | 1110 } |
| 1101 | 1111 |
| 1102 test_class_alias_reference_generic_imported() { | 1112 test_class_alias_reference_generic_imported() { |
| 1103 addNamedSource( | 1113 addNamedSource( |
| 1104 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); | 1114 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); |
| 1105 EntityRef typeRef = | 1115 EntityRef typeRef = |
| 1106 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1116 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1107 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1117 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', |
| 1108 numTypeParameters: 2); | 1118 numTypeParameters: 2, numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 1119 if (!checkAstDerivedData) { |
| 1120 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 1121 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 1122 } |
| 1109 } | 1123 } |
| 1110 | 1124 |
| 1111 test_class_alias_supertype() { | 1125 test_class_alias_supertype() { |
| 1112 UnlinkedClass cls = | 1126 UnlinkedClass cls = |
| 1113 serializeClassText('class C = D with E; class D {} class E {}'); | 1127 serializeClassText('class C = D with E; class D {} class E {}'); |
| 1114 checkTypeRef(cls.supertype, null, null, 'D'); | 1128 checkTypeRef(cls.supertype, null, null, 'D'); |
| 1115 expect(cls.hasNoSupertype, isFalse); | 1129 expect(cls.hasNoSupertype, isFalse); |
| 1116 } | 1130 } |
| 1117 | 1131 |
| 1118 test_class_codeRange() { | 1132 test_class_codeRange() { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 } | 1325 } |
| 1312 | 1326 |
| 1313 test_class_private() { | 1327 test_class_private() { |
| 1314 serializeClassText('class _C {}', className: '_C'); | 1328 serializeClassText('class _C {}', className: '_C'); |
| 1315 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1329 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1316 } | 1330 } |
| 1317 | 1331 |
| 1318 test_class_reference_generic() { | 1332 test_class_reference_generic() { |
| 1319 EntityRef typeRef = | 1333 EntityRef typeRef = |
| 1320 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); | 1334 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); |
| 1321 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1335 checkTypeRef(typeRef, null, null, 'C', |
| 1336 numTypeParameters: 2, numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 1337 if (!checkAstDerivedData) { |
| 1338 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 1339 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 1340 } |
| 1322 } | 1341 } |
| 1323 | 1342 |
| 1324 test_class_reference_generic_imported() { | 1343 test_class_reference_generic_imported() { |
| 1325 addNamedSource('/lib.dart', 'class C<D, E> {}'); | 1344 addNamedSource('/lib.dart', 'class C<D, E> {}'); |
| 1326 EntityRef typeRef = | 1345 EntityRef typeRef = |
| 1327 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1346 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1328 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1347 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', |
| 1329 numTypeParameters: 2); | 1348 numTypeParameters: 2, numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 1349 if (!checkAstDerivedData) { |
| 1350 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 1351 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 1352 } |
| 1330 } | 1353 } |
| 1331 | 1354 |
| 1332 test_class_superclass() { | 1355 test_class_superclass() { |
| 1333 UnlinkedClass cls = serializeClassText('class C {}'); | 1356 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1334 expect(cls.supertype, isNull); | 1357 expect(cls.supertype, isNull); |
| 1335 expect(cls.hasNoSupertype, isFalse); | 1358 expect(cls.hasNoSupertype, isFalse); |
| 1336 } | 1359 } |
| 1337 | 1360 |
| 1338 test_class_superclass_explicit() { | 1361 test_class_superclass_explicit() { |
| 1339 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); | 1362 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); |
| 1340 expect(cls.supertype, isNotNull); | 1363 expect(cls.supertype, isNotNull); |
| 1341 checkTypeRef(cls.supertype, null, null, 'D'); | 1364 checkTypeRef(cls.supertype, null, null, 'D'); |
| 1342 expect(cls.hasNoSupertype, isFalse); | 1365 expect(cls.hasNoSupertype, isFalse); |
| 1343 } | 1366 } |
| 1344 | 1367 |
| 1345 test_class_type_param_bound() { | 1368 test_class_type_param_bound() { |
| 1346 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); | 1369 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); |
| 1347 expect(cls.typeParameters, hasLength(1)); | 1370 expect(cls.typeParameters, hasLength(1)); |
| 1348 expect(cls.typeParameters[0].name, 'T'); | 1371 { |
| 1349 expect(cls.typeParameters[0].bound, isNotNull); | 1372 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; |
| 1350 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', | 1373 expect(typeParameter.name, 'T'); |
| 1351 numTypeParameters: 1); | 1374 expect(typeParameter.bound, isNotNull); |
| 1375 checkTypeRef(typeParameter.bound, 'dart:core', 'dart:core', 'List', |
| 1376 numTypeParameters: 1, numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 1377 if (!checkAstDerivedData) { |
| 1378 checkDynamicTypeRef(typeParameter.bound.typeArguments[0]); |
| 1379 } |
| 1380 } |
| 1352 } | 1381 } |
| 1353 | 1382 |
| 1354 test_class_type_param_f_bound() { | 1383 test_class_type_param_f_bound() { |
| 1355 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); | 1384 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); |
| 1356 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; | 1385 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; |
| 1357 checkParamTypeRef(typeArgument, 2); | 1386 checkParamTypeRef(typeArgument, 2); |
| 1358 } | 1387 } |
| 1359 | 1388 |
| 1360 test_class_type_param_f_bound_self_ref() { | 1389 test_class_type_param_f_bound_self_ref() { |
| 1361 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); | 1390 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); |
| (...skipping 6056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7418 serializeLibraryText('import "dart:async" as a; a.Future v;'); | 7447 serializeLibraryText('import "dart:async" as a; a.Future v;'); |
| 7419 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); | 7448 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); |
| 7420 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); | 7449 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); |
| 7421 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); | 7450 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); |
| 7422 } | 7451 } |
| 7423 | 7452 |
| 7424 test_import_prefix_reference() { | 7453 test_import_prefix_reference() { |
| 7425 UnlinkedVariable variable = | 7454 UnlinkedVariable variable = |
| 7426 serializeVariableText('import "dart:async" as a; a.Future v;'); | 7455 serializeVariableText('import "dart:async" as a; a.Future v;'); |
| 7427 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 7456 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', |
| 7428 expectedPrefix: 'a', numTypeParameters: 1); | 7457 expectedPrefix: 'a', |
| 7458 numTypeParameters: 1, |
| 7459 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7460 if (!checkAstDerivedData) { |
| 7461 checkDynamicTypeRef(variable.type.typeArguments[0]); |
| 7462 } |
| 7429 } | 7463 } |
| 7430 | 7464 |
| 7431 test_import_prefixes_take_precedence_over_imported_names() { | 7465 test_import_prefixes_take_precedence_over_imported_names() { |
| 7432 addNamedSource('/a.dart', 'class b {} class A'); | 7466 addNamedSource('/a.dart', 'class b {} class A'); |
| 7433 addNamedSource('/b.dart', 'class Cls {}'); | 7467 addNamedSource('/b.dart', 'class Cls {}'); |
| 7434 addNamedSource('/c.dart', 'class Cls {}'); | 7468 addNamedSource('/c.dart', 'class Cls {}'); |
| 7435 addNamedSource('/d.dart', 'class c {} class D'); | 7469 addNamedSource('/d.dart', 'class c {} class D'); |
| 7436 serializeLibraryText(''' | 7470 serializeLibraryText(''' |
| 7437 import 'a.dart'; | 7471 import 'a.dart'; |
| 7438 import 'b.dart' as b; | 7472 import 'b.dart' as b; |
| 7439 import 'c.dart' as c; | 7473 import 'c.dart' as c; |
| 7440 import 'd.dart'; | 7474 import 'd.dart'; |
| 7441 A aCls; | 7475 A aCls; |
| 7442 b.Cls bCls; | 7476 b.Cls bCls; |
| 7443 c.Cls cCls; | 7477 c.Cls cCls; |
| 7444 D dCls; | 7478 D dCls; |
| 7445 '''); | 7479 '''); |
| 7446 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'a.dart', 'A'); | 7480 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'a.dart', 'A'); |
| 7447 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'b.dart', 'Cls', | 7481 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'b.dart', 'Cls', |
| 7448 expectedPrefix: 'b'); | 7482 expectedPrefix: 'b'); |
| 7449 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'c.dart', 'Cls', | 7483 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'c.dart', 'Cls', |
| 7450 expectedPrefix: 'c'); | 7484 expectedPrefix: 'c'); |
| 7451 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'd.dart', 'D'); | 7485 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'd.dart', 'D'); |
| 7452 } | 7486 } |
| 7453 | 7487 |
| 7454 test_import_reference() { | 7488 test_import_reference() { |
| 7455 UnlinkedVariable variable = | 7489 UnlinkedVariable variable = |
| 7456 serializeVariableText('import "dart:async"; Future v;'); | 7490 serializeVariableText('import "dart:async"; Future v;'); |
| 7457 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 7491 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', |
| 7458 numTypeParameters: 1); | 7492 numTypeParameters: 1, numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7493 if (!checkAstDerivedData) { |
| 7494 checkDynamicTypeRef(variable.type.typeArguments[0]); |
| 7495 } |
| 7459 } | 7496 } |
| 7460 | 7497 |
| 7461 test_import_reference_merged_no_prefix() { | 7498 test_import_reference_merged_no_prefix() { |
| 7462 serializeLibraryText(''' | 7499 serializeLibraryText(''' |
| 7463 import "dart:async" show Future; | 7500 import "dart:async" show Future; |
| 7464 import "dart:async" show Stream; | 7501 import "dart:async" show Stream; |
| 7465 | 7502 |
| 7466 Future f; | 7503 Future f; |
| 7467 Stream s; | 7504 Stream s; |
| 7468 '''); | 7505 '''); |
| 7469 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future', | 7506 { |
| 7470 numTypeParameters: 1); | 7507 EntityRef typeRef = findVariable('f').type; |
| 7471 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', | 7508 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', |
| 7472 expectedTargetUnit: 1, numTypeParameters: 1); | 7509 numTypeParameters: 1, numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7510 if (!checkAstDerivedData) { |
| 7511 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 7512 } |
| 7513 } |
| 7514 { |
| 7515 EntityRef typeRef = findVariable('s').type; |
| 7516 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', |
| 7517 expectedTargetUnit: 1, |
| 7518 numTypeParameters: 1, |
| 7519 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7520 if (!checkAstDerivedData) { |
| 7521 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 7522 } |
| 7523 } |
| 7473 } | 7524 } |
| 7474 | 7525 |
| 7475 test_import_reference_merged_prefixed() { | 7526 test_import_reference_merged_prefixed() { |
| 7476 serializeLibraryText(''' | 7527 serializeLibraryText(''' |
| 7477 import "dart:async" as a show Future; | 7528 import "dart:async" as a show Future; |
| 7478 import "dart:async" as a show Stream; | 7529 import "dart:async" as a show Stream; |
| 7479 | 7530 |
| 7480 a.Future f; | 7531 a.Future f; |
| 7481 a.Stream s; | 7532 a.Stream s; |
| 7482 '''); | 7533 '''); |
| 7483 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future', | 7534 { |
| 7484 expectedPrefix: 'a', numTypeParameters: 1); | 7535 EntityRef typeRef = findVariable('f').type; |
| 7485 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', | 7536 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', |
| 7486 expectedTargetUnit: 1, expectedPrefix: 'a', numTypeParameters: 1); | 7537 expectedPrefix: 'a', |
| 7538 numTypeParameters: 1, |
| 7539 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7540 if (!checkAstDerivedData) { |
| 7541 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 7542 } |
| 7543 } |
| 7544 { |
| 7545 EntityRef typeRef = findVariable('s').type; |
| 7546 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', |
| 7547 expectedTargetUnit: 1, |
| 7548 expectedPrefix: 'a', |
| 7549 numTypeParameters: 1, |
| 7550 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 7551 if (!checkAstDerivedData) { |
| 7552 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 7553 } |
| 7554 } |
| 7487 } | 7555 } |
| 7488 | 7556 |
| 7489 test_import_reference_merged_prefixed_separate_libraries() { | 7557 test_import_reference_merged_prefixed_separate_libraries() { |
| 7490 addNamedSource('/a.dart', 'class A {}'); | 7558 addNamedSource('/a.dart', 'class A {}'); |
| 7491 addNamedSource('/b.dart', 'class B {}'); | 7559 addNamedSource('/b.dart', 'class B {}'); |
| 7492 serializeLibraryText(''' | 7560 serializeLibraryText(''' |
| 7493 import 'a.dart' as p; | 7561 import 'a.dart' as p; |
| 7494 import 'b.dart' as p; | 7562 import 'b.dart' as p; |
| 7495 | 7563 |
| 7496 p.A a; | 7564 p.A a; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7566 void f(g) {} | 7634 void f(g) {} |
| 7567 } | 7635 } |
| 7568 '''); | 7636 '''); |
| 7569 expect(c.executables, hasLength(1)); | 7637 expect(c.executables, hasLength(1)); |
| 7570 UnlinkedExecutable f = c.executables[0]; | 7638 UnlinkedExecutable f = c.executables[0]; |
| 7571 expect(f.parameters, hasLength(1)); | 7639 expect(f.parameters, hasLength(1)); |
| 7572 UnlinkedParam g = f.parameters[0]; | 7640 UnlinkedParam g = f.parameters[0]; |
| 7573 expect(g.name, 'g'); | 7641 expect(g.name, 'g'); |
| 7574 EntityRef typeRef = getTypeRefForSlot(g.inferredTypeSlot); | 7642 EntityRef typeRef = getTypeRefForSlot(g.inferredTypeSlot); |
| 7575 checkLinkedTypeRef(typeRef, null, null, 'f', | 7643 checkLinkedTypeRef(typeRef, null, null, 'f', |
| 7576 expectedKind: ReferenceKind.method, allowTypeArguments: true); | 7644 expectedKind: ReferenceKind.method, numTypeArguments: 1); |
| 7577 expect(typeRef.typeArguments, hasLength(1)); | 7645 checkLinkedDynamicTypeRef(typeRef.typeArguments[0]); |
| 7578 checkLinkedTypeRef(typeRef.typeArguments[0], null, null, 'dynamic'); | |
| 7579 } | 7646 } |
| 7580 | 7647 |
| 7581 test_inferred_type_keeps_leading_dynamic() { | 7648 test_inferred_type_keeps_leading_dynamic() { |
| 7582 if (!strongMode || skipFullyLinkedData) { | 7649 if (!strongMode || skipFullyLinkedData) { |
| 7583 return; | 7650 return; |
| 7584 } | 7651 } |
| 7585 UnlinkedClass cls = | 7652 UnlinkedClass cls = |
| 7586 serializeClassText('class C { final x = <dynamic, int>{}; }'); | 7653 serializeClassText('class C { final x = <dynamic, int>{}; }'); |
| 7587 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7654 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7588 // Check that x has inferred type `Map<dynamic, int>`. | 7655 // Check that x has inferred type `Map<dynamic, int>`. |
| 7589 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7656 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7590 allowTypeArguments: true, numTypeParameters: 2); | 7657 numTypeParameters: 2, numTypeArguments: 2); |
| 7591 expect(type.typeArguments, hasLength(2)); | |
| 7592 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); | 7658 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); |
| 7593 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 7659 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7594 } | 7660 } |
| 7595 | 7661 |
| 7596 test_inferred_type_refers_to_bound_type_param() { | 7662 test_inferred_type_refers_to_bound_type_param() { |
| 7597 if (!strongMode || skipFullyLinkedData) { | 7663 if (!strongMode || skipFullyLinkedData) { |
| 7598 return; | 7664 return; |
| 7599 } | 7665 } |
| 7600 UnlinkedClass cls = serializeClassText( | 7666 UnlinkedClass cls = serializeClassText( |
| 7601 'class C<T> extends D<int, T> { var v; }' | 7667 'class C<T> extends D<int, T> { var v; }' |
| 7602 ' abstract class D<U, V> { Map<V, U> get v; }', | 7668 ' abstract class D<U, V> { Map<V, U> get v; }', |
| 7603 className: 'C'); | 7669 className: 'C'); |
| 7604 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7670 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7605 // Check that v has inferred type Map<T, int>. | 7671 // Check that v has inferred type Map<T, int>. |
| 7606 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7672 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7607 allowTypeArguments: true, numTypeParameters: 2); | 7673 numTypeParameters: 2, numTypeArguments: 2); |
| 7608 checkParamTypeRef(type.typeArguments[0], 1); | 7674 checkParamTypeRef(type.typeArguments[0], 1); |
| 7609 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 7675 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7610 } | 7676 } |
| 7611 | 7677 |
| 7612 test_inferred_type_refers_to_function_typed_param_of_typedef() { | 7678 test_inferred_type_refers_to_function_typed_param_of_typedef() { |
| 7613 if (!strongMode || skipFullyLinkedData) { | 7679 if (!strongMode || skipFullyLinkedData) { |
| 7614 return; | 7680 return; |
| 7615 } | 7681 } |
| 7616 UnlinkedVariable v = serializeVariableText(''' | 7682 UnlinkedVariable v = serializeVariableText(''' |
| 7617 typedef void F(int g(String s)); | 7683 typedef void F(int g(String s)); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7788 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); | 7854 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); |
| 7789 } | 7855 } |
| 7790 | 7856 |
| 7791 test_inferred_type_skips_trailing_dynamic() { | 7857 test_inferred_type_skips_trailing_dynamic() { |
| 7792 if (!strongMode || skipFullyLinkedData) { | 7858 if (!strongMode || skipFullyLinkedData) { |
| 7793 return; | 7859 return; |
| 7794 } | 7860 } |
| 7795 UnlinkedClass cls = | 7861 UnlinkedClass cls = |
| 7796 serializeClassText('class C { final x = <int, dynamic>{}; }'); | 7862 serializeClassText('class C { final x = <int, dynamic>{}; }'); |
| 7797 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7863 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7798 // Check that x has inferred type `Map<int>`. The trailing type argument | 7864 // Check that x has inferred type `Map<int, dynamic>`. |
| 7799 // `dynamic` is omitted. | |
| 7800 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7865 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7801 allowTypeArguments: true, numTypeParameters: 2); | 7866 numTypeParameters: 2, numTypeArguments: 2); |
| 7802 expect(type.typeArguments, hasLength(1)); | |
| 7803 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 7867 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 7868 checkLinkedDynamicTypeRef(type.typeArguments[1]); |
| 7804 } | 7869 } |
| 7805 | 7870 |
| 7806 test_inferred_type_skips_unnecessary_dynamic() { | 7871 test_inferred_type_skips_unnecessary_dynamic() { |
| 7807 if (!strongMode || skipFullyLinkedData) { | 7872 if (!strongMode || skipFullyLinkedData) { |
| 7808 return; | 7873 return; |
| 7809 } | 7874 } |
| 7810 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); | 7875 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); |
| 7811 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7876 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7812 // Check that x has inferred type `List`, not `List<dynamic>`. | 7877 // Check that x has inferred type `List<dynamic>`. |
| 7813 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', | 7878 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', |
| 7814 numTypeParameters: 1); | 7879 numTypeParameters: 1, numTypeArguments: 1); |
| 7815 } | 7880 } |
| 7816 | 7881 |
| 7817 test_initializer_executable_with_bottom_return_type() { | 7882 test_initializer_executable_with_bottom_return_type() { |
| 7818 // The synthetic executable for `v` has type `() => Bottom`. | 7883 // The synthetic executable for `v` has type `() => Bottom`. |
| 7819 UnlinkedVariable variable = serializeVariableText('int v = null;'); | 7884 UnlinkedVariable variable = serializeVariableText('int v = null;'); |
| 7820 expect(variable.initializer.returnType, isNull); | 7885 expect(variable.initializer.returnType, isNull); |
| 7821 checkInferredTypeSlot( | 7886 checkInferredTypeSlot( |
| 7822 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', | 7887 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', |
| 7823 onlyInStrongMode: false); | 7888 onlyInStrongMode: false); |
| 7824 } | 7889 } |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8938 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', | 9003 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', |
| 8939 'dart:core', 'int'); | 9004 'dart:core', 'int'); |
| 8940 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', | 9005 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', |
| 8941 'dart:core', 'String'); | 9006 'dart:core', 'String'); |
| 8942 } | 9007 } |
| 8943 | 9008 |
| 8944 test_type_arguments_explicit() { | 9009 test_type_arguments_explicit() { |
| 8945 EntityRef typeRef = serializeTypeText('List<int>'); | 9010 EntityRef typeRef = serializeTypeText('List<int>'); |
| 8946 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9011 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 8947 numTypeParameters: 1, numTypeArguments: 1); | 9012 numTypeParameters: 1, numTypeArguments: 1); |
| 8948 expect(typeRef.typeArguments, hasLength(1)); | |
| 8949 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9013 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 8950 } | 9014 } |
| 8951 | 9015 |
| 8952 test_type_arguments_explicit_dynamic() { | 9016 test_type_arguments_explicit_dynamic() { |
| 8953 EntityRef typeRef = serializeTypeText('List<dynamic>'); | 9017 EntityRef typeRef = serializeTypeText('List<dynamic>'); |
| 8954 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9018 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 8955 numTypeParameters: 1); | 9019 numTypeParameters: 1, numTypeArguments: 1); |
| 8956 expect(typeRef.typeArguments, isEmpty); | 9020 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8957 } | 9021 } |
| 8958 | 9022 |
| 8959 test_type_arguments_explicit_dynamic_dynamic() { | 9023 test_type_arguments_explicit_dynamic_dynamic() { |
| 8960 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); | 9024 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); |
| 8961 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9025 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8962 numTypeParameters: 2); | 9026 numTypeParameters: 2, numTypeArguments: 2); |
| 8963 // Trailing type arguments of type `dynamic` are omitted. | 9027 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8964 expect(typeRef.typeArguments, isEmpty); | 9028 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 8965 } | 9029 } |
| 8966 | 9030 |
| 8967 test_type_arguments_explicit_dynamic_int() { | 9031 test_type_arguments_explicit_dynamic_int() { |
| 8968 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); | 9032 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); |
| 8969 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9033 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8970 numTypeParameters: 2, numTypeArguments: 2); | 9034 numTypeParameters: 2, numTypeArguments: 2); |
| 8971 // Leading type arguments of type `dynamic` are not omitted. | |
| 8972 expect(typeRef.typeArguments.length, 2); | |
| 8973 checkDynamicTypeRef(typeRef.typeArguments[0]); | 9035 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8974 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 9036 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 8975 } | 9037 } |
| 8976 | 9038 |
| 8977 test_type_arguments_explicit_dynamic_typedef() { | 9039 test_type_arguments_explicit_dynamic_typedef() { |
| 8978 EntityRef typeRef = | 9040 EntityRef typeRef = |
| 8979 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); | 9041 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); |
| 8980 checkTypeRef(typeRef, null, null, 'F', | 9042 checkTypeRef(typeRef, null, null, 'F', |
| 8981 expectedKind: ReferenceKind.typedef, | 9043 expectedKind: ReferenceKind.typedef, |
| 8982 numTypeParameters: 1, | 9044 numTypeParameters: 1, |
| 8983 numTypeArguments: 0); | 9045 numTypeArguments: 1); |
| 8984 expect(typeRef.typeArguments, isEmpty); | 9046 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8985 } | 9047 } |
| 8986 | 9048 |
| 8987 test_type_arguments_explicit_String_dynamic() { | 9049 test_type_arguments_explicit_String_dynamic() { |
| 8988 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); | 9050 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); |
| 8989 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9051 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8990 numTypeParameters: 2, numTypeArguments: 1); | 9052 numTypeParameters: 2, numTypeArguments: 2); |
| 8991 // Trailing type arguments of type `dynamic` are omitted. | |
| 8992 expect(typeRef.typeArguments.length, 1); | |
| 8993 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 9053 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
| 9054 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 8994 } | 9055 } |
| 8995 | 9056 |
| 8996 test_type_arguments_explicit_String_int() { | 9057 test_type_arguments_explicit_String_int() { |
| 8997 EntityRef typeRef = serializeTypeText('Map<String, int>'); | 9058 EntityRef typeRef = serializeTypeText('Map<String, int>'); |
| 8998 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9059 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8999 numTypeParameters: 2, numTypeArguments: 2); | 9060 numTypeParameters: 2, numTypeArguments: 2); |
| 9000 expect(typeRef.typeArguments.length, 2); | |
| 9001 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 9061 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
| 9002 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 9062 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 9003 } | 9063 } |
| 9004 | 9064 |
| 9005 test_type_arguments_explicit_typedef() { | 9065 test_type_arguments_explicit_typedef() { |
| 9006 EntityRef typeRef = | 9066 EntityRef typeRef = |
| 9007 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); | 9067 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); |
| 9008 checkTypeRef(typeRef, null, null, 'F', | 9068 checkTypeRef(typeRef, null, null, 'F', |
| 9009 expectedKind: ReferenceKind.typedef, | 9069 expectedKind: ReferenceKind.typedef, |
| 9010 numTypeParameters: 1, | 9070 numTypeParameters: 1, |
| 9011 numTypeArguments: 1); | 9071 numTypeArguments: 1); |
| 9012 expect(typeRef.typeArguments, hasLength(1)); | |
| 9013 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9072 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 9014 } | 9073 } |
| 9015 | 9074 |
| 9016 test_type_arguments_implicit() { | 9075 test_type_arguments_implicit() { |
| 9017 EntityRef typeRef = serializeTypeText('List'); | 9076 EntityRef typeRef = serializeTypeText('List'); |
| 9018 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9077 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 9019 numTypeParameters: 1); | 9078 numTypeParameters: 1, numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 9020 expect(typeRef.typeArguments, isEmpty); | 9079 if (!checkAstDerivedData) { |
| 9080 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9081 } |
| 9021 } | 9082 } |
| 9022 | 9083 |
| 9023 test_type_arguments_implicit_typedef() { | 9084 test_type_arguments_implicit_typedef() { |
| 9024 EntityRef typeRef = | 9085 EntityRef typeRef = |
| 9025 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); | 9086 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); |
| 9026 checkTypeRef(typeRef, null, null, 'F', | 9087 checkTypeRef(typeRef, null, null, 'F', |
| 9027 expectedKind: ReferenceKind.typedef, | 9088 expectedKind: ReferenceKind.typedef, |
| 9028 numTypeParameters: 1, | 9089 numTypeParameters: 1, |
| 9029 numTypeArguments: 0); | 9090 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 9030 expect(typeRef.typeArguments, isEmpty); | 9091 if (!checkAstDerivedData) { |
| 9092 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9093 } |
| 9094 } |
| 9095 |
| 9096 test_type_arguments_implicit_typedef_withBound() { |
| 9097 EntityRef typeRef = serializeTypeText('F', |
| 9098 otherDeclarations: 'typedef T F<T extends num>();'); |
| 9099 checkTypeRef(typeRef, null, null, 'F', |
| 9100 expectedKind: ReferenceKind.typedef, |
| 9101 numTypeParameters: 1, |
| 9102 numTypeArguments: !checkAstDerivedData ? 1 : 0); |
| 9103 if (!checkAstDerivedData) { |
| 9104 if (strongMode) { |
| 9105 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'num'); |
| 9106 } else { |
| 9107 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9108 } |
| 9109 } |
| 9031 } | 9110 } |
| 9032 | 9111 |
| 9033 test_type_arguments_order() { | 9112 test_type_arguments_order() { |
| 9034 EntityRef typeRef = serializeTypeText('Map<int, Object>'); | 9113 EntityRef typeRef = serializeTypeText('Map<int, Object>'); |
| 9035 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9114 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 9036 numTypeParameters: 2, numTypeArguments: 2); | 9115 numTypeParameters: 2, numTypeArguments: 2); |
| 9037 expect(typeRef.typeArguments, hasLength(2)); | |
| 9038 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9116 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 9039 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); | 9117 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); |
| 9040 } | 9118 } |
| 9041 | 9119 |
| 9042 test_type_dynamic() { | 9120 test_type_dynamic() { |
| 9043 checkDynamicTypeRef(serializeTypeText('dynamic')); | 9121 checkDynamicTypeRef(serializeTypeText('dynamic')); |
| 9044 } | 9122 } |
| 9045 | 9123 |
| 9046 test_type_param_codeRange() { | 9124 test_type_param_codeRange() { |
| 9047 UnlinkedClass cls = | 9125 UnlinkedClass cls = |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9351 | 9429 |
| 9352 test_typedef_private() { | 9430 test_typedef_private() { |
| 9353 serializeTypedefText('typedef _F();', '_F'); | 9431 serializeTypedefText('typedef _F();', '_F'); |
| 9354 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 9432 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 9355 } | 9433 } |
| 9356 | 9434 |
| 9357 test_typedef_reference_generic() { | 9435 test_typedef_reference_generic() { |
| 9358 EntityRef typeRef = | 9436 EntityRef typeRef = |
| 9359 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); | 9437 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); |
| 9360 checkTypeRef(typeRef, null, null, 'F', | 9438 checkTypeRef(typeRef, null, null, 'F', |
| 9361 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 9439 numTypeParameters: 2, |
| 9440 expectedKind: ReferenceKind.typedef, |
| 9441 numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 9442 if (!checkAstDerivedData) { |
| 9443 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9444 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 9445 } |
| 9362 } | 9446 } |
| 9363 | 9447 |
| 9364 test_typedef_reference_generic_imported() { | 9448 test_typedef_reference_generic_imported() { |
| 9365 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); | 9449 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); |
| 9366 EntityRef typeRef = | 9450 EntityRef typeRef = |
| 9367 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); | 9451 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); |
| 9368 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', | 9452 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', |
| 9369 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 9453 numTypeParameters: 2, |
| 9454 expectedKind: ReferenceKind.typedef, |
| 9455 numTypeArguments: !checkAstDerivedData ? 2 : 0); |
| 9456 if (!checkAstDerivedData) { |
| 9457 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 9458 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 9459 } |
| 9370 } | 9460 } |
| 9371 | 9461 |
| 9372 test_typedef_return_type_explicit() { | 9462 test_typedef_return_type_explicit() { |
| 9373 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); | 9463 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); |
| 9374 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); | 9464 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); |
| 9375 } | 9465 } |
| 9376 | 9466 |
| 9377 test_typedef_type_param_in_parameter() { | 9467 test_typedef_type_param_in_parameter() { |
| 9378 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); | 9468 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); |
| 9379 checkParamTypeRef(type.parameters[0].type, 1); | 9469 checkParamTypeRef(type.parameters[0].type, 1); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9647 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 9737 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 9648 } | 9738 } |
| 9649 | 9739 |
| 9650 test_variable_propagated_type_omit_dynamic() { | 9740 test_variable_propagated_type_omit_dynamic() { |
| 9651 if (skipFullyLinkedData) { | 9741 if (skipFullyLinkedData) { |
| 9652 return; | 9742 return; |
| 9653 } | 9743 } |
| 9654 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};'); | 9744 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};'); |
| 9655 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot); | 9745 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot); |
| 9656 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 9746 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 9657 allowTypeArguments: true, numTypeParameters: 2); | 9747 numTypeParameters: 2, numTypeArguments: 2); |
| 9658 expect(type.typeArguments, hasLength(1)); | |
| 9659 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9748 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 9749 checkLinkedDynamicTypeRef(type.typeArguments[1]); |
| 9660 } | 9750 } |
| 9661 | 9751 |
| 9662 test_variable_propagatedTypeSlot_const() { | 9752 test_variable_propagatedTypeSlot_const() { |
| 9663 // Const variables are propagable so they have a nonzero | 9753 // Const variables are propagable so they have a nonzero |
| 9664 // propagatedTypeSlot. | 9754 // propagatedTypeSlot. |
| 9665 UnlinkedVariable variable = serializeVariableText('const v = 0;'); | 9755 UnlinkedVariable variable = serializeVariableText('const v = 0;'); |
| 9666 expect(variable.propagatedTypeSlot, isNot(0)); | 9756 expect(variable.propagatedTypeSlot, isNot(0)); |
| 9667 } | 9757 } |
| 9668 | 9758 |
| 9669 test_variable_propagatedTypeSlot_final() { | 9759 test_variable_propagatedTypeSlot_final() { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9860 class _PrefixExpectation { | 9950 class _PrefixExpectation { |
| 9861 final ReferenceKind kind; | 9951 final ReferenceKind kind; |
| 9862 final String name; | 9952 final String name; |
| 9863 final String absoluteUri; | 9953 final String absoluteUri; |
| 9864 final String relativeUri; | 9954 final String relativeUri; |
| 9865 final int numTypeParameters; | 9955 final int numTypeParameters; |
| 9866 | 9956 |
| 9867 _PrefixExpectation(this.kind, this.name, | 9957 _PrefixExpectation(this.kind, this.name, |
| 9868 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9958 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9869 } | 9959 } |
| OLD | NEW |