From 8fbb5bbf5b15fa1e0defff6c2d862fd8b41ef0fb Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 15 Mar 2022 17:49:15 +0000 Subject: [PATCH] Remove GenericInferrer.considerExtendsClause. This logic allowed the analyzer to omit consideration of type parameter bounds during execution of the `matchSupertypeConstraints` method (which is used for mixin type parameter inference). I added it back in 2018 (https://dart-review.googlesource.com/c/sdk/+/44220) in an attempt to fix #32353, however after I made the fix, additional work by the front end team made it seem like I had probably misunderstood the issue. In any case, I've verified with both SDK trybots and an internal presubmit that removing this logic doesn't break anything, so I believe it's likely that the bug was later fixed in a different (and presumably more correct) fashion. I'm currently doing work on the analyzer's type inference logic, and GenericInferrer.considerExtendsClause is complicating my efforts, so it seems reasonable to remove it at this point. Change-Id: Ia0a988c7297e1579c2e96f9fa886e280f47ab62e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237003 Reviewed-by: Konstantin Shcheglov Commit-Queue: Paul Berry --- pkg/analyzer/lib/src/dart/element/generic_inferrer.dart | 8 ++------ pkg/analyzer/lib/src/dart/element/type_system.dart | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart index eb43608f4e7..a842f66e01f 100644 --- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart +++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart @@ -59,9 +59,6 @@ class GenericInferrer { /// The list of type parameters being inferred. final List _typeFormals; - /// Indicates whether type parameter bounds should be included in constraints. - final bool considerExtendsClause; - /// The [ErrorReporter] to which inference errors should be reported, or /// `null` if errors shouldn't be reported. final ErrorReporter? errorReporter; @@ -75,8 +72,7 @@ class GenericInferrer { final bool genericMetadataIsEnabled; GenericInferrer(this._typeSystem, this._typeFormals, - {this.considerExtendsClause = true, - this.errorReporter, + {this.errorReporter, this.errorNode, required this.genericMetadataIsEnabled}) { if (errorReporter != null) { @@ -438,7 +434,7 @@ class GenericInferrer { var typeParam = _typeFormals[i] as TypeParameterElementImpl; _TypeConstraint? extendsClause; var bound = typeParam.bound; - if (considerExtendsClause && bound != null) { + if (bound != null) { extendsClause = _TypeConstraint.fromExtends( typeParam, bound, diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart index 10f80f75a20..e782c15dffc 100644 --- a/pkg/analyzer/lib/src/dart/element/type_system.dart +++ b/pkg/analyzer/lib/src/dart/element/type_system.dart @@ -1219,7 +1219,6 @@ class TypeSystemImpl implements TypeSystem { }) { var typeParameters = mixinElement.typeParameters; var inferrer = GenericInferrer(this, typeParameters, - considerExtendsClause: false, genericMetadataIsEnabled: genericMetadataIsEnabled); for (int i = 0; i < srcTypes.length; i++) { inferrer.constrainReturnType(srcTypes[i], destTypes[i]);