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

Side by Side Diff: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Issue 2972653002: Use entities internally in MemberTypeInformation (Closed)
Patch Set: Created 3 years, 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 compiler.src.inferrer.type_graph_nodes; 5 library compiler.src.inferrer.type_graph_nodes;
6 6
7 import 'dart:collection' show IterableBase; 7 import 'dart:collection' show IterableBase;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show Identifiers; 10 import '../common/names.dart' show Identifiers;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 * 333 *
334 * - Fields and parameters being assigned by synthesized calls done by 334 * - Fields and parameters being assigned by synthesized calls done by
335 * the backend: we do not know what types the backend will use. 335 * the backend: we do not know what types the backend will use.
336 * 336 *
337 * - Native functions and fields: because native methods contain no Dart 337 * - Native functions and fields: because native methods contain no Dart
338 * code, and native fields do not have Dart assignments, we just 338 * code, and native fields do not have Dart assignments, we just
339 * trust their type annotation. 339 * trust their type annotation.
340 * 340 *
341 */ 341 */
342 abstract class ElementTypeInformation extends TypeInformation { 342 abstract class ElementTypeInformation extends TypeInformation {
343 final Element _element;
344
345 /// Marker to disable inference for closures in [handleSpecialCases]. 343 /// Marker to disable inference for closures in [handleSpecialCases].
346 bool disableInferenceForClosures = true; 344 bool disableInferenceForClosures = true;
347 345
348 ElementTypeInformation._internal(MemberTypeInformation context, this._element) 346 ElementTypeInformation._internal(MemberTypeInformation context)
349 : super(context); 347 : super(context);
350 ElementTypeInformation._withAssignments(MemberTypeInformation context, 348 ElementTypeInformation._withAssignments(
351 this._element, ParameterAssignments assignments) 349 MemberTypeInformation context, ParameterAssignments assignments)
352 : super.withAssignments(context, assignments); 350 : super.withAssignments(context, assignments);
353 351
354 String getInferredSignature(TypeSystem types); 352 String getInferredSignature(TypeSystem types);
355 353
356 String get debugName; 354 String get debugName;
357 } 355 }
358 356
359 /** 357 /**
360 * A node representing members in the broadest sense: 358 * A node representing members in the broadest sense:
361 * 359 *
362 * - Functions 360 * - Functions
363 * - Constructors 361 * - Constructors
364 * - Fields (also synthetic ones due to closures) 362 * - Fields (also synthetic ones due to closures)
365 * - Local functions (closures) 363 * - Local functions (closures)
366 * 364 *
367 * These should never be created directly but instead are constructed by 365 * These should never be created directly but instead are constructed by
368 * the [ElementTypeInformation] factory. 366 * the [ElementTypeInformation] factory.
369 */ 367 */
370 abstract class MemberTypeInformation extends ElementTypeInformation 368 abstract class MemberTypeInformation extends ElementTypeInformation
371 with ApplyableTypeInformation { 369 with ApplyableTypeInformation {
372 MemberElement get _member => super._element; 370 final MemberEntity _member;
373 371
374 /** 372 /**
375 * If [element] is a function, [closurizedCount] is the number of 373 * If [element] is a function, [closurizedCount] is the number of
376 * times it is closurized. The value gets updated while inferring. 374 * times it is closurized. The value gets updated while inferring.
377 */ 375 */
378 int closurizedCount = 0; 376 int closurizedCount = 0;
379 377
380 // Strict `bool` value is computed in cleanup(). Also used as a flag to see if 378 // Strict `bool` value is computed in cleanup(). Also used as a flag to see if
381 // cleanup has been called. 379 // cleanup has been called.
382 bool _isCalledOnce = null; 380 bool _isCalledOnce = null;
383 381
384 /** 382 /**
385 * This map contains the callers of [element]. It stores all unique call sites 383 * This map contains the callers of [element]. It stores all unique call sites
386 * to enable counting the global number of call sites of [element]. 384 * to enable counting the global number of call sites of [element].
387 * 385 *
388 * A call site is either an AST [ast.Node], an [Element] (see uses of 386 * A call site is either an AST [ast.Node], an [Element] (see uses of
389 * [synthesizeForwardingCall] in [SimpleTypeInferrerVisitor]). 387 * [synthesizeForwardingCall] in [SimpleTypeInferrerVisitor]).
390 * 388 *
391 * The global information is summarized in [cleanup], after which [_callers] 389 * The global information is summarized in [cleanup], after which [_callers]
392 * is set to `null`. 390 * is set to `null`.
393 */ 391 */
394 Map<MemberElement, Setlet<Spannable>> _callers; 392 Map<MemberElement, Setlet<Spannable>> _callers;
395 393
396 MemberTypeInformation._internal(MemberElement element) 394 MemberTypeInformation._internal(this._member) : super._internal(null);
397 : super._internal(null, element);
398 395
399 MemberElement get member => _element; 396 MemberElement get member => _member;
400 397
401 String get debugName => '$member'; 398 String get debugName => '$member';
402 399
403 void addCall(MemberElement caller, Spannable node) { 400 void addCall(MemberElement caller, Spannable node) {
404 assert(node is ast.Node || node is Element); 401 assert(node is ast.Node || node is Element);
405 _callers ??= <MemberElement, Setlet<Spannable>>{}; 402 _callers ??= <MemberElement, Setlet<Spannable>>{};
406 _callers.putIfAbsent(caller, () => new Setlet()).add(node); 403 _callers.putIfAbsent(caller, () => new Setlet()).add(node);
407 } 404 }
408 405
409 void removeCall(MemberElement caller, node) { 406 void removeCall(MemberElement caller, node) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 inferrer.closedWorld.nativeData.getNativeMethodBehavior(function)) 464 inferrer.closedWorld.nativeData.getNativeMethodBehavior(function))
468 .type; 465 .type;
469 } 466 }
470 return null; 467 return null;
471 } 468 }
472 469
473 TypeMask potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 470 TypeMask potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
474 Compiler compiler = inferrer.compiler; 471 Compiler compiler = inferrer.compiler;
475 if (!compiler.options.trustTypeAnnotations && 472 if (!compiler.options.trustTypeAnnotations &&
476 !compiler.options.enableTypeAssertions && 473 !compiler.options.enableTypeAssertions &&
477 !inferrer.trustTypeAnnotations(_member)) { 474 !inferrer.optimizerHints.trustTypeAnnotations(_member)) {
478 return mask; 475 return mask;
479 } 476 }
480 return _potentiallyNarrowType(mask, inferrer); 477 return _potentiallyNarrowType(mask, inferrer);
481 } 478 }
482 479
483 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer); 480 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer);
484 481
485 TypeMask computeType(InferrerEngine inferrer) { 482 TypeMask computeType(InferrerEngine inferrer) {
486 TypeMask special = handleSpecialCases(inferrer); 483 TypeMask special = handleSpecialCases(inferrer);
487 if (special != null) return potentiallyNarrowType(special, inferrer); 484 if (special != null) return potentiallyNarrowType(special, inferrer);
(...skipping 19 matching lines...) Expand all
507 super.cleanup(); 504 super.cleanup();
508 } 505 }
509 506
510 @override 507 @override
511 String getInferredSignature(TypeSystem types) { 508 String getInferredSignature(TypeSystem types) {
512 return types.getInferredSignatureOfMethod(_member); 509 return types.getInferredSignatureOfMethod(_member);
513 } 510 }
514 } 511 }
515 512
516 class FieldTypeInformation extends MemberTypeInformation { 513 class FieldTypeInformation extends MemberTypeInformation {
517 FieldElement get _field => _member; 514 FieldEntity get _field => _member;
515 final DartType _type;
518 516
519 FieldTypeInformation(FieldElement element) : super._internal(element); 517 FieldTypeInformation(FieldEntity element, this._type)
518 : super._internal(element);
520 519
521 TypeMask handleSpecialCases(InferrerEngine inferrer) { 520 TypeMask handleSpecialCases(InferrerEngine inferrer) {
522 if (!inferrer.backend.canFieldBeUsedForGlobalOptimizations( 521 if (!inferrer.backend.canFieldBeUsedForGlobalOptimizations(
523 _field, inferrer.closedWorld) || 522 _field, inferrer.closedWorld) ||
524 inferrer.assumeDynamic(_field)) { 523 inferrer.optimizerHints.assumeDynamic(_field)) {
525 // Do not infer types for fields that have a corresponding annotation or 524 // Do not infer types for fields that have a corresponding annotation or
526 // are assigned by synthesized calls 525 // are assigned by synthesized calls
527 526
528 giveUp(inferrer); 527 giveUp(inferrer);
529 return safeType(inferrer); 528 return safeType(inferrer);
530 } 529 }
531 if (inferrer.closedWorld.nativeData.isNativeMember(_field)) { 530 if (inferrer.closedWorld.nativeData.isNativeMember(_field)) {
532 // Use the type annotation as the type for native elements. We 531 // Use the type annotation as the type for native elements. We
533 // also give up on inferring to make sure this element never 532 // also give up on inferring to make sure this element never
534 // goes in the work queue. 533 // goes in the work queue.
535 giveUp(inferrer); 534 giveUp(inferrer);
536 return inferrer 535 return inferrer
537 .typeOfNativeBehavior(inferrer.closedWorld.nativeData 536 .typeOfNativeBehavior(inferrer.closedWorld.nativeData
538 .getNativeFieldLoadBehavior(_field)) 537 .getNativeFieldLoadBehavior(_field))
539 .type; 538 .type;
540 } 539 }
541 return null; 540 return null;
542 } 541 }
543 542
544 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 543 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
545 return _narrowType(inferrer.closedWorld, mask, _field.type); 544 return _narrowType(inferrer.closedWorld, mask, _type);
546 } 545 }
547 546
548 bool hasStableType(InferrerEngine inferrer) { 547 bool hasStableType(InferrerEngine inferrer) {
549 // The number of assignments of non-final fields is 548 // The number of assignments of non-final fields is
550 // not stable. Therefore such a field cannot be stable. 549 // not stable. Therefore such a field cannot be stable.
551 if (!(_field.isConst || _field.isFinal)) { 550 if (!_field.isAssignable) {
552 return false; 551 return false;
553 } 552 }
554 return super.hasStableType(inferrer); 553 return super.hasStableType(inferrer);
555 } 554 }
556 } 555 }
557 556
558 class GetterTypeInformation extends MemberTypeInformation { 557 class GetterTypeInformation extends MemberTypeInformation {
559 GetterElement get _getter => _member; 558 FunctionEntity get _getter => _member;
559 final FunctionType _type;
560 560
561 GetterTypeInformation(GetterElement element) : super._internal(element); 561 GetterTypeInformation(FunctionEntity element, this._type)
562 : super._internal(element);
562 563
563 TypeMask handleSpecialCases(InferrerEngine inferrer) { 564 TypeMask handleSpecialCases(InferrerEngine inferrer) {
564 return _handleFunctionCase(_getter, inferrer); 565 return _handleFunctionCase(_getter, inferrer);
565 } 566 }
566 567
567 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 568 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
568 FunctionType type = _getter.type; 569 return _narrowType(inferrer.closedWorld, mask, _type.returnType);
569 return _narrowType(inferrer.closedWorld, mask, type.returnType);
570 } 570 }
571 571
572 bool hasStableType(InferrerEngine inferrer) { 572 bool hasStableType(InferrerEngine inferrer) {
573 return super.hasStableType(inferrer); 573 return super.hasStableType(inferrer);
574 } 574 }
575 } 575 }
576 576
577 class SetterTypeInformation extends MemberTypeInformation { 577 class SetterTypeInformation extends MemberTypeInformation {
578 SetterElement get _setter => _member; 578 FunctionEntity get _setter => _member;
579 579
580 SetterTypeInformation(SetterElement element) : super._internal(element); 580 SetterTypeInformation(FunctionEntity element) : super._internal(element);
581 581
582 TypeMask handleSpecialCases(InferrerEngine inferrer) { 582 TypeMask handleSpecialCases(InferrerEngine inferrer) {
583 return _handleFunctionCase(_setter, inferrer); 583 return _handleFunctionCase(_setter, inferrer);
584 } 584 }
585 585
586 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 586 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
587 return mask; 587 return mask;
588 } 588 }
589 589
590 bool hasStableType(InferrerEngine inferrer) { 590 bool hasStableType(InferrerEngine inferrer) {
591 return super.hasStableType(inferrer); 591 return super.hasStableType(inferrer);
592 } 592 }
593 } 593 }
594 594
595 class MethodTypeInformation extends MemberTypeInformation { 595 class MethodTypeInformation extends MemberTypeInformation {
596 MethodElement get _method => _member; 596 FunctionEntity get _method => _member;
597 final FunctionType _type;
597 598
598 MethodTypeInformation(MethodElement element) : super._internal(element); 599 MethodTypeInformation(FunctionEntity element, this._type)
600 : super._internal(element);
599 601
600 TypeMask handleSpecialCases(InferrerEngine inferrer) { 602 TypeMask handleSpecialCases(InferrerEngine inferrer) {
601 return _handleFunctionCase(_method, inferrer); 603 return _handleFunctionCase(_method, inferrer);
602 } 604 }
603 605
604 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 606 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
605 FunctionType type = _method.type; 607 return _narrowType(inferrer.closedWorld, mask, _type.returnType);
606 return _narrowType(inferrer.closedWorld, mask, type.returnType);
607 } 608 }
608 609
609 bool hasStableType(InferrerEngine inferrer) { 610 bool hasStableType(InferrerEngine inferrer) {
610 return false; 611 return false;
611 } 612 }
612 } 613 }
613 614
614 class FactoryConstructorTypeInformation extends MemberTypeInformation { 615 class FactoryConstructorTypeInformation extends MemberTypeInformation {
615 ConstructorElement get _constructor => _member; 616 ConstructorEntity get _constructor => _member;
617 final FunctionType _type;
616 618
617 FactoryConstructorTypeInformation(ConstructorElement element) 619 FactoryConstructorTypeInformation(ConstructorEntity element, this._type)
618 : super._internal(element); 620 : super._internal(element);
619 621
620 TypeMask handleSpecialCases(InferrerEngine inferrer) { 622 TypeMask handleSpecialCases(InferrerEngine inferrer) {
621 CommonMasks commonMasks = inferrer.commonMasks; 623 CommonMasks commonMasks = inferrer.commonMasks;
622 if (_constructor.isIntFromEnvironmentConstructor) { 624 if (_constructor.isFromEnvironmentConstructor) {
623 giveUp(inferrer); 625 if (_constructor.enclosingClass == inferrer.commonElements.intClass) {
624 return commonMasks.intType.nullable(); 626 giveUp(inferrer);
625 } else if (_constructor.isBoolFromEnvironmentConstructor) { 627 return commonMasks.intType.nullable();
626 giveUp(inferrer); 628 } else if (_constructor.enclosingClass ==
627 return commonMasks.boolType.nullable(); 629 inferrer.commonElements.boolClass) {
628 } else if (_constructor.isStringFromEnvironmentConstructor) { 630 giveUp(inferrer);
629 giveUp(inferrer); 631 return commonMasks.boolType.nullable();
630 return commonMasks.stringType.nullable(); 632 } else if (_constructor.enclosingClass ==
633 inferrer.commonElements.stringClass) {
634 giveUp(inferrer);
635 return commonMasks.stringType.nullable();
636 }
631 } 637 }
632 return _handleFunctionCase(_constructor, inferrer); 638 return _handleFunctionCase(_constructor, inferrer);
633 } 639 }
634 640
635 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 641 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
636 FunctionType type = _constructor.type; 642 return _narrowType(inferrer.closedWorld, mask, _type.returnType);
637 return _narrowType(inferrer.closedWorld, mask, type.returnType);
638 } 643 }
639 644
640 bool hasStableType(InferrerEngine inferrer) { 645 bool hasStableType(InferrerEngine inferrer) {
641 return super.hasStableType(inferrer); 646 return super.hasStableType(inferrer);
642 } 647 }
643 } 648 }
644 649
645 class GenerativeConstructorTypeInformation extends MemberTypeInformation { 650 class GenerativeConstructorTypeInformation extends MemberTypeInformation {
646 ConstructorElement get _constructor => _member; 651 ConstructorEntity get _constructor => _member;
647 652
648 GenerativeConstructorTypeInformation(ConstructorElement element) 653 GenerativeConstructorTypeInformation(ConstructorElement element)
649 : super._internal(element); 654 : super._internal(element);
650 655
651 TypeMask handleSpecialCases(InferrerEngine inferrer) { 656 TypeMask handleSpecialCases(InferrerEngine inferrer) {
652 return _handleFunctionCase(_constructor, inferrer); 657 return _handleFunctionCase(_constructor, inferrer);
653 } 658 }
654 659
655 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 660 TypeMask _potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
656 return mask; 661 return mask;
657 } 662 }
658 663
659 bool hasStableType(InferrerEngine inferrer) { 664 bool hasStableType(InferrerEngine inferrer) {
660 return super.hasStableType(inferrer); 665 return super.hasStableType(inferrer);
661 } 666 }
662 } 667 }
663 668
664 /** 669 /**
665 * A node representing parameters: 670 * A node representing parameters:
666 * 671 *
667 * - Parameters 672 * - Parameters
668 * - Initializing formals 673 * - Initializing formals
669 * 674 *
670 * These should never be created directly but instead are constructed by 675 * These should never be created directly but instead are constructed by
671 * the [ElementTypeInformation] factory. 676 * the [ElementTypeInformation] factory.
672 */ 677 */
673 class ParameterTypeInformation extends ElementTypeInformation { 678 class ParameterTypeInformation extends ElementTypeInformation {
674 ParameterElement get _parameter => super._element; 679 final ParameterElement _parameter;
675 final MethodElement _method; 680 final MethodElement _method;
676 bool _isInstanceMemberParameter; 681 bool _isInstanceMemberParameter;
677 bool _isClosureParameter; 682 bool _isClosureParameter;
678 bool _isTearOffClosureParameter = false; 683 bool _isTearOffClosureParameter = false;
679 684
680 ParameterTypeInformation.localFunction( 685 ParameterTypeInformation.localFunction(
681 MemberTypeInformation context, ParameterElement parameter, this._method) 686 MemberTypeInformation context, this._parameter, this._method)
682 : _isInstanceMemberParameter = false, 687 : _isInstanceMemberParameter = false,
683 _isClosureParameter = true, 688 _isClosureParameter = true,
684 super._internal(context, parameter); 689 super._internal(context);
685 690
686 ParameterTypeInformation.static( 691 ParameterTypeInformation.static(
687 MemberTypeInformation context, ParameterElement parameter, this._method) 692 MemberTypeInformation context, this._parameter, this._method)
688 : _isInstanceMemberParameter = false, 693 : _isInstanceMemberParameter = false,
689 _isClosureParameter = false, 694 _isClosureParameter = false,
690 super._internal(context, parameter); 695 super._internal(context);
691 696
692 ParameterTypeInformation.instanceMember( 697 ParameterTypeInformation.instanceMember(MemberTypeInformation context,
693 MemberTypeInformation context, 698 this._parameter, this._method, ParameterAssignments assignments)
694 ParameterElement parameter,
695 this._method,
696 ParameterAssignments assignments)
697 : _isInstanceMemberParameter = true, 699 : _isInstanceMemberParameter = true,
698 _isClosureParameter = false, 700 _isClosureParameter = false,
699 super._withAssignments(context, parameter, assignments); 701 super._withAssignments(context, assignments);
700 702
701 MethodElement get method => _method; 703 MethodElement get method => _method;
702 704
703 Local get parameter => _parameter; 705 Local get parameter => _parameter;
704 706
705 String get debugName => '$parameter'; 707 String get debugName => '$parameter';
706 708
707 void tagAsTearOffClosureParameter(InferrerEngine inferrer) { 709 void tagAsTearOffClosureParameter(InferrerEngine inferrer) {
708 assert(_parameter.isRegularParameter); 710 assert(_parameter.isRegularParameter);
709 _isTearOffClosureParameter = true; 711 _isTearOffClosureParameter = true;
710 // We have to add a flow-edge for the default value (if it exists), as we 712 // We have to add a flow-edge for the default value (if it exists), as we
711 // might not see all call-sites and thus miss the use of it. 713 // might not see all call-sites and thus miss the use of it.
712 TypeInformation defaultType = 714 TypeInformation defaultType =
713 inferrer.getDefaultTypeOfParameter(_parameter); 715 inferrer.getDefaultTypeOfParameter(_parameter);
714 if (defaultType != null) defaultType.addUser(this); 716 if (defaultType != null) defaultType.addUser(this);
715 } 717 }
716 718
717 // TODO(herhut): Cleanup into one conditional. 719 // TODO(herhut): Cleanup into one conditional.
718 TypeMask handleSpecialCases(InferrerEngine inferrer) { 720 TypeMask handleSpecialCases(InferrerEngine inferrer) {
719 if (!inferrer.backend.canFunctionParametersBeUsedForGlobalOptimizations( 721 if (!inferrer.backend.canFunctionParametersBeUsedForGlobalOptimizations(
720 _method, inferrer.closedWorld) || 722 _method, inferrer.closedWorld) ||
721 inferrer.assumeDynamic(_method)) { 723 inferrer.optimizerHints.assumeDynamic(_method)) {
722 // Do not infer types for parameters that have a corresponding annotation 724 // Do not infer types for parameters that have a corresponding annotation
723 // or that are assigned by synthesized calls. 725 // or that are assigned by synthesized calls.
724 giveUp(inferrer); 726 giveUp(inferrer);
725 return safeType(inferrer); 727 return safeType(inferrer);
726 } 728 }
727 729
728 // The below do not apply to parameters of constructors, so skip 730 // The below do not apply to parameters of constructors, so skip
729 // initializing formals. 731 // initializing formals.
730 if (_parameter.isInitializingFormal) return null; 732 if (_parameter.isInitializingFormal) return null;
731 733
(...skipping 28 matching lines...) Expand all
760 giveUp(inferrer); 762 giveUp(inferrer);
761 return safeType(inferrer); 763 return safeType(inferrer);
762 } 764 }
763 765
764 return null; 766 return null;
765 } 767 }
766 768
767 TypeMask potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) { 769 TypeMask potentiallyNarrowType(TypeMask mask, InferrerEngine inferrer) {
768 Compiler compiler = inferrer.compiler; 770 Compiler compiler = inferrer.compiler;
769 if (!compiler.options.trustTypeAnnotations && 771 if (!compiler.options.trustTypeAnnotations &&
770 !inferrer.trustTypeAnnotations(_method)) { 772 !inferrer.optimizerHints.trustTypeAnnotations(_method)) {
771 return mask; 773 return mask;
772 } 774 }
773 // When type assertions are enabled (aka checked mode), we have to always 775 // When type assertions are enabled (aka checked mode), we have to always
774 // ignore type annotations to ensure that the checks are actually inserted 776 // ignore type annotations to ensure that the checks are actually inserted
775 // into the function body and retained until runtime. 777 // into the function body and retained until runtime.
776 assert(!compiler.options.enableTypeAssertions); 778 assert(!compiler.options.enableTypeAssertions);
777 return _narrowType(inferrer.closedWorld, mask, _parameter.type); 779 return _narrowType(inferrer.closedWorld, mask, _parameter.type);
778 } 780 }
779 781
780 TypeMask computeType(InferrerEngine inferrer) { 782 TypeMask computeType(InferrerEngine inferrer) {
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 // TODO(ngeoffray): Narrow to bound. 1889 // TODO(ngeoffray): Narrow to bound.
1888 return type; 1890 return type;
1889 } else { 1891 } else {
1890 ResolutionInterfaceType interfaceType = annotation; 1892 ResolutionInterfaceType interfaceType = annotation;
1891 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); 1893 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld);
1892 } 1894 }
1893 if (isNullable) otherType = otherType.nullable(); 1895 if (isNullable) otherType = otherType.nullable();
1894 if (type == null) return otherType; 1896 if (type == null) return otherType;
1895 return type.intersection(otherType, closedWorld); 1897 return type.intersection(otherType, closedWorld);
1896 } 1898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698