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

Side by Side Diff: pkg/analyzer/lib/src/dart/constant/value.dart

Issue 2196483002: Revert "Revert "fix #26141, add support for type arguments to constants"" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add comments Created 4 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /** 5 /**
6 * The implementation of the class [DartObject]. 6 * The implementation of the class [DartObject].
7 */ 7 */
8 library analyzer.src.dart.constant.value; 8 library analyzer.src.dart.constant.value;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (state is SymbolState) { 713 if (state is SymbolState) {
714 return state.value; 714 return state.value;
715 } 715 }
716 return null; 716 return null;
717 } 717 }
718 718
719 @override 719 @override
720 DartType toTypeValue() { 720 DartType toTypeValue() {
721 InstanceState state = _state; 721 InstanceState state = _state;
722 if (state is TypeState) { 722 if (state is TypeState) {
723 Element element = state._element; 723 return state._type;
724 if (element is TypeDefiningElement) {
725 return element.type;
726 }
727 } 724 }
728 return null; 725 return null;
729 } 726 }
730 } 727 }
731 728
732 /** 729 /**
733 * The state of an object representing a double. 730 * The state of an object representing a double.
734 */ 731 */
735 class DoubleState extends NumState { 732 class DoubleState extends NumState {
736 /** 733 /**
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 String toString() => value == null ? "-unknown-" : "#$value"; 2761 String toString() => value == null ? "-unknown-" : "#$value";
2765 } 2762 }
2766 2763
2767 /** 2764 /**
2768 * The state of an object representing a type. 2765 * The state of an object representing a type.
2769 */ 2766 */
2770 class TypeState extends InstanceState { 2767 class TypeState extends InstanceState {
2771 /** 2768 /**
2772 * The element representing the type being modeled. 2769 * The element representing the type being modeled.
2773 */ 2770 */
2774 final Element _element; 2771 final DartType _type;
2775 2772
2776 /** 2773 /**
2777 * Initialize a newly created state to represent the given [value]. 2774 * Initialize a newly created state to represent the given [value].
2778 */ 2775 */
2779 TypeState(this._element); 2776 TypeState(this._type);
2780 2777
2781 @override 2778 @override
2782 int get hashCode => _element == null ? 0 : _element.hashCode; 2779 int get hashCode => _type?.hashCode ?? 0;
2783 2780
2784 @override 2781 @override
2785 String get typeName => "Type"; 2782 String get typeName => "Type";
2786 2783
2787 @override 2784 @override
2788 bool operator ==(Object object) => 2785 bool operator ==(Object object) =>
2789 object is TypeState && (_element == object._element); 2786 object is TypeState && (_type == object._type);
2790 2787
2791 @override 2788 @override
2792 StringState convertToString() { 2789 StringState convertToString() {
2793 if (_element == null) { 2790 if (_type == null) {
2794 return StringState.UNKNOWN_VALUE; 2791 return StringState.UNKNOWN_VALUE;
2795 } 2792 }
2796 return new StringState(_element.name); 2793 return new StringState(_type.displayName);
2797 } 2794 }
2798 2795
2799 @override 2796 @override
2800 BoolState equalEqual(InstanceState rightOperand) { 2797 BoolState equalEqual(InstanceState rightOperand) {
2801 assertBoolNumStringOrNull(rightOperand); 2798 assertBoolNumStringOrNull(rightOperand);
2802 return isIdentical(rightOperand); 2799 return isIdentical(rightOperand);
2803 } 2800 }
2804 2801
2805 @override 2802 @override
2806 BoolState isIdentical(InstanceState rightOperand) { 2803 BoolState isIdentical(InstanceState rightOperand) {
2807 if (_element == null) { 2804 if (_type == null) {
2808 return BoolState.UNKNOWN_VALUE; 2805 return BoolState.UNKNOWN_VALUE;
2809 } 2806 }
2810 if (rightOperand is TypeState) { 2807 if (rightOperand is TypeState) {
2811 Element rightElement = rightOperand._element; 2808 DartType rightType = rightOperand._type;
2812 if (rightElement == null) { 2809 if (rightType == null) {
2813 return BoolState.UNKNOWN_VALUE; 2810 return BoolState.UNKNOWN_VALUE;
2814 } 2811 }
2815 return BoolState.from(_element == rightElement); 2812 return BoolState.from(_type == rightType);
2816 } else if (rightOperand is DynamicState) { 2813 } else if (rightOperand is DynamicState) {
2817 return BoolState.UNKNOWN_VALUE; 2814 return BoolState.UNKNOWN_VALUE;
2818 } 2815 }
2819 return BoolState.FALSE_STATE; 2816 return BoolState.FALSE_STATE;
2820 } 2817 }
2821 2818
2822 @override 2819 @override
2823 String toString() => _element == null ? "-unknown-" : _element.name; 2820 String toString() => _type?.toString() ?? "-unknown-";
2824 } 2821 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/evaluation.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698