Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1633863002: Support for constructor references in constant serializer and prelinker. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 * to the compilation unit within which the [typeRef] appears; if not 461 * to the compilation unit within which the [typeRef] appears; if not
462 * specified they are assumed to refer to the defining compilation unit. 462 * specified they are assumed to refer to the defining compilation unit.
463 * [expectedTargetUnit] is the index of the compilation unit in which the 463 * [expectedTargetUnit] is the index of the compilation unit in which the
464 * target of the [typeRef] is expected to appear; if not specified it is 464 * target of the [typeRef] is expected to appear; if not specified it is
465 * assumed to be the defining compilation unit. [numTypeParameters] is the 465 * assumed to be the defining compilation unit. [numTypeParameters] is the
466 * number of type parameters of the thing being referred to. 466 * number of type parameters of the thing being referred to.
467 */ 467 */
468 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri, 468 void checkTypeRef(EntityRef typeRef, String absoluteUri, String relativeUri,
469 String expectedName, 469 String expectedName,
470 {String expectedPrefix, 470 {String expectedPrefix,
471 List<_PrefixExpectation> prefixExpectations,
471 bool allowTypeParameters: false, 472 bool allowTypeParameters: false,
472 ReferenceKind expectedKind: ReferenceKind.classOrEnum, 473 ReferenceKind expectedKind: ReferenceKind.classOrEnum,
473 int expectedTargetUnit: 0, 474 int expectedTargetUnit: 0,
474 LinkedUnit linkedSourceUnit, 475 LinkedUnit linkedSourceUnit,
475 UnlinkedUnit unlinkedSourceUnit, 476 UnlinkedUnit unlinkedSourceUnit,
476 int numTypeParameters: 0}) { 477 int numTypeParameters: 0}) {
477 linkedSourceUnit ??= definingUnit; 478 linkedSourceUnit ??= definingUnit;
478 expect(typeRef, new isInstanceOf<EntityRef>()); 479 expect(typeRef, new isInstanceOf<EntityRef>());
479 expect(typeRef.paramReference, 0); 480 expect(typeRef.paramReference, 0);
480 int index = typeRef.reference; 481 int index = typeRef.reference;
481 if (!allowTypeParameters) { 482 if (!allowTypeParameters) {
482 expect(typeRef.typeArguments, isEmpty); 483 expect(typeRef.typeArguments, isEmpty);
483 } 484 }
484 UnlinkedReference reference = checkTypeRefCommonElements( 485 UnlinkedReference reference = checkTypeRefCommonElements(
485 index, 486 index,
486 absoluteUri, 487 absoluteUri,
487 relativeUri, 488 relativeUri,
488 expectedName, 489 expectedName,
489 expectedKind, 490 expectedKind,
490 expectedTargetUnit, 491 expectedTargetUnit,
491 linkedSourceUnit, 492 linkedSourceUnit,
492 unlinkedSourceUnit, 493 unlinkedSourceUnit,
493 numTypeParameters); 494 numTypeParameters);
494 expect(reference, isNotNull, 495 expect(reference, isNotNull,
495 reason: 'Unlinked type refs must refer to an explicit reference'); 496 reason: 'Unlinked type refs must refer to an explicit reference');
496 if (expectedKind == ReferenceKind.unresolved && !checkAstDerivedData) { 497 if (expectedKind == ReferenceKind.unresolved && !checkAstDerivedData) {
497 // summarize_elements.dart isn't yet able to record the prefix of 498 // summarize_elements.dart isn't yet able to record the prefix of
498 // unresolved references. TODO(paulberry): fix this. 499 // unresolved references. TODO(paulberry): fix this.
499 expect(reference.prefixReference, 0); 500 expect(reference.prefixReference, 0);
500 } else if (expectedPrefix == null) { 501 } else if (expectedPrefix != null) {
502 checkPrefix(reference.prefixReference, expectedPrefix);
503 } else if (prefixExpectations != null) {
504 for (_PrefixExpectation expectation in prefixExpectations) {
505 expect(reference.prefixReference, isNot(0));
506 reference = checkTypeRefCommonElements(
507 reference.prefixReference,
508 expectation.inLibraryDefiningUnit ? null : absoluteUri,
509 expectation.inLibraryDefiningUnit ? null : relativeUri,
510 expectation.name,
511 expectation.kind,
512 expectedTargetUnit,
513 linkedSourceUnit,
514 unlinkedSourceUnit,
515 expectation.numTypeParameters);
516 }
501 expect(reference.prefixReference, 0); 517 expect(reference.prefixReference, 0);
502 } else { 518 } else {
503 checkPrefix(reference.prefixReference, expectedPrefix); 519 expect(reference.prefixReference, 0);
504 } 520 }
505 } 521 }
506 522
507 /** 523 /**
508 * Check the data structures that are common between [checkTypeRef] and 524 * Check the data structures that are common between [checkTypeRef] and
509 * [checkLinkedTypeRef]. If the type reference in question is an explicit 525 * [checkLinkedTypeRef]. If the type reference in question is an explicit
510 * reference, return the [UnlinkedReference] that is used to make the 526 * reference, return the [UnlinkedReference] that is used to make the
511 * explicit reference. If the type reference in question is an implicit 527 * explicit reference. If the type reference in question is an implicit
512 * reference, return `null`. 528 * reference, return `null`.
513 */ 529 */
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 _assertUnlinkedConst(variable.constExpr, operators: [ 1521 _assertUnlinkedConst(variable.constExpr, operators: [
1506 UnlinkedConstOperation.pushInt, 1522 UnlinkedConstOperation.pushInt,
1507 UnlinkedConstOperation.pushNull, 1523 UnlinkedConstOperation.pushNull,
1508 UnlinkedConstOperation.identical 1524 UnlinkedConstOperation.identical
1509 ], ints: [ 1525 ], ints: [
1510 42 1526 42
1511 ]); 1527 ]);
1512 } 1528 }
1513 1529
1514 test_constExpr_invokeConstructor_named() { 1530 test_constExpr_invokeConstructor_named() {
1515 if (checkAstDerivedData) {
1516 // TODO(scheglov) at the moment we cannot link class member references
1517 return;
1518 }
1519 UnlinkedVariable variable = serializeVariableText(''' 1531 UnlinkedVariable variable = serializeVariableText('''
1520 class C { 1532 class C {
1521 const C.named(); 1533 const C.named();
1522 } 1534 }
1523 const v = const C.named(); 1535 const v = const C.named();
1524 '''); 1536 ''');
1525 _assertUnlinkedConst(variable.constExpr, operators: [ 1537 _assertUnlinkedConst(variable.constExpr, operators: [
1526 UnlinkedConstOperation.invokeConstructor, 1538 UnlinkedConstOperation.invokeConstructor,
1527 ], ints: [ 1539 ], ints: [
1528 0, 1540 0,
1529 0 1541 0
1530 ], strings: [
1531 'named'
1532 ], referenceValidators: [ 1542 ], referenceValidators: [
1533 (EntityRef r) => checkTypeRef(r, null, null, 'C', 1543 (EntityRef r) => checkTypeRef(r, null, null, 'named',
1534 expectedKind: ReferenceKind.classOrEnum) 1544 expectedKind: ReferenceKind.constructor,
1545 prefixExpectations: [
1546 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
1547 ])
1535 ]); 1548 ]);
1536 } 1549 }
1537 1550
1538 test_constExpr_invokeConstructor_named_imported() { 1551 test_constExpr_invokeConstructor_named_imported() {
1539 if (checkAstDerivedData) {
1540 // TODO(scheglov) at the moment we cannot link class member references
1541 return;
1542 }
1543 addNamedSource( 1552 addNamedSource(
1544 '/a.dart', 1553 '/a.dart',
1545 ''' 1554 '''
1546 class C { 1555 class C {
1547 const C.named(); 1556 const C.named();
1548 } 1557 }
1549 '''); 1558 ''');
1550 UnlinkedVariable variable = serializeVariableText(''' 1559 UnlinkedVariable variable = serializeVariableText('''
1551 import 'a.dart'; 1560 import 'a.dart';
1552 const v = const C.named(); 1561 const v = const C.named();
1553 '''); 1562 ''');
1554 _assertUnlinkedConst(variable.constExpr, operators: [ 1563 _assertUnlinkedConst(variable.constExpr, operators: [
1555 UnlinkedConstOperation.invokeConstructor, 1564 UnlinkedConstOperation.invokeConstructor,
1556 ], ints: [ 1565 ], ints: [
1557 0, 1566 0,
1558 0 1567 0
1559 ], strings: [
1560 'named'
1561 ], referenceValidators: [ 1568 ], referenceValidators: [
1562 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1569 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
1563 expectedKind: ReferenceKind.classOrEnum) 1570 expectedKind: ReferenceKind.constructor,
1571 prefixExpectations: [
1572 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
1573 ])
1564 ]); 1574 ]);
1565 } 1575 }
1566 1576
1567 test_constExpr_invokeConstructor_named_imported_withPrefix() { 1577 test_constExpr_invokeConstructor_named_imported_withPrefix() {
1568 addNamedSource( 1578 addNamedSource(
1569 '/a.dart', 1579 '/a.dart',
1570 ''' 1580 '''
1571 class C { 1581 class C {
1572 const C.named(); 1582 const C.named();
1573 } 1583 }
1574 '''); 1584 ''');
1575 UnlinkedVariable variable = serializeVariableText(''' 1585 UnlinkedVariable variable = serializeVariableText('''
1576 import 'a.dart' as p; 1586 import 'a.dart' as p;
1577 const v = const p.C.named(); 1587 const v = const p.C.named();
1578 '''); 1588 ''');
1579 _assertUnlinkedConst(variable.constExpr, operators: [ 1589 _assertUnlinkedConst(variable.constExpr, operators: [
1580 UnlinkedConstOperation.invokeConstructor, 1590 UnlinkedConstOperation.invokeConstructor,
1581 ], ints: [ 1591 ], ints: [
1582 0, 1592 0,
1583 0 1593 0
1584 ], strings: [
1585 'named'
1586 ], referenceValidators: [ 1594 ], referenceValidators: [
1587 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1595 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'named',
1588 expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p') 1596 expectedKind: ReferenceKind.constructor,
1597 prefixExpectations: [
1598 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'),
1599 new _PrefixExpectation(ReferenceKind.prefix, 'p',
1600 inLibraryDefiningUnit: true)
1601 ])
1589 ]); 1602 ]);
1590 } 1603 }
1591 1604
1592 test_constExpr_invokeConstructor_unnamed() { 1605 test_constExpr_invokeConstructor_unnamed() {
1593 UnlinkedVariable variable = serializeVariableText(''' 1606 UnlinkedVariable variable = serializeVariableText('''
1594 class C { 1607 class C {
1595 const C(a, b, c, d, {e, f, g}); 1608 const C(a, b, c, d, {e, f, g});
1596 } 1609 }
1597 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66); 1610 const v = const C(11, 22, 3.3, '444', e: 55, g: '777', f: 66);
1598 '''); 1611 ''');
(...skipping 17 matching lines...) Expand all
1616 66, 1629 66,
1617 3, 1630 3,
1618 4, 1631 4,
1619 ], doubles: [ 1632 ], doubles: [
1620 3.3 1633 3.3
1621 ], strings: [ 1634 ], strings: [
1622 '444', 1635 '444',
1623 '777', 1636 '777',
1624 'e', 1637 'e',
1625 'g', 1638 'g',
1626 'f', 1639 'f'
1627 ''
1628 ], referenceValidators: [ 1640 ], referenceValidators: [
1629 (EntityRef r) => checkTypeRef(r, null, null, 'C', 1641 (EntityRef r) => checkTypeRef(r, null, null, '',
1630 expectedKind: ReferenceKind.classOrEnum) 1642 expectedKind: ReferenceKind.constructor,
1643 prefixExpectations: [
1644 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
1645 ])
1631 ]); 1646 ]);
1632 } 1647 }
1633 1648
1634 test_constExpr_length() { 1649 test_constExpr_length() {
1635 UnlinkedVariable variable = 1650 UnlinkedVariable variable =
1636 serializeVariableText('const v = "abc".length;'); 1651 serializeVariableText('const v = "abc".length;');
1637 _assertUnlinkedConst(variable.constExpr, operators: [ 1652 _assertUnlinkedConst(variable.constExpr, operators: [
1638 UnlinkedConstOperation.pushString, 1653 UnlinkedConstOperation.pushString,
1639 UnlinkedConstOperation.length 1654 UnlinkedConstOperation.length
1640 ], strings: [ 1655 ], strings: [
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0); 3266 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0);
3252 } 3267 }
3253 3268
3254 test_field_inferred_type_nonstatic_explicit_initialized() { 3269 test_field_inferred_type_nonstatic_explicit_initialized() {
3255 UnlinkedVariable v = serializeClassText('class C { num v = 0; }').fields[0]; 3270 UnlinkedVariable v = serializeClassText('class C { num v = 0; }').fields[0];
3256 expect(v.inferredTypeSlot, 0); 3271 expect(v.inferredTypeSlot, 0);
3257 } 3272 }
3258 3273
3259 test_field_inferred_type_nonstatic_explicit_uninitialized() { 3274 test_field_inferred_type_nonstatic_explicit_uninitialized() {
3260 UnlinkedVariable v = serializeClassText( 3275 UnlinkedVariable v = serializeClassText(
3261 'class C extends D { num v; } abstract class D { int get v; }', 3276 'class C extends D { num v; } abstract class D { int get v; }',
3262 className: 'C', 3277 className: 'C',
3263 allowErrors: true).fields[0]; 3278 allowErrors: true)
3279 .fields[0];
3264 expect(v.inferredTypeSlot, 0); 3280 expect(v.inferredTypeSlot, 0);
3265 } 3281 }
3266 3282
3267 test_field_inferred_type_nonstatic_implicit_initialized() { 3283 test_field_inferred_type_nonstatic_implicit_initialized() {
3268 UnlinkedVariable v = serializeClassText('class C { var v = 0; }').fields[0]; 3284 UnlinkedVariable v = serializeClassText('class C { var v = 0; }').fields[0];
3269 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); 3285 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3270 } 3286 }
3271 3287
3272 test_field_inferred_type_nonstatic_implicit_uninitialized() { 3288 test_field_inferred_type_nonstatic_implicit_uninitialized() {
3273 UnlinkedVariable v = serializeClassText( 3289 UnlinkedVariable v = serializeClassText(
3274 'class C extends D { var v; } abstract class D { int get v; }', 3290 'class C extends D { var v; } abstract class D { int get v; }',
3275 className: 'C').fields[0]; 3291 className: 'C')
3292 .fields[0];
3276 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int'); 3293 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3277 } 3294 }
3278 3295
3279 test_field_inferred_type_static_explicit_initialized() { 3296 test_field_inferred_type_static_explicit_initialized() {
3280 UnlinkedVariable v = 3297 UnlinkedVariable v =
3281 serializeClassText('class C { static int v = 0; }').fields[0]; 3298 serializeClassText('class C { static int v = 0; }').fields[0];
3282 expect(v.inferredTypeSlot, 0); 3299 expect(v.inferredTypeSlot, 0);
3283 } 3300 }
3284 3301
3285 test_field_inferred_type_static_implicit_initialized() { 3302 test_field_inferred_type_static_implicit_initialized() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 * Docs 3380 * Docs
3364 */ 3381 */
3365 get f => null;'''; 3382 get f => null;''';
3366 UnlinkedExecutable executable = serializeExecutableText(text); 3383 UnlinkedExecutable executable = serializeExecutableText(text);
3367 expect(executable.documentationComment, isNotNull); 3384 expect(executable.documentationComment, isNotNull);
3368 checkDocumentationComment(executable.documentationComment, text); 3385 checkDocumentationComment(executable.documentationComment, text);
3369 } 3386 }
3370 3387
3371 test_getter_inferred_type_nonstatic_explicit_return() { 3388 test_getter_inferred_type_nonstatic_explicit_return() {
3372 UnlinkedExecutable f = serializeClassText( 3389 UnlinkedExecutable f = serializeClassText(
3373 'class C extends D { num get f => null; }' 3390 'class C extends D { num get f => null; }'
3374 ' abstract class D { int get f; }', 3391 ' abstract class D { int get f; }',
3375 className: 'C', 3392 className: 'C',
3376 allowErrors: true).executables[0]; 3393 allowErrors: true)
3394 .executables[0];
3377 expect(f.inferredReturnTypeSlot, 0); 3395 expect(f.inferredReturnTypeSlot, 0);
3378 } 3396 }
3379 3397
3380 test_getter_inferred_type_nonstatic_implicit_return() { 3398 test_getter_inferred_type_nonstatic_implicit_return() {
3381 UnlinkedExecutable f = serializeClassText( 3399 UnlinkedExecutable f = serializeClassText(
3382 'class C extends D { get f => null; } abstract class D { int get f; }', 3400 'class C extends D { get f => null; } abstract class D { int get f; }',
3383 className: 'C').executables[0]; 3401 className: 'C')
3402 .executables[0];
3384 checkInferredTypeSlot( 3403 checkInferredTypeSlot(
3385 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int'); 3404 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int');
3386 } 3405 }
3387 3406
3388 test_getter_inferred_type_static_implicit_return() { 3407 test_getter_inferred_type_static_implicit_return() {
3389 UnlinkedExecutable f = serializeClassText( 3408 UnlinkedExecutable f = serializeClassText(
3390 'class C extends D { static get f => null; }' 3409 'class C extends D { static get f => null; }'
3391 ' class D { static int get f => null; }', 3410 ' class D { static int get f => null; }',
3392 className: 'C').executables[0]; 3411 className: 'C')
3412 .executables[0];
3393 expect(f.inferredReturnTypeSlot, 0); 3413 expect(f.inferredReturnTypeSlot, 0);
3394 } 3414 }
3395 3415
3396 test_implicit_dependencies_follow_other_dependencies() { 3416 test_implicit_dependencies_follow_other_dependencies() {
3397 if (skipFullyLinkedData) { 3417 if (skipFullyLinkedData) {
3398 return; 3418 return;
3399 } 3419 }
3400 addNamedSource('/a.dart', 'import "b.dart"; class C {} D f() => null;'); 3420 addNamedSource('/a.dart', 'import "b.dart"; class C {} D f() => null;');
3401 addNamedSource('/b.dart', 'class D {}'); 3421 addNamedSource('/b.dart', 'class D {}');
3402 serializeLibraryText('import "a.dart"; final x = f(); C y;'); 3422 serializeLibraryText('import "a.dart"; final x = f(); C y;');
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3772 */ 3792 */
3773 f() {} 3793 f() {}
3774 }'''; 3794 }''';
3775 UnlinkedExecutable executable = serializeClassText(text).executables[0]; 3795 UnlinkedExecutable executable = serializeClassText(text).executables[0];
3776 expect(executable.documentationComment, isNotNull); 3796 expect(executable.documentationComment, isNotNull);
3777 checkDocumentationComment(executable.documentationComment, text); 3797 checkDocumentationComment(executable.documentationComment, text);
3778 } 3798 }
3779 3799
3780 test_method_inferred_type_nonstatic_explicit_param() { 3800 test_method_inferred_type_nonstatic_explicit_param() {
3781 UnlinkedExecutable f = serializeClassText( 3801 UnlinkedExecutable f = serializeClassText(
3782 'class C extends D { void f(num value) {} }' 3802 'class C extends D { void f(num value) {} }'
3783 ' abstract class D { void f(int value); }', 3803 ' abstract class D { void f(int value); }',
3784 className: 'C').executables[0]; 3804 className: 'C')
3805 .executables[0];
3785 expect(f.parameters[0].inferredTypeSlot, 0); 3806 expect(f.parameters[0].inferredTypeSlot, 0);
3786 } 3807 }
3787 3808
3788 test_method_inferred_type_nonstatic_explicit_return() { 3809 test_method_inferred_type_nonstatic_explicit_return() {
3789 UnlinkedExecutable f = serializeClassText( 3810 UnlinkedExecutable f = serializeClassText(
3790 'class C extends D { num f() => null; } abstract class D { int f(); }', 3811 'class C extends D { num f() => null; } abstract class D { int f(); }',
3791 className: 'C', 3812 className: 'C',
3792 allowErrors: true).executables[0]; 3813 allowErrors: true)
3814 .executables[0];
3793 expect(f.inferredReturnTypeSlot, 0); 3815 expect(f.inferredReturnTypeSlot, 0);
3794 } 3816 }
3795 3817
3796 test_method_inferred_type_nonstatic_implicit_param() { 3818 test_method_inferred_type_nonstatic_implicit_param() {
3797 UnlinkedExecutable f = serializeClassText( 3819 UnlinkedExecutable f = serializeClassText(
3798 'class C extends D { void f(value) {} }' 3820 'class C extends D { void f(value) {} }'
3799 ' abstract class D { void f(int value); }', 3821 ' abstract class D { void f(int value); }',
3800 className: 'C').executables[0]; 3822 className: 'C')
3823 .executables[0];
3801 checkInferredTypeSlot( 3824 checkInferredTypeSlot(
3802 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int'); 3825 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3803 } 3826 }
3804 3827
3805 test_method_inferred_type_nonstatic_implicit_return() { 3828 test_method_inferred_type_nonstatic_implicit_return() {
3806 UnlinkedExecutable f = serializeClassText( 3829 UnlinkedExecutable f = serializeClassText(
3807 'class C extends D { f() => null; } abstract class D { int f(); }', 3830 'class C extends D { f() => null; } abstract class D { int f(); }',
3808 className: 'C').executables[0]; 3831 className: 'C')
3832 .executables[0];
3809 checkInferredTypeSlot( 3833 checkInferredTypeSlot(
3810 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int'); 3834 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int');
3811 } 3835 }
3812 3836
3813 test_method_inferred_type_static_implicit_param() { 3837 test_method_inferred_type_static_implicit_param() {
3814 UnlinkedExecutable f = serializeClassText( 3838 UnlinkedExecutable f = serializeClassText(
3815 'class C extends D { static void f(value) {} }' 3839 'class C extends D { static void f(value) {} }'
3816 ' class D { static void f(int value) {} }', 3840 ' class D { static void f(int value) {} }',
3817 className: 'C').executables[0]; 3841 className: 'C')
3842 .executables[0];
3818 expect(f.parameters[0].inferredTypeSlot, 0); 3843 expect(f.parameters[0].inferredTypeSlot, 0);
3819 } 3844 }
3820 3845
3821 test_method_inferred_type_static_implicit_return() { 3846 test_method_inferred_type_static_implicit_return() {
3822 UnlinkedExecutable f = serializeClassText( 3847 UnlinkedExecutable f = serializeClassText(
3823 'class C extends D { static f() => null; }' 3848 'class C extends D { static f() => null; }'
3824 ' class D { static int f() => null; }', 3849 ' class D { static int f() => null; }',
3825 className: 'C').executables[0]; 3850 className: 'C')
3851 .executables[0];
3826 expect(f.inferredReturnTypeSlot, 0); 3852 expect(f.inferredReturnTypeSlot, 0);
3827 } 3853 }
3828 3854
3829 test_part_declaration() { 3855 test_part_declaration() {
3830 addNamedSource('/a.dart', 'part of my.lib;'); 3856 addNamedSource('/a.dart', 'part of my.lib;');
3831 String text = 'library my.lib; part "a.dart"; // <-part'; 3857 String text = 'library my.lib; part "a.dart"; // <-part';
3832 serializeLibraryText(text); 3858 serializeLibraryText(text);
3833 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); 3859 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
3834 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart'); 3860 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart');
3835 expect(unlinkedUnits[0].parts, hasLength(1)); 3861 expect(unlinkedUnits[0].parts, hasLength(1));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3868 * Docs 3894 * Docs
3869 */ 3895 */
3870 void set f(value) {}'''; 3896 void set f(value) {}''';
3871 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); 3897 UnlinkedExecutable executable = serializeExecutableText(text, 'f=');
3872 expect(executable.documentationComment, isNotNull); 3898 expect(executable.documentationComment, isNotNull);
3873 checkDocumentationComment(executable.documentationComment, text); 3899 checkDocumentationComment(executable.documentationComment, text);
3874 } 3900 }
3875 3901
3876 test_setter_inferred_type_nonstatic_explicit_param() { 3902 test_setter_inferred_type_nonstatic_explicit_param() {
3877 UnlinkedExecutable f = serializeClassText( 3903 UnlinkedExecutable f = serializeClassText(
3878 'class C extends D { void set f(num value) {} }' 3904 'class C extends D { void set f(num value) {} }'
3879 ' abstract class D { void set f(int value); }', 3905 ' abstract class D { void set f(int value); }',
3880 className: 'C').executables[0]; 3906 className: 'C')
3907 .executables[0];
3881 expect(f.parameters[0].inferredTypeSlot, 0); 3908 expect(f.parameters[0].inferredTypeSlot, 0);
3882 } 3909 }
3883 3910
3884 test_setter_inferred_type_nonstatic_explicit_return() { 3911 test_setter_inferred_type_nonstatic_explicit_return() {
3885 UnlinkedExecutable f = 3912 UnlinkedExecutable f =
3886 serializeClassText('class C { void set f(int value) {} }').executables[ 3913 serializeClassText('class C { void set f(int value) {} }').executables[
3887 0]; 3914 0];
3888 expect(f.inferredReturnTypeSlot, 0); 3915 expect(f.inferredReturnTypeSlot, 0);
3889 } 3916 }
3890 3917
3891 test_setter_inferred_type_nonstatic_implicit_param() { 3918 test_setter_inferred_type_nonstatic_implicit_param() {
3892 UnlinkedExecutable f = serializeClassText( 3919 UnlinkedExecutable f = serializeClassText(
3893 'class C extends D { void set f(value) {} }' 3920 'class C extends D { void set f(value) {} }'
3894 ' abstract class D { void set f(int value); }', 3921 ' abstract class D { void set f(int value); }',
3895 className: 'C').executables[0]; 3922 className: 'C')
3923 .executables[0];
3896 checkInferredTypeSlot( 3924 checkInferredTypeSlot(
3897 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int'); 3925 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3898 } 3926 }
3899 3927
3900 test_setter_inferred_type_nonstatic_implicit_return() { 3928 test_setter_inferred_type_nonstatic_implicit_return() {
3901 UnlinkedExecutable f = 3929 UnlinkedExecutable f =
3902 serializeClassText('class C { set f(int value) {} }').executables[0]; 3930 serializeClassText('class C { set f(int value) {} }').executables[0];
3903 checkInferredTypeSlot(f.inferredReturnTypeSlot, null, null, 'void'); 3931 checkInferredTypeSlot(f.inferredReturnTypeSlot, null, null, 'void');
3904 } 3932 }
3905 3933
3906 test_setter_inferred_type_static_implicit_param() { 3934 test_setter_inferred_type_static_implicit_param() {
3907 UnlinkedExecutable f = serializeClassText( 3935 UnlinkedExecutable f = serializeClassText(
3908 'class C extends D { static void set f(value) {} }' 3936 'class C extends D { static void set f(value) {} }'
3909 ' class D { static void set f(int value) {} }', 3937 ' class D { static void set f(int value) {} }',
3910 className: 'C').executables[0]; 3938 className: 'C')
3939 .executables[0];
3911 expect(f.parameters[0].inferredTypeSlot, 0); 3940 expect(f.parameters[0].inferredTypeSlot, 0);
3912 } 3941 }
3913 3942
3914 test_setter_inferred_type_static_implicit_return() { 3943 test_setter_inferred_type_static_implicit_return() {
3915 UnlinkedExecutable f = 3944 UnlinkedExecutable f =
3916 serializeClassText('class C { static set f(int value) {} }') 3945 serializeClassText('class C { static set f(int value) {} }')
3917 .executables[0]; 3946 .executables[0];
3918 expect(f.inferredReturnTypeSlot, 0); 3947 expect(f.inferredReturnTypeSlot, 0);
3919 } 3948 }
3920 3949
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
4583 expect(constExpr.operations, operators); 4612 expect(constExpr.operations, operators);
4584 expect(constExpr.ints, ints); 4613 expect(constExpr.ints, ints);
4585 expect(constExpr.doubles, doubles); 4614 expect(constExpr.doubles, doubles);
4586 expect(constExpr.strings, strings); 4615 expect(constExpr.strings, strings);
4587 expect(constExpr.references, hasLength(referenceValidators.length)); 4616 expect(constExpr.references, hasLength(referenceValidators.length));
4588 for (int i = 0; i < referenceValidators.length; i++) { 4617 for (int i = 0; i < referenceValidators.length; i++) {
4589 referenceValidators[i](constExpr.references[i]); 4618 referenceValidators[i](constExpr.references[i]);
4590 } 4619 }
4591 } 4620 }
4592 } 4621 }
4622
4623 class _PrefixExpectation {
Paul Berry 2016/01/26 00:47:21 Some documentation for this class would be really
scheglov 2016/01/26 04:34:49 Done.
4624 final ReferenceKind kind;
4625 final String name;
4626 final bool inLibraryDefiningUnit;
4627 final int numTypeParameters;
4628
4629 _PrefixExpectation(this.kind, this.name,
4630 {this.inLibraryDefiningUnit: false, this.numTypeParameters: 0});
4631 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698