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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 2456803004: fixes #27586, prefer context type in generic inference (Closed)
Patch Set: fix Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/member.dart ('k') | pkg/analyzer/lib/src/error/codes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 7e89111267204f50df81fa5282415dcf345cbd78..9dc98451a0c97b1811b4bf18fb3493231e069f6c 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -2660,9 +2660,47 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
@override
int get hashCode => element.hashCode;
+ /**
+ * Append a textual representation of this type to the given [buffer]. The set
+ * of [visitedTypes] is used to prevent infinite recursion.
+ */
+ void appendTo(StringBuffer buffer, Set<TypeImpl> visitedTypes) {
+ super.appendTo(buffer, visitedTypes);
+ TypeParameterElement e = element;
+ if (e is TypeParameterMember &&
+ e.bound != e.baseElement.bound &&
+ !_appendingBounds) {
+ buffer.write(' extends ');
+ // If we're appending bounds already, we don't want to do it recursively.
+ _appendingBounds = true;
+ try {
+ (e.bound as TypeImpl).appendTo(buffer, visitedTypes);
+ } finally {
+ _appendingBounds = false;
+ }
+ }
+ }
+
@override
- bool operator ==(Object object) =>
- object is TypeParameterTypeImpl && (element == object.element);
+ bool operator ==(Object other) {
+ if (other is TypeParameterTypeImpl && element == other.element) {
+ if (_comparingBounds) {
+ // If we're comparing bounds already, then we only need type variable
+ // equality.
+ return true;
+ }
+ _comparingBounds = true;
+ try {
+ return bound == other.bound;
+ } finally {
+ _comparingBounds = false;
+ }
+ }
+ return false;
+ }
+
+ static bool _comparingBounds = false;
+ static bool _appendingBounds = false;
@override
bool isMoreSpecificThan(DartType s,
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/member.dart ('k') | pkg/analyzer/lib/src/error/codes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698