Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit edbf630

Browse files
scheglovCommit Bot
authored andcommitted
Remove MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION.
When we cannot infer types, we leave `M<dynamic>` and report other errors. Change-Id: Ice6ebabf4bc844ee21aa1cc842e6496fcf8b3c11 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226660 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent c997e57 commit edbf630

File tree

4 files changed

+0
-128
lines changed

4 files changed

+0
-128
lines changed

pkg/analyzer/lib/error/error.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ const List<ErrorCode> errorCodeValues = [
293293
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
294294
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR,
295295
CompileTimeErrorCode.MIXIN_DEFERRED_CLASS,
296-
CompileTimeErrorCode.MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
297-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
298-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
299296
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,
300297
CompileTimeErrorCode.MIXIN_INSTANTIATE,
301298
CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8912,29 +8912,6 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
89128912
uniqueName: 'MIXIN_DEFERRED_CLASS',
89138913
);
89148914

8915-
static const CompileTimeErrorCode
8916-
MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES = CompileTimeErrorCode(
8917-
'MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES',
8918-
"Type parameters couldn't be inferred for the mixin '{0}' because the base "
8919-
"class implements the mixin's supertype constraint '{1}' in multiple "
8920-
"conflicting ways",
8921-
);
8922-
8923-
static const CompileTimeErrorCode MIXIN_INFERENCE_NO_MATCHING_CLASS =
8924-
CompileTimeErrorCode(
8925-
'MIXIN_INFERENCE_NO_MATCHING_CLASS',
8926-
"Type parameters couldn't be inferred for the mixin '{0}' because the base "
8927-
"class doesn't implement the mixin's supertype constraint '{1}'",
8928-
);
8929-
8930-
static const CompileTimeErrorCode MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION =
8931-
CompileTimeErrorCode(
8932-
'MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION',
8933-
"Type parameters couldn't be inferred for the mixin '{0}' because no type "
8934-
"parameter substitution could be found matching the mixin's supertype "
8935-
"constraints",
8936-
);
8937-
89388915
/**
89398916
* Parameters:
89408917
* 0: the name of the mixin that is invalid

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
13291329
CompileTimeErrorCode.IMPLEMENTS_REPEATED);
13301330
_checkImplementsSuperClass(implementsClause);
13311331
_checkMixinsSuperClass(withClause);
1332-
_checkMixinInference(node, withClause);
13331332
_checkForMixinWithConflictingPrivateMember(withClause, superclass);
13341333
_checkForConflictingGenerics(node);
13351334
if (node is ClassDeclaration) {
@@ -4758,56 +4757,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
47584757
}
47594758
}
47604759

4761-
void _checkMixinInference(
4762-
NamedCompilationUnitMember node, WithClause? withClause) {
4763-
if (withClause == null) {
4764-
return;
4765-
}
4766-
var classElement = node.declaredElement as ClassElement;
4767-
var supertype = classElement.supertype;
4768-
4769-
var interfacesMerger = InterfacesMerger(typeSystem);
4770-
interfacesMerger.addWithSupertypes(supertype);
4771-
4772-
for (var namedType in withClause.mixinTypes2) {
4773-
var mixinType = namedType.type;
4774-
if (mixinType is InterfaceType) {
4775-
var mixinElement = mixinType.element;
4776-
if (namedType.typeArguments == null) {
4777-
var mixinSupertypeConstraints = typeSystem
4778-
.gatherMixinSupertypeConstraintsForInference(mixinElement);
4779-
if (mixinSupertypeConstraints.isNotEmpty) {
4780-
var matchingInterfaceTypes = _findInterfaceTypesForConstraints(
4781-
namedType,
4782-
mixinSupertypeConstraints,
4783-
interfacesMerger.typeList,
4784-
);
4785-
if (matchingInterfaceTypes != null) {
4786-
// Try to pattern match matchingInterfaceType against
4787-
// mixinSupertypeConstraint to find the correct set of type
4788-
// parameters to apply to the mixin.
4789-
var inferredTypeArguments = typeSystem.matchSupertypeConstraints(
4790-
mixinElement,
4791-
mixinSupertypeConstraints,
4792-
matchingInterfaceTypes,
4793-
genericMetadataIsEnabled: _currentLibrary.featureSet
4794-
.isEnabled(Feature.generic_metadata),
4795-
);
4796-
if (inferredTypeArguments == null) {
4797-
errorReporter.reportErrorForToken(
4798-
CompileTimeErrorCode
4799-
.MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
4800-
namedType.name.beginToken,
4801-
[namedType]);
4802-
}
4803-
}
4804-
}
4805-
}
4806-
interfacesMerger.addWithSupertypes(mixinType);
4807-
}
4808-
}
4809-
}
4810-
48114760
/// Checks the class for problems with the superclass, mixins, or implemented
48124761
/// interfaces.
48134762
void _checkMixinInheritance(MixinDeclaration node, OnClause? onClause,
@@ -4965,51 +4914,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
49654914
}
49664915
}
49674916

4968-
InterfaceType? _findInterfaceTypeForMixin(NamedType mixin,
4969-
InterfaceType supertypeConstraint, List<InterfaceType> interfaceTypes) {
4970-
var element = supertypeConstraint.element;
4971-
InterfaceType? foundInterfaceType;
4972-
for (var interfaceType in interfaceTypes) {
4973-
if (interfaceType.element != element) continue;
4974-
if (foundInterfaceType == null) {
4975-
foundInterfaceType = interfaceType;
4976-
} else {
4977-
if (interfaceType != foundInterfaceType) {
4978-
errorReporter.reportErrorForToken(
4979-
CompileTimeErrorCode
4980-
.MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
4981-
mixin.name.beginToken,
4982-
[mixin, supertypeConstraint]);
4983-
}
4984-
}
4985-
}
4986-
if (foundInterfaceType == null) {
4987-
errorReporter.reportErrorForToken(
4988-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
4989-
mixin.name.beginToken,
4990-
[mixin, supertypeConstraint]);
4991-
}
4992-
return foundInterfaceType;
4993-
}
4994-
4995-
List<InterfaceType>? _findInterfaceTypesForConstraints(
4996-
NamedType mixin,
4997-
List<InterfaceType> supertypeConstraints,
4998-
List<InterfaceType> interfaceTypes) {
4999-
var result = <InterfaceType>[];
5000-
for (var constraint in supertypeConstraints) {
5001-
var interfaceType =
5002-
_findInterfaceTypeForMixin(mixin, constraint, interfaceTypes);
5003-
if (interfaceType == null) {
5004-
// No matching interface type found, so inference fails. The error has
5005-
// already been reported.
5006-
return null;
5007-
}
5008-
result.add(interfaceType);
5009-
}
5010-
return result;
5011-
}
5012-
50134917
/// Given an [expression] in a switch case whose value is expected to be an
50144918
/// enum constant, return the name of the constant.
50154919
String? _getConstantName(Expression expression) {

pkg/analyzer/messages.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7705,12 +7705,6 @@ CompileTimeErrorCode:
77057705

77067706
class B extends A {}
77077707
```
7708-
MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES:
7709-
problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class implements the mixin's supertype constraint '{1}' in multiple conflicting ways"
7710-
MIXIN_INFERENCE_NO_MATCHING_CLASS:
7711-
problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'"
7712-
MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION:
7713-
problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because no type parameter substitution could be found matching the mixin's supertype constraints"
77147708
MIXIN_INHERITS_FROM_NOT_OBJECT:
77157709
problemMessage: "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'."
77167710
hasPublishedDocs: true

0 commit comments

Comments
 (0)