Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 * that summaries need, so that this flag is no longer needed. | 156 * that summaries need, so that this flag is no longer needed. |
| 157 */ | 157 */ |
| 158 bool get checkAstDerivedData; | 158 bool get checkAstDerivedData; |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * Get access to the linked defining compilation unit. | 161 * Get access to the linked defining compilation unit. |
| 162 */ | 162 */ |
| 163 LinkedUnit get definingUnit => linked.units[0]; | 163 LinkedUnit get definingUnit => linked.units[0]; |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * `true` if element model was used to produce summary. | |
| 167 */ | |
| 168 bool get elementMode; | |
|
Paul Berry
2016/05/06 18:11:38
This is redundant. Use `!checkAstDerivedData` ins
scheglov
2016/05/06 19:12:36
Done.
| |
| 169 | |
| 170 /** | |
| 166 * `true` if the linked portion of the summary is expected to contain | 171 * `true` if the linked portion of the summary is expected to contain |
| 167 * absolute URIs. This happens because the element model doesn't (yet) store | 172 * absolute URIs. This happens because the element model doesn't (yet) store |
| 168 * enough information to recover relative URIs, TODO(paulberry): fix this. | 173 * enough information to recover relative URIs, TODO(paulberry): fix this. |
| 169 */ | 174 */ |
| 170 bool get expectAbsoluteUrisInDependencies; | 175 bool get expectAbsoluteUrisInDependencies; |
| 171 | 176 |
| 172 /** | 177 /** |
| 173 * Get access to the linked summary that results from serializing and | 178 * Get access to the linked summary that results from serializing and |
| 174 * then deserializing the library under test. | 179 * then deserializing the library under test. |
| 175 */ | 180 */ |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 return null; | 355 return null; |
| 351 } | 356 } |
| 352 | 357 |
| 353 /** | 358 /** |
| 354 * Test an inferred type. If [onlyInStrongMode] is `true` (the default) and | 359 * 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 | 360 * strong mode is disabled, verify that the given [slotId] exists and has no |
| 356 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. | 361 * associated type. Otherwise, behave as in [checkLinkedTypeSlot]. |
| 357 */ | 362 */ |
| 358 void checkInferredTypeSlot( | 363 void checkInferredTypeSlot( |
| 359 int slotId, String absoluteUri, String relativeUri, String expectedName, | 364 int slotId, String absoluteUri, String relativeUri, String expectedName, |
| 360 {bool allowTypeParameters: false, | 365 {int numTypeArguments: 0, |
| 361 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 366 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 362 int expectedTargetUnit: 0, | 367 int expectedTargetUnit: 0, |
| 363 LinkedUnit linkedSourceUnit, | 368 LinkedUnit linkedSourceUnit, |
| 364 UnlinkedUnit unlinkedSourceUnit, | 369 UnlinkedUnit unlinkedSourceUnit, |
| 365 int numTypeParameters: 0, | 370 int numTypeParameters: 0, |
| 366 bool onlyInStrongMode: true}) { | 371 bool onlyInStrongMode: true}) { |
| 367 if (strongMode || !onlyInStrongMode) { | 372 if (strongMode || !onlyInStrongMode) { |
| 368 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName, | 373 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName, |
| 369 allowTypeArguments: allowTypeParameters, | 374 numTypeArguments: numTypeArguments, |
| 370 expectedKind: expectedKind, | 375 expectedKind: expectedKind, |
| 371 expectedTargetUnit: expectedTargetUnit, | 376 expectedTargetUnit: expectedTargetUnit, |
| 372 linkedSourceUnit: linkedSourceUnit, | 377 linkedSourceUnit: linkedSourceUnit, |
| 373 unlinkedSourceUnit: unlinkedSourceUnit, | 378 unlinkedSourceUnit: unlinkedSourceUnit, |
| 374 numTypeParameters: numTypeParameters); | 379 numTypeParameters: numTypeParameters); |
| 375 } else { | 380 } else { |
| 376 // A slot id should have been assigned but it should not be associated | 381 // A slot id should have been assigned but it should not be associated |
| 377 // with any type. | 382 // with any type. |
| 378 expect(slotId, isNot(0)); | 383 expect(slotId, isNot(0)); |
| 379 expect(getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), | 384 expect(getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 393 relativeUri = absoluteUri; | 398 relativeUri = absoluteUri; |
| 394 } | 399 } |
| 395 for (LinkedDependency dep in linked.dependencies) { | 400 for (LinkedDependency dep in linked.dependencies) { |
| 396 if (dep.uri == relativeUri) { | 401 if (dep.uri == relativeUri) { |
| 397 fail('Unexpected dependency found: $relativeUri'); | 402 fail('Unexpected dependency found: $relativeUri'); |
| 398 } | 403 } |
| 399 } | 404 } |
| 400 } | 405 } |
| 401 | 406 |
| 402 /** | 407 /** |
| 408 * Verify that the given [typeRef] represents the type `dynamic`. | |
| 409 */ | |
| 410 void checkLinkedDynamicTypeRef(EntityRef typeRef) { | |
| 411 checkLinkedTypeRef(typeRef, null, null, 'dynamic'); | |
| 412 } | |
| 413 | |
| 414 /** | |
| 403 * Verify that the given [typeRef] represents a reference to a type declared | 415 * Verify that the given [typeRef] represents a reference to a type declared |
| 404 * in a file reachable via [absoluteUri] and [relativeUri], having name | 416 * in a file reachable via [absoluteUri] and [relativeUri], having name |
| 405 * [expectedName]. If [allowTypeArguments] is true, allow the type | 417 * [expectedName]. Verify that the number of type arguments |
| 406 * reference to supply type arguments. [expectedKind] is the kind of object | 418 * is equal to [numTypeArguments]. [expectedKind] is the kind of object |
| 407 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 419 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the |
| 408 * compilation unit within which the [typeRef] appears; if not specified they | 420 * compilation unit within which the [typeRef] appears; if not specified they |
| 409 * are assumed to refer to the defining compilation unit. | 421 * are assumed to refer to the defining compilation unit. |
| 410 * [expectedTargetUnit] is the index of the compilation unit in which the | 422 * [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 | 423 * target of the [typeRef] is expected to appear; if not specified it is |
| 412 * assumed to be the defining compilation unit. [numTypeParameters] is the | 424 * assumed to be the defining compilation unit. [numTypeParameters] is the |
| 413 * number of type parameters of the thing being referred to. | 425 * number of type parameters of the thing being referred to. |
| 414 */ | 426 */ |
| 415 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri, | 427 void checkLinkedTypeRef(EntityRef typeRef, String absoluteUri, |
| 416 String relativeUri, String expectedName, | 428 String relativeUri, String expectedName, |
| 417 {bool allowTypeArguments: false, | 429 {int numTypeArguments: 0, |
| 418 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 430 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 419 int expectedTargetUnit: 0, | 431 int expectedTargetUnit: 0, |
| 420 LinkedUnit linkedSourceUnit, | 432 LinkedUnit linkedSourceUnit, |
| 421 UnlinkedUnit unlinkedSourceUnit, | 433 UnlinkedUnit unlinkedSourceUnit, |
| 422 int numTypeParameters: 0}) { | 434 int numTypeParameters: 0}) { |
| 423 linkedSourceUnit ??= definingUnit; | 435 linkedSourceUnit ??= definingUnit; |
| 424 expect(typeRef, isNotNull, | 436 expect(typeRef, isNotNull, |
| 425 reason: 'No entry in linkedSourceUnit.types matching slotId'); | 437 reason: 'No entry in linkedSourceUnit.types matching slotId'); |
| 426 expect(typeRef.paramReference, 0); | 438 expect(typeRef.paramReference, 0); |
| 427 int index = typeRef.reference; | 439 int index = typeRef.reference; |
| 428 if (!allowTypeArguments) { | 440 expect(typeRef.typeArguments, hasLength(numTypeArguments)); |
| 429 expect(typeRef.typeArguments, isEmpty); | |
| 430 } | |
| 431 checkReferenceIndex(index, absoluteUri, relativeUri, expectedName, | 441 checkReferenceIndex(index, absoluteUri, relativeUri, expectedName, |
| 432 expectedKind: expectedKind, | 442 expectedKind: expectedKind, |
| 433 expectedTargetUnit: expectedTargetUnit, | 443 expectedTargetUnit: expectedTargetUnit, |
| 434 linkedSourceUnit: linkedSourceUnit, | 444 linkedSourceUnit: linkedSourceUnit, |
| 435 unlinkedSourceUnit: unlinkedSourceUnit, | 445 unlinkedSourceUnit: unlinkedSourceUnit, |
| 436 numTypeParameters: numTypeParameters); | 446 numTypeParameters: numTypeParameters); |
| 437 } | 447 } |
| 438 | 448 |
| 439 /** | 449 /** |
| 440 * Verify that the given [slotId] represents a reference to a type declared | 450 * Verify that the given [slotId] represents a reference to a type declared |
| 441 * in a file reachable via [absoluteUri] and [relativeUri], having name | 451 * in a file reachable via [absoluteUri] and [relativeUri], having name |
| 442 * [expectedName]. If [allowTypeArguments] is true, allow the type | 452 * [expectedName]. Verify that the number of type arguments |
| 443 * reference to supply type arguments. [expectedKind] is the kind of object | 453 * is equal to [numTypeArguments]. [expectedKind] is the kind of object |
| 444 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the | 454 * referenced. [linkedSourceUnit] and [unlinkedSourceUnit] refer to the |
| 445 * compilation unit within which the [typeRef] appears; if not specified they | 455 * compilation unit within which the [typeRef] appears; if not specified they |
| 446 * are assumed to refer to the defining compilation unit. | 456 * are assumed to refer to the defining compilation unit. |
| 447 * [expectedTargetUnit] is the index of the compilation unit in which the | 457 * [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 | 458 * target of the [typeRef] is expected to appear; if not specified it is |
| 449 * assumed to be the defining compilation unit. [numTypeParameters] is the | 459 * assumed to be the defining compilation unit. [numTypeParameters] is the |
| 450 * number of type parameters of the thing being referred to. | 460 * number of type parameters of the thing being referred to. |
| 451 */ | 461 */ |
| 452 void checkLinkedTypeSlot( | 462 void checkLinkedTypeSlot( |
| 453 int slotId, String absoluteUri, String relativeUri, String expectedName, | 463 int slotId, String absoluteUri, String relativeUri, String expectedName, |
| 454 {bool allowTypeArguments: false, | 464 {int numTypeArguments: 0, |
| 455 ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 465 ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 456 int expectedTargetUnit: 0, | 466 int expectedTargetUnit: 0, |
| 457 LinkedUnit linkedSourceUnit, | 467 LinkedUnit linkedSourceUnit, |
| 458 UnlinkedUnit unlinkedSourceUnit, | 468 UnlinkedUnit unlinkedSourceUnit, |
| 459 int numTypeParameters: 0}) { | 469 int numTypeParameters: 0}) { |
| 460 // Slot ids should be nonzero, since zero means "no associated slot". | 470 // Slot ids should be nonzero, since zero means "no associated slot". |
| 461 expect(slotId, isNot(0)); | 471 expect(slotId, isNot(0)); |
| 462 if (skipFullyLinkedData) { | 472 if (skipFullyLinkedData) { |
| 463 return; | 473 return; |
| 464 } | 474 } |
| 465 linkedSourceUnit ??= definingUnit; | 475 linkedSourceUnit ??= definingUnit; |
| 466 checkLinkedTypeRef( | 476 checkLinkedTypeRef( |
| 467 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), | 477 getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit), |
| 468 absoluteUri, | 478 absoluteUri, |
| 469 relativeUri, | 479 relativeUri, |
| 470 expectedName, | 480 expectedName, |
| 471 allowTypeArguments: allowTypeArguments, | 481 numTypeArguments: numTypeArguments, |
| 472 expectedKind: expectedKind, | 482 expectedKind: expectedKind, |
| 473 expectedTargetUnit: expectedTargetUnit, | 483 expectedTargetUnit: expectedTargetUnit, |
| 474 linkedSourceUnit: linkedSourceUnit, | 484 linkedSourceUnit: linkedSourceUnit, |
| 475 unlinkedSourceUnit: unlinkedSourceUnit, | 485 unlinkedSourceUnit: unlinkedSourceUnit, |
| 476 numTypeParameters: numTypeParameters); | 486 numTypeParameters: numTypeParameters); |
| 477 } | 487 } |
| 478 | 488 |
| 479 /** | 489 /** |
| 480 * Verify that the given [typeRef] represents a reference to a type parameter | 490 * Verify that the given [typeRef] represents a reference to a type parameter |
| 481 * having the given [deBruijnIndex]. | 491 * having the given [deBruijnIndex]. |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 | 1099 |
| 1090 test_class_alias_private() { | 1100 test_class_alias_private() { |
| 1091 serializeClassText('class _C = _D with _E; class _D {} class _E {}', | 1101 serializeClassText('class _C = _D with _E; class _D {} class _E {}', |
| 1092 className: '_C'); | 1102 className: '_C'); |
| 1093 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1103 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1094 } | 1104 } |
| 1095 | 1105 |
| 1096 test_class_alias_reference_generic() { | 1106 test_class_alias_reference_generic() { |
| 1097 EntityRef typeRef = serializeTypeText('C', | 1107 EntityRef typeRef = serializeTypeText('C', |
| 1098 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); | 1108 otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}'); |
| 1099 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1109 checkTypeRef(typeRef, null, null, 'C', |
| 1110 numTypeParameters: 2, numTypeArguments: elementMode ? 2 : 0); | |
| 1111 if (elementMode) { | |
| 1112 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 1113 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 1114 } | |
| 1100 } | 1115 } |
| 1101 | 1116 |
| 1102 test_class_alias_reference_generic_imported() { | 1117 test_class_alias_reference_generic_imported() { |
| 1103 addNamedSource( | 1118 addNamedSource( |
| 1104 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); | 1119 '/lib.dart', 'class C<D, E> = F with G; class F {} class G {}'); |
| 1105 EntityRef typeRef = | 1120 EntityRef typeRef = |
| 1106 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1121 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1107 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1122 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', |
| 1108 numTypeParameters: 2); | 1123 numTypeParameters: 2, numTypeArguments: elementMode ? 2 : 0); |
| 1124 if (elementMode) { | |
| 1125 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 1126 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 1127 } | |
| 1109 } | 1128 } |
| 1110 | 1129 |
| 1111 test_class_alias_supertype() { | 1130 test_class_alias_supertype() { |
| 1112 UnlinkedClass cls = | 1131 UnlinkedClass cls = |
| 1113 serializeClassText('class C = D with E; class D {} class E {}'); | 1132 serializeClassText('class C = D with E; class D {} class E {}'); |
| 1114 checkTypeRef(cls.supertype, null, null, 'D'); | 1133 checkTypeRef(cls.supertype, null, null, 'D'); |
| 1115 expect(cls.hasNoSupertype, isFalse); | 1134 expect(cls.hasNoSupertype, isFalse); |
| 1116 } | 1135 } |
| 1117 | 1136 |
| 1118 test_class_codeRange() { | 1137 test_class_codeRange() { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 } | 1330 } |
| 1312 | 1331 |
| 1313 test_class_private() { | 1332 test_class_private() { |
| 1314 serializeClassText('class _C {}', className: '_C'); | 1333 serializeClassText('class _C {}', className: '_C'); |
| 1315 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 1334 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 1316 } | 1335 } |
| 1317 | 1336 |
| 1318 test_class_reference_generic() { | 1337 test_class_reference_generic() { |
| 1319 EntityRef typeRef = | 1338 EntityRef typeRef = |
| 1320 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); | 1339 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}'); |
| 1321 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2); | 1340 checkTypeRef(typeRef, null, null, 'C', |
| 1341 numTypeParameters: 2, numTypeArguments: elementMode ? 2 : 0); | |
| 1342 if (elementMode) { | |
| 1343 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 1344 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 1345 } | |
| 1322 } | 1346 } |
| 1323 | 1347 |
| 1324 test_class_reference_generic_imported() { | 1348 test_class_reference_generic_imported() { |
| 1325 addNamedSource('/lib.dart', 'class C<D, E> {}'); | 1349 addNamedSource('/lib.dart', 'class C<D, E> {}'); |
| 1326 EntityRef typeRef = | 1350 EntityRef typeRef = |
| 1327 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); | 1351 serializeTypeText('C', otherDeclarations: 'import "lib.dart";'); |
| 1328 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', | 1352 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C', |
| 1329 numTypeParameters: 2); | 1353 numTypeParameters: 2, numTypeArguments: elementMode ? 2 : 0); |
| 1354 if (elementMode) { | |
| 1355 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 1356 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 1357 } | |
| 1330 } | 1358 } |
| 1331 | 1359 |
| 1332 test_class_superclass() { | 1360 test_class_superclass() { |
| 1333 UnlinkedClass cls = serializeClassText('class C {}'); | 1361 UnlinkedClass cls = serializeClassText('class C {}'); |
| 1334 expect(cls.supertype, isNull); | 1362 expect(cls.supertype, isNull); |
| 1335 expect(cls.hasNoSupertype, isFalse); | 1363 expect(cls.hasNoSupertype, isFalse); |
| 1336 } | 1364 } |
| 1337 | 1365 |
| 1338 test_class_superclass_explicit() { | 1366 test_class_superclass_explicit() { |
| 1339 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); | 1367 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); |
| 1340 expect(cls.supertype, isNotNull); | 1368 expect(cls.supertype, isNotNull); |
| 1341 checkTypeRef(cls.supertype, null, null, 'D'); | 1369 checkTypeRef(cls.supertype, null, null, 'D'); |
| 1342 expect(cls.hasNoSupertype, isFalse); | 1370 expect(cls.hasNoSupertype, isFalse); |
| 1343 } | 1371 } |
| 1344 | 1372 |
| 1345 test_class_type_param_bound() { | 1373 test_class_type_param_bound() { |
| 1346 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); | 1374 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); |
| 1347 expect(cls.typeParameters, hasLength(1)); | 1375 expect(cls.typeParameters, hasLength(1)); |
| 1348 expect(cls.typeParameters[0].name, 'T'); | 1376 { |
| 1349 expect(cls.typeParameters[0].bound, isNotNull); | 1377 UnlinkedTypeParam typeParameter = cls.typeParameters[0]; |
| 1350 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', | 1378 expect(typeParameter.name, 'T'); |
| 1351 numTypeParameters: 1); | 1379 expect(typeParameter.bound, isNotNull); |
| 1380 checkTypeRef(typeParameter.bound, 'dart:core', 'dart:core', 'List', | |
| 1381 numTypeParameters: 1, numTypeArguments: elementMode ? 1 : 0); | |
| 1382 if (elementMode) { | |
| 1383 checkDynamicTypeRef(typeParameter.bound.typeArguments[0]); | |
| 1384 } | |
| 1385 } | |
| 1352 } | 1386 } |
| 1353 | 1387 |
| 1354 test_class_type_param_f_bound() { | 1388 test_class_type_param_f_bound() { |
| 1355 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); | 1389 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); |
| 1356 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; | 1390 EntityRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; |
| 1357 checkParamTypeRef(typeArgument, 2); | 1391 checkParamTypeRef(typeArgument, 2); |
| 1358 } | 1392 } |
| 1359 | 1393 |
| 1360 test_class_type_param_f_bound_self_ref() { | 1394 test_class_type_param_f_bound_self_ref() { |
| 1361 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); | 1395 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;'); | 7452 serializeLibraryText('import "dart:async" as a; a.Future v;'); |
| 7419 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); | 7453 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); |
| 7420 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); | 7454 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); |
| 7421 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); | 7455 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); |
| 7422 } | 7456 } |
| 7423 | 7457 |
| 7424 test_import_prefix_reference() { | 7458 test_import_prefix_reference() { |
| 7425 UnlinkedVariable variable = | 7459 UnlinkedVariable variable = |
| 7426 serializeVariableText('import "dart:async" as a; a.Future v;'); | 7460 serializeVariableText('import "dart:async" as a; a.Future v;'); |
| 7427 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 7461 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', |
| 7428 expectedPrefix: 'a', numTypeParameters: 1); | 7462 expectedPrefix: 'a', |
| 7463 numTypeParameters: 1, | |
| 7464 numTypeArguments: elementMode ? 1 : 0); | |
| 7465 if (elementMode) { | |
| 7466 checkDynamicTypeRef(variable.type.typeArguments[0]); | |
| 7467 } | |
| 7429 } | 7468 } |
| 7430 | 7469 |
| 7431 test_import_prefixes_take_precedence_over_imported_names() { | 7470 test_import_prefixes_take_precedence_over_imported_names() { |
| 7432 addNamedSource('/a.dart', 'class b {} class A'); | 7471 addNamedSource('/a.dart', 'class b {} class A'); |
| 7433 addNamedSource('/b.dart', 'class Cls {}'); | 7472 addNamedSource('/b.dart', 'class Cls {}'); |
| 7434 addNamedSource('/c.dart', 'class Cls {}'); | 7473 addNamedSource('/c.dart', 'class Cls {}'); |
| 7435 addNamedSource('/d.dart', 'class c {} class D'); | 7474 addNamedSource('/d.dart', 'class c {} class D'); |
| 7436 serializeLibraryText(''' | 7475 serializeLibraryText(''' |
| 7437 import 'a.dart'; | 7476 import 'a.dart'; |
| 7438 import 'b.dart' as b; | 7477 import 'b.dart' as b; |
| 7439 import 'c.dart' as c; | 7478 import 'c.dart' as c; |
| 7440 import 'd.dart'; | 7479 import 'd.dart'; |
| 7441 A aCls; | 7480 A aCls; |
| 7442 b.Cls bCls; | 7481 b.Cls bCls; |
| 7443 c.Cls cCls; | 7482 c.Cls cCls; |
| 7444 D dCls; | 7483 D dCls; |
| 7445 '''); | 7484 '''); |
| 7446 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'a.dart', 'A'); | 7485 checkTypeRef(findVariable('aCls').type, absUri('/a.dart'), 'a.dart', 'A'); |
| 7447 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'b.dart', 'Cls', | 7486 checkTypeRef(findVariable('bCls').type, absUri('/b.dart'), 'b.dart', 'Cls', |
| 7448 expectedPrefix: 'b'); | 7487 expectedPrefix: 'b'); |
| 7449 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'c.dart', 'Cls', | 7488 checkTypeRef(findVariable('cCls').type, absUri('/c.dart'), 'c.dart', 'Cls', |
| 7450 expectedPrefix: 'c'); | 7489 expectedPrefix: 'c'); |
| 7451 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'd.dart', 'D'); | 7490 checkTypeRef(findVariable('dCls').type, absUri('/d.dart'), 'd.dart', 'D'); |
| 7452 } | 7491 } |
| 7453 | 7492 |
| 7454 test_import_reference() { | 7493 test_import_reference() { |
| 7455 UnlinkedVariable variable = | 7494 UnlinkedVariable variable = |
| 7456 serializeVariableText('import "dart:async"; Future v;'); | 7495 serializeVariableText('import "dart:async"; Future v;'); |
| 7457 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', | 7496 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', |
| 7458 numTypeParameters: 1); | 7497 numTypeParameters: 1, numTypeArguments: elementMode ? 1 : 0); |
| 7498 if (elementMode) { | |
| 7499 checkDynamicTypeRef(variable.type.typeArguments[0]); | |
| 7500 } | |
| 7459 } | 7501 } |
| 7460 | 7502 |
| 7461 test_import_reference_merged_no_prefix() { | 7503 test_import_reference_merged_no_prefix() { |
| 7462 serializeLibraryText(''' | 7504 serializeLibraryText(''' |
| 7463 import "dart:async" show Future; | 7505 import "dart:async" show Future; |
| 7464 import "dart:async" show Stream; | 7506 import "dart:async" show Stream; |
| 7465 | 7507 |
| 7466 Future f; | 7508 Future f; |
| 7467 Stream s; | 7509 Stream s; |
| 7468 '''); | 7510 '''); |
| 7469 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future', | 7511 { |
| 7470 numTypeParameters: 1); | 7512 EntityRef typeRef = findVariable('f').type; |
| 7471 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', | 7513 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', |
| 7472 expectedTargetUnit: 1, numTypeParameters: 1); | 7514 numTypeParameters: 1, numTypeArguments: elementMode ? 1 : 0); |
| 7515 if (elementMode) { | |
| 7516 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 7517 } | |
| 7518 } | |
| 7519 { | |
| 7520 EntityRef typeRef = findVariable('s').type; | |
| 7521 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', | |
| 7522 expectedTargetUnit: 1, | |
| 7523 numTypeParameters: 1, | |
| 7524 numTypeArguments: elementMode ? 1 : 0); | |
| 7525 if (elementMode) { | |
| 7526 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 7527 } | |
| 7528 } | |
| 7473 } | 7529 } |
| 7474 | 7530 |
| 7475 test_import_reference_merged_prefixed() { | 7531 test_import_reference_merged_prefixed() { |
| 7476 serializeLibraryText(''' | 7532 serializeLibraryText(''' |
| 7477 import "dart:async" as a show Future; | 7533 import "dart:async" as a show Future; |
| 7478 import "dart:async" as a show Stream; | 7534 import "dart:async" as a show Stream; |
| 7479 | 7535 |
| 7480 a.Future f; | 7536 a.Future f; |
| 7481 a.Stream s; | 7537 a.Stream s; |
| 7482 '''); | 7538 '''); |
| 7483 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future', | 7539 { |
| 7484 expectedPrefix: 'a', numTypeParameters: 1); | 7540 EntityRef typeRef = findVariable('f').type; |
| 7485 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', | 7541 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Future', |
| 7486 expectedTargetUnit: 1, expectedPrefix: 'a', numTypeParameters: 1); | 7542 expectedPrefix: 'a', |
| 7543 numTypeParameters: 1, | |
| 7544 numTypeArguments: elementMode ? 1 : 0); | |
| 7545 if (elementMode) { | |
| 7546 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 7547 } | |
| 7548 } | |
| 7549 { | |
| 7550 EntityRef typeRef = findVariable('s').type; | |
| 7551 checkTypeRef(typeRef, 'dart:async', 'dart:async', 'Stream', | |
| 7552 expectedTargetUnit: 1, | |
| 7553 expectedPrefix: 'a', | |
| 7554 numTypeParameters: 1, | |
| 7555 numTypeArguments: elementMode ? 1 : 0); | |
| 7556 if (elementMode) { | |
| 7557 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 7558 } | |
| 7559 } | |
| 7487 } | 7560 } |
| 7488 | 7561 |
| 7489 test_import_reference_merged_prefixed_separate_libraries() { | 7562 test_import_reference_merged_prefixed_separate_libraries() { |
| 7490 addNamedSource('/a.dart', 'class A {}'); | 7563 addNamedSource('/a.dart', 'class A {}'); |
| 7491 addNamedSource('/b.dart', 'class B {}'); | 7564 addNamedSource('/b.dart', 'class B {}'); |
| 7492 serializeLibraryText(''' | 7565 serializeLibraryText(''' |
| 7493 import 'a.dart' as p; | 7566 import 'a.dart' as p; |
| 7494 import 'b.dart' as p; | 7567 import 'b.dart' as p; |
| 7495 | 7568 |
| 7496 p.A a; | 7569 p.A a; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7551 | 7624 |
| 7552 test_inferred_type_keeps_leading_dynamic() { | 7625 test_inferred_type_keeps_leading_dynamic() { |
| 7553 if (!strongMode || skipFullyLinkedData) { | 7626 if (!strongMode || skipFullyLinkedData) { |
| 7554 return; | 7627 return; |
| 7555 } | 7628 } |
| 7556 UnlinkedClass cls = | 7629 UnlinkedClass cls = |
| 7557 serializeClassText('class C { final x = <dynamic, int>{}; }'); | 7630 serializeClassText('class C { final x = <dynamic, int>{}; }'); |
| 7558 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7631 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7559 // Check that x has inferred type `Map<dynamic, int>`. | 7632 // Check that x has inferred type `Map<dynamic, int>`. |
| 7560 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7633 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7561 allowTypeArguments: true, numTypeParameters: 2); | 7634 numTypeParameters: 2, numTypeArguments: 2); |
| 7562 expect(type.typeArguments, hasLength(2)); | |
| 7563 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); | 7635 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); |
| 7564 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 7636 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7565 } | 7637 } |
| 7566 | 7638 |
| 7567 test_inferred_type_refers_to_bound_type_param() { | 7639 test_inferred_type_refers_to_bound_type_param() { |
| 7568 if (!strongMode || skipFullyLinkedData) { | 7640 if (!strongMode || skipFullyLinkedData) { |
| 7569 return; | 7641 return; |
| 7570 } | 7642 } |
| 7571 UnlinkedClass cls = serializeClassText( | 7643 UnlinkedClass cls = serializeClassText( |
| 7572 'class C<T> extends D<int, T> { var v; }' | 7644 'class C<T> extends D<int, T> { var v; }' |
| 7573 ' abstract class D<U, V> { Map<V, U> get v; }', | 7645 ' abstract class D<U, V> { Map<V, U> get v; }', |
| 7574 className: 'C'); | 7646 className: 'C'); |
| 7575 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7647 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7576 // Check that v has inferred type Map<T, int>. | 7648 // Check that v has inferred type Map<T, int>. |
| 7577 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7649 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7578 allowTypeArguments: true, numTypeParameters: 2); | 7650 numTypeParameters: 2, numTypeArguments: 2); |
| 7579 checkParamTypeRef(type.typeArguments[0], 1); | 7651 checkParamTypeRef(type.typeArguments[0], 1); |
| 7580 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 7652 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7581 } | 7653 } |
| 7582 | 7654 |
| 7583 test_inferred_type_refers_to_function_typed_param_of_typedef() { | 7655 test_inferred_type_refers_to_function_typed_param_of_typedef() { |
| 7584 if (!strongMode || skipFullyLinkedData) { | 7656 if (!strongMode || skipFullyLinkedData) { |
| 7585 return; | 7657 return; |
| 7586 } | 7658 } |
| 7587 UnlinkedVariable v = serializeVariableText(''' | 7659 UnlinkedVariable v = serializeVariableText(''' |
| 7588 typedef void F(int g(String s)); | 7660 typedef void F(int g(String s)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7721 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); | 7793 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); |
| 7722 } | 7794 } |
| 7723 | 7795 |
| 7724 test_inferred_type_skips_trailing_dynamic() { | 7796 test_inferred_type_skips_trailing_dynamic() { |
| 7725 if (!strongMode || skipFullyLinkedData) { | 7797 if (!strongMode || skipFullyLinkedData) { |
| 7726 return; | 7798 return; |
| 7727 } | 7799 } |
| 7728 UnlinkedClass cls = | 7800 UnlinkedClass cls = |
| 7729 serializeClassText('class C { final x = <int, dynamic>{}; }'); | 7801 serializeClassText('class C { final x = <int, dynamic>{}; }'); |
| 7730 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7802 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7731 // Check that x has inferred type `Map<int>`. The trailing type argument | 7803 // Check that x has inferred type `Map<int, dynamic>`. |
| 7732 // `dynamic` is omitted. | |
| 7733 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7804 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7734 allowTypeArguments: true, numTypeParameters: 2); | 7805 numTypeParameters: 2, numTypeArguments: 2); |
| 7735 expect(type.typeArguments, hasLength(1)); | |
| 7736 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 7806 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 7807 checkLinkedDynamicTypeRef(type.typeArguments[1]); | |
| 7737 } | 7808 } |
| 7738 | 7809 |
| 7739 test_inferred_type_skips_unnecessary_dynamic() { | 7810 test_inferred_type_skips_unnecessary_dynamic() { |
| 7740 if (!strongMode || skipFullyLinkedData) { | 7811 if (!strongMode || skipFullyLinkedData) { |
| 7741 return; | 7812 return; |
| 7742 } | 7813 } |
| 7743 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); | 7814 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); |
| 7744 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7815 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7745 // Check that x has inferred type `List`, not `List<dynamic>`. | 7816 // Check that x has inferred type `List<dynamic>`. |
| 7746 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', | 7817 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', |
| 7747 numTypeParameters: 1); | 7818 numTypeParameters: 1, numTypeArguments: 1); |
| 7748 } | 7819 } |
| 7749 | 7820 |
| 7750 test_initializer_executable_with_bottom_return_type() { | 7821 test_initializer_executable_with_bottom_return_type() { |
| 7751 // The synthetic executable for `v` has type `() => Bottom`. | 7822 // The synthetic executable for `v` has type `() => Bottom`. |
| 7752 UnlinkedVariable variable = serializeVariableText('int v = null;'); | 7823 UnlinkedVariable variable = serializeVariableText('int v = null;'); |
| 7753 expect(variable.initializer.returnType, isNull); | 7824 expect(variable.initializer.returnType, isNull); |
| 7754 checkInferredTypeSlot( | 7825 checkInferredTypeSlot( |
| 7755 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', | 7826 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', |
| 7756 onlyInStrongMode: false); | 7827 onlyInStrongMode: false); |
| 7757 } | 7828 } |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8871 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', | 8942 checkTypeRef(propagatedType.syntheticParams[0].type, 'dart:core', |
| 8872 'dart:core', 'int'); | 8943 'dart:core', 'int'); |
| 8873 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', | 8944 checkTypeRef(propagatedType.syntheticParams[1].type, 'dart:core', |
| 8874 'dart:core', 'String'); | 8945 'dart:core', 'String'); |
| 8875 } | 8946 } |
| 8876 | 8947 |
| 8877 test_type_arguments_explicit() { | 8948 test_type_arguments_explicit() { |
| 8878 EntityRef typeRef = serializeTypeText('List<int>'); | 8949 EntityRef typeRef = serializeTypeText('List<int>'); |
| 8879 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 8950 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 8880 numTypeParameters: 1, numTypeArguments: 1); | 8951 numTypeParameters: 1, numTypeArguments: 1); |
| 8881 expect(typeRef.typeArguments, hasLength(1)); | |
| 8882 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 8952 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 8883 } | 8953 } |
| 8884 | 8954 |
| 8885 test_type_arguments_explicit_dynamic() { | 8955 test_type_arguments_explicit_dynamic() { |
| 8886 EntityRef typeRef = serializeTypeText('List<dynamic>'); | 8956 EntityRef typeRef = serializeTypeText('List<dynamic>'); |
| 8887 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 8957 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 8888 numTypeParameters: 1); | 8958 numTypeParameters: 1, numTypeArguments: 1); |
| 8889 expect(typeRef.typeArguments, isEmpty); | 8959 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8890 } | 8960 } |
| 8891 | 8961 |
| 8892 test_type_arguments_explicit_dynamic_dynamic() { | 8962 test_type_arguments_explicit_dynamic_dynamic() { |
| 8893 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); | 8963 EntityRef typeRef = serializeTypeText('Map<dynamic, dynamic>'); |
| 8894 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8964 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8895 numTypeParameters: 2); | 8965 numTypeParameters: 2, numTypeArguments: 2); |
| 8896 // Trailing type arguments of type `dynamic` are omitted. | 8966 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8897 expect(typeRef.typeArguments, isEmpty); | 8967 checkDynamicTypeRef(typeRef.typeArguments[1]); |
| 8898 } | 8968 } |
| 8899 | 8969 |
| 8900 test_type_arguments_explicit_dynamic_int() { | 8970 test_type_arguments_explicit_dynamic_int() { |
| 8901 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); | 8971 EntityRef typeRef = serializeTypeText('Map<dynamic, int>'); |
| 8902 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8972 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8903 numTypeParameters: 2, numTypeArguments: 2); | 8973 numTypeParameters: 2, numTypeArguments: 2); |
| 8904 // Leading type arguments of type `dynamic` are not omitted. | |
| 8905 expect(typeRef.typeArguments.length, 2); | |
| 8906 checkDynamicTypeRef(typeRef.typeArguments[0]); | 8974 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8907 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 8975 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 8908 } | 8976 } |
| 8909 | 8977 |
| 8910 test_type_arguments_explicit_dynamic_typedef() { | 8978 test_type_arguments_explicit_dynamic_typedef() { |
| 8911 EntityRef typeRef = | 8979 EntityRef typeRef = |
| 8912 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); | 8980 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); |
| 8913 checkTypeRef(typeRef, null, null, 'F', | 8981 checkTypeRef(typeRef, null, null, 'F', |
| 8914 expectedKind: ReferenceKind.typedef, | 8982 expectedKind: ReferenceKind.typedef, |
| 8915 numTypeParameters: 1, | 8983 numTypeParameters: 1, |
| 8916 numTypeArguments: 0); | 8984 numTypeArguments: 1); |
| 8917 expect(typeRef.typeArguments, isEmpty); | 8985 checkDynamicTypeRef(typeRef.typeArguments[0]); |
| 8918 } | 8986 } |
| 8919 | 8987 |
| 8920 test_type_arguments_explicit_String_dynamic() { | 8988 test_type_arguments_explicit_String_dynamic() { |
| 8921 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); | 8989 EntityRef typeRef = serializeTypeText('Map<String, dynamic>'); |
| 8922 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8990 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8923 numTypeParameters: 2, numTypeArguments: 1); | 8991 numTypeParameters: 2, numTypeArguments: 2); |
| 8924 // Trailing type arguments of type `dynamic` are omitted. | |
| 8925 expect(typeRef.typeArguments.length, 1); | |
| 8926 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 8992 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
| 8993 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 8927 } | 8994 } |
| 8928 | 8995 |
| 8929 test_type_arguments_explicit_String_int() { | 8996 test_type_arguments_explicit_String_int() { |
| 8930 EntityRef typeRef = serializeTypeText('Map<String, int>'); | 8997 EntityRef typeRef = serializeTypeText('Map<String, int>'); |
| 8931 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 8998 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8932 numTypeParameters: 2, numTypeArguments: 2); | 8999 numTypeParameters: 2, numTypeArguments: 2); |
| 8933 expect(typeRef.typeArguments.length, 2); | |
| 8934 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); | 9000 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'String'); |
| 8935 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 9001 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 8936 } | 9002 } |
| 8937 | 9003 |
| 8938 test_type_arguments_explicit_typedef() { | 9004 test_type_arguments_explicit_typedef() { |
| 8939 EntityRef typeRef = | 9005 EntityRef typeRef = |
| 8940 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); | 9006 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); |
| 8941 checkTypeRef(typeRef, null, null, 'F', | 9007 checkTypeRef(typeRef, null, null, 'F', |
| 8942 expectedKind: ReferenceKind.typedef, | 9008 expectedKind: ReferenceKind.typedef, |
| 8943 numTypeParameters: 1, | 9009 numTypeParameters: 1, |
| 8944 numTypeArguments: 1); | 9010 numTypeArguments: 1); |
| 8945 expect(typeRef.typeArguments, hasLength(1)); | |
| 8946 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9011 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 8947 } | 9012 } |
| 8948 | 9013 |
| 8949 test_type_arguments_implicit() { | 9014 test_type_arguments_implicit() { |
| 8950 EntityRef typeRef = serializeTypeText('List'); | 9015 EntityRef typeRef = serializeTypeText('List'); |
| 8951 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', | 9016 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', |
| 8952 numTypeParameters: 1); | 9017 numTypeParameters: 1, numTypeArguments: elementMode ? 1 : 0); |
| 8953 expect(typeRef.typeArguments, isEmpty); | 9018 if (elementMode) { |
| 9019 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 9020 } | |
| 8954 } | 9021 } |
| 8955 | 9022 |
| 8956 test_type_arguments_implicit_typedef() { | 9023 test_type_arguments_implicit_typedef() { |
| 8957 EntityRef typeRef = | 9024 EntityRef typeRef = |
| 8958 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); | 9025 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); |
| 8959 checkTypeRef(typeRef, null, null, 'F', | 9026 checkTypeRef(typeRef, null, null, 'F', |
| 8960 expectedKind: ReferenceKind.typedef, | 9027 expectedKind: ReferenceKind.typedef, |
| 8961 numTypeParameters: 1, | 9028 numTypeParameters: 1, |
| 8962 numTypeArguments: 0); | 9029 numTypeArguments: elementMode ? 1 : 0); |
| 8963 expect(typeRef.typeArguments, isEmpty); | 9030 if (elementMode) { |
| 9031 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 9032 } | |
| 9033 } | |
| 9034 | |
| 9035 test_type_arguments_implicit_typedef_withBound() { | |
| 9036 EntityRef typeRef = serializeTypeText('F', | |
| 9037 otherDeclarations: 'typedef T F<T extends num>();'); | |
| 9038 checkTypeRef(typeRef, null, null, 'F', | |
| 9039 expectedKind: ReferenceKind.typedef, | |
| 9040 numTypeParameters: 1, | |
| 9041 numTypeArguments: elementMode ? 1 : 0); | |
| 9042 if (elementMode) { | |
| 9043 if (strongMode) { | |
| 9044 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'num'); | |
| 9045 } else { | |
| 9046 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 9047 } | |
| 9048 } | |
| 8964 } | 9049 } |
| 8965 | 9050 |
| 8966 test_type_arguments_order() { | 9051 test_type_arguments_order() { |
| 8967 EntityRef typeRef = serializeTypeText('Map<int, Object>'); | 9052 EntityRef typeRef = serializeTypeText('Map<int, Object>'); |
| 8968 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', | 9053 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', |
| 8969 numTypeParameters: 2, numTypeArguments: 2); | 9054 numTypeParameters: 2, numTypeArguments: 2); |
| 8970 expect(typeRef.typeArguments, hasLength(2)); | |
| 8971 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9055 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 8972 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); | 9056 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); |
| 8973 } | 9057 } |
| 8974 | 9058 |
| 8975 test_type_dynamic() { | 9059 test_type_dynamic() { |
| 8976 checkDynamicTypeRef(serializeTypeText('dynamic')); | 9060 checkDynamicTypeRef(serializeTypeText('dynamic')); |
| 8977 } | 9061 } |
| 8978 | 9062 |
| 8979 test_type_param_codeRange() { | 9063 test_type_param_codeRange() { |
| 8980 UnlinkedClass cls = | 9064 UnlinkedClass cls = |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9284 | 9368 |
| 9285 test_typedef_private() { | 9369 test_typedef_private() { |
| 9286 serializeTypedefText('typedef _F();', '_F'); | 9370 serializeTypedefText('typedef _F();', '_F'); |
| 9287 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 9371 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 9288 } | 9372 } |
| 9289 | 9373 |
| 9290 test_typedef_reference_generic() { | 9374 test_typedef_reference_generic() { |
| 9291 EntityRef typeRef = | 9375 EntityRef typeRef = |
| 9292 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); | 9376 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();'); |
| 9293 checkTypeRef(typeRef, null, null, 'F', | 9377 checkTypeRef(typeRef, null, null, 'F', |
| 9294 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 9378 numTypeParameters: 2, |
| 9379 expectedKind: ReferenceKind.typedef, | |
| 9380 numTypeArguments: elementMode ? 2 : 0); | |
| 9381 if (elementMode) { | |
| 9382 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 9383 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 9384 } | |
| 9295 } | 9385 } |
| 9296 | 9386 |
| 9297 test_typedef_reference_generic_imported() { | 9387 test_typedef_reference_generic_imported() { |
| 9298 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); | 9388 addNamedSource('/lib.dart', 'typedef void F<A, B>();'); |
| 9299 EntityRef typeRef = | 9389 EntityRef typeRef = |
| 9300 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); | 9390 serializeTypeText('F', otherDeclarations: 'import "lib.dart";'); |
| 9301 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', | 9391 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F', |
| 9302 numTypeParameters: 2, expectedKind: ReferenceKind.typedef); | 9392 numTypeParameters: 2, |
| 9393 expectedKind: ReferenceKind.typedef, | |
| 9394 numTypeArguments: elementMode ? 2 : 0); | |
| 9395 if (elementMode) { | |
| 9396 checkDynamicTypeRef(typeRef.typeArguments[0]); | |
| 9397 checkDynamicTypeRef(typeRef.typeArguments[1]); | |
| 9398 } | |
| 9303 } | 9399 } |
| 9304 | 9400 |
| 9305 test_typedef_return_type_explicit() { | 9401 test_typedef_return_type_explicit() { |
| 9306 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); | 9402 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); |
| 9307 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); | 9403 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); |
| 9308 } | 9404 } |
| 9309 | 9405 |
| 9310 test_typedef_type_param_in_parameter() { | 9406 test_typedef_type_param_in_parameter() { |
| 9311 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); | 9407 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); |
| 9312 checkParamTypeRef(type.parameters[0].type, 1); | 9408 checkParamTypeRef(type.parameters[0].type, 1); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9580 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); | 9676 greaterThanOrEqualTo(unlinkedUnits[0].references.length)); |
| 9581 } | 9677 } |
| 9582 | 9678 |
| 9583 test_variable_propagated_type_omit_dynamic() { | 9679 test_variable_propagated_type_omit_dynamic() { |
| 9584 if (skipFullyLinkedData) { | 9680 if (skipFullyLinkedData) { |
| 9585 return; | 9681 return; |
| 9586 } | 9682 } |
| 9587 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};'); | 9683 UnlinkedVariable v = serializeVariableText('final v = <int, dynamic>{};'); |
| 9588 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot); | 9684 EntityRef type = getTypeRefForSlot(v.propagatedTypeSlot); |
| 9589 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 9685 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 9590 allowTypeArguments: true, numTypeParameters: 2); | 9686 numTypeParameters: 2, numTypeArguments: 2); |
| 9591 expect(type.typeArguments, hasLength(1)); | |
| 9592 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); | 9687 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 9688 checkLinkedDynamicTypeRef(type.typeArguments[1]); | |
| 9593 } | 9689 } |
| 9594 | 9690 |
| 9595 test_variable_propagatedTypeSlot_const() { | 9691 test_variable_propagatedTypeSlot_const() { |
| 9596 // Const variables are propagable so they have a nonzero | 9692 // Const variables are propagable so they have a nonzero |
| 9597 // propagatedTypeSlot. | 9693 // propagatedTypeSlot. |
| 9598 UnlinkedVariable variable = serializeVariableText('const v = 0;'); | 9694 UnlinkedVariable variable = serializeVariableText('const v = 0;'); |
| 9599 expect(variable.propagatedTypeSlot, isNot(0)); | 9695 expect(variable.propagatedTypeSlot, isNot(0)); |
| 9600 } | 9696 } |
| 9601 | 9697 |
| 9602 test_variable_propagatedTypeSlot_final() { | 9698 test_variable_propagatedTypeSlot_final() { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9793 class _PrefixExpectation { | 9889 class _PrefixExpectation { |
| 9794 final ReferenceKind kind; | 9890 final ReferenceKind kind; |
| 9795 final String name; | 9891 final String name; |
| 9796 final String absoluteUri; | 9892 final String absoluteUri; |
| 9797 final String relativeUri; | 9893 final String relativeUri; |
| 9798 final int numTypeParameters; | 9894 final int numTypeParameters; |
| 9799 | 9895 |
| 9800 _PrefixExpectation(this.kind, this.name, | 9896 _PrefixExpectation(this.kind, this.name, |
| 9801 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9897 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9802 } | 9898 } |
| OLD | NEW |