mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 05:16:40 +00:00
Don't use '.type' in TypeParameterMember.
R=brianwilkerson@google.com Change-Id: Icd481da622f226aa0e12c0f1f91820ce6c3a0537 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118889 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
3c18db7d9e
commit
38a3a6b6cb
|
@ -941,7 +941,7 @@ class TypeParameterMember extends Member implements TypeParameterElement {
|
||||||
TypeParameterType instantiate({
|
TypeParameterType instantiate({
|
||||||
@required NullabilitySuffix nullabilitySuffix,
|
@required NullabilitySuffix nullabilitySuffix,
|
||||||
}) {
|
}) {
|
||||||
return baseElement.instantiate(nullabilitySuffix: nullabilitySuffix);
|
return TypeParameterTypeImpl(this, nullabilitySuffix: nullabilitySuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -968,37 +968,39 @@ class TypeParameterMember extends Member implements TypeParameterElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<TypeParameterElement> from2(
|
static List<TypeParameterElement> from2(
|
||||||
List<TypeParameterElement> formals,
|
List<TypeParameterElement> elements,
|
||||||
MapSubstitution substitution,
|
MapSubstitution substitution,
|
||||||
) {
|
) {
|
||||||
if (substitution.map.isEmpty) {
|
if (substitution.map.isEmpty) {
|
||||||
return formals;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create type formals with specialized bounds.
|
// Create type formals with specialized bounds.
|
||||||
// For example `<U extends T>` where T comes from an outer scope.
|
// For example `<U extends T>` where T comes from an outer scope.
|
||||||
var newElements = formals.toList(growable: false);
|
var newElements = List<TypeParameterElement>(elements.length);
|
||||||
var newTypes = List<TypeParameterType>(formals.length);
|
var newTypes = List<TypeParameterType>(elements.length);
|
||||||
for (int i = 0; i < newElements.length; i++) {
|
for (int i = 0; i < newElements.length; i++) {
|
||||||
var formal = newElements[i];
|
var element = elements[i];
|
||||||
DartType bound = formal?.bound;
|
var bound = element?.bound;
|
||||||
if (bound != null) {
|
if (bound != null) {
|
||||||
bound = substitution.substituteType(bound);
|
bound = substitution.substituteType(bound);
|
||||||
var member = TypeParameterMember(formal, substitution, bound);
|
element = TypeParameterMember(element, substitution, bound);
|
||||||
newElements[i] = member;
|
|
||||||
}
|
}
|
||||||
newTypes[i] = newElements[i].type;
|
newElements[i] = element;
|
||||||
|
newTypes[i] = newElements[i].instantiate(
|
||||||
|
nullabilitySuffix: NullabilitySuffix.none,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursive bounds are allowed too, so make sure these are updated
|
// Recursive bounds are allowed too, so make sure these are updated
|
||||||
// to refer to any new TypeParameterMember we just made, rather than
|
// to refer to any new TypeParameterMember we just made, rather than
|
||||||
// the original type parameter
|
// the original type parameter
|
||||||
var substitution2 = Substitution.fromPairs(formals, newTypes);
|
var substitution2 = Substitution.fromPairs(elements, newTypes);
|
||||||
for (var formal in newElements) {
|
for (var newElement in newElements) {
|
||||||
if (formal is TypeParameterMember) {
|
if (newElement is TypeParameterMember) {
|
||||||
// TODO(jmesserly): this is required so substituting for the
|
// TODO(jmesserly): this is required so substituting for the
|
||||||
// type formal will work. Investigate if there's a better solution.
|
// type formal will work. Investigate if there's a better solution.
|
||||||
formal._bound = substitution2.substituteType(formal.bound);
|
newElement._bound = substitution2.substituteType(newElement.bound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newElements;
|
return newElements;
|
||||||
|
|
|
@ -191,17 +191,6 @@ class _FreshTypeParametersSubstitutor extends _TypeSubstitutor {
|
||||||
|
|
||||||
_FreshTypeParametersSubstitutor(_TypeSubstitutor outer) : super(outer);
|
_FreshTypeParametersSubstitutor(_TypeSubstitutor outer) : super(outer);
|
||||||
|
|
||||||
TypeParameterElement freshTypeParameter(TypeParameterElement element) {
|
|
||||||
var freshElement = new TypeParameterElementImpl(element.name, -1);
|
|
||||||
var freshType = new TypeParameterTypeImpl(freshElement);
|
|
||||||
freshElement.type = freshType;
|
|
||||||
substitution[element] = freshType;
|
|
||||||
if (element.bound != null) {
|
|
||||||
freshElement.bound = visit(element.bound);
|
|
||||||
}
|
|
||||||
return freshElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<TypeParameterElement> freshTypeParameters(
|
List<TypeParameterElement> freshTypeParameters(
|
||||||
List<TypeParameterElement> elements) {
|
List<TypeParameterElement> elements) {
|
||||||
|
|
Loading…
Reference in a new issue