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 <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2022-03-15 17:49:15 +00:00 committed by Commit Bot
parent 3f0988bc17
commit 8fbb5bbf5b
2 changed files with 2 additions and 7 deletions

View file

@ -59,9 +59,6 @@ class GenericInferrer {
/// The list of type parameters being inferred.
final List<TypeParameterElement> _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,

View file

@ -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]);