mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 19:10:05 +00:00
Optimize gatherMixinSupertypeConstraints for new mixin syntax.
Since this method is only used to find supertype constraints that are relevant for mixin inference, it can save its caller from doing extra work by filtering out mixins that don't take type parameters. Previously, we were doing that when supporting the old "--supermixin" feature, but not when using the new mixin syntax. The method has been renamed to gatherMixinSupertypeConstraintsForInference so that it's less surprising that it doesn't return *all* supertype constraints. Change-Id: I33c5cf20bb4955a19ef0f7dc2425fefc26cf4d39 Reviewed-on: https://dart-review.googlesource.com/75983 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
5cf0d9e844
commit
e9ff597673
|
@ -5819,8 +5819,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
|||
var mixinElement = mixinType.element;
|
||||
if (mixinElement is ClassElement) {
|
||||
if (typeName.typeArguments == null) {
|
||||
var mixinSupertypeConstraints =
|
||||
_typeSystem.gatherMixinSupertypeConstraints(mixinElement);
|
||||
var mixinSupertypeConstraints = _typeSystem
|
||||
.gatherMixinSupertypeConstraintsForInference(mixinElement);
|
||||
if (mixinSupertypeConstraints.isNotEmpty) {
|
||||
var matchingInterfaceTypes = _findInterfaceTypesForConstraints(
|
||||
typeName,
|
||||
|
|
|
@ -1757,16 +1757,17 @@ abstract class TypeSystem {
|
|||
*/
|
||||
TypeProvider get typeProvider;
|
||||
|
||||
List<InterfaceType> gatherMixinSupertypeConstraints(
|
||||
List<InterfaceType> gatherMixinSupertypeConstraintsForInference(
|
||||
ClassElement mixinElement) {
|
||||
List<InterfaceType> candidates;
|
||||
if (mixinElement.isMixin) {
|
||||
return mixinElement.superclassConstraints;
|
||||
}
|
||||
|
||||
var candidates = [mixinElement.supertype];
|
||||
candidates.addAll(mixinElement.mixins);
|
||||
if (mixinElement.isMixinApplication) {
|
||||
candidates.removeLast();
|
||||
candidates = mixinElement.superclassConstraints;
|
||||
} else {
|
||||
candidates = [mixinElement.supertype];
|
||||
candidates.addAll(mixinElement.mixins);
|
||||
if (mixinElement.isMixinApplication) {
|
||||
candidates.removeLast();
|
||||
}
|
||||
}
|
||||
return candidates
|
||||
.where((type) => type.element.typeParameters.isNotEmpty)
|
||||
|
|
|
@ -715,7 +715,7 @@ class ClassElementForLink_Class extends ClassElementForLink
|
|||
this.enclosingElement;
|
||||
if (enclosingElement is CompilationUnitElementInBuildUnit) {
|
||||
var mixinSupertypeConstraints = context.typeSystem
|
||||
.gatherMixinSupertypeConstraints(mixinElement);
|
||||
.gatherMixinSupertypeConstraintsForInference(mixinElement);
|
||||
if (mixinSupertypeConstraints.isNotEmpty) {
|
||||
if (supertypesForMixinInference == null) {
|
||||
supertypesForMixinInference = <InterfaceType>[];
|
||||
|
|
Loading…
Reference in a new issue