@@ -2084,13 +2084,6 @@ TypeDecl *EquivalenceClass::lookupNestedType(
2084
2084
foundMembers);
2085
2085
for (auto member : foundMembers) {
2086
2086
if (auto type = dyn_cast<TypeDecl>(member)) {
2087
- // Resolve the signature of this type.
2088
- if (!type->hasInterfaceType ()) {
2089
- type->getASTContext ().getLazyResolver ()->resolveDeclSignature (type);
2090
- if (!type->hasInterfaceType ())
2091
- continue ;
2092
- }
2093
-
2094
2087
concreteDecls.push_back (type);
2095
2088
}
2096
2089
}
@@ -3812,25 +3805,31 @@ PotentialArchetype *GenericSignatureBuilder::realizePotentialArchetype(
3812
3805
return pa;
3813
3806
}
3814
3807
3808
+ static Type getStructuralType (TypeDecl *typeDecl, LazyResolver *resolver) {
3809
+ if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) {
3810
+ // Resolve the underlying type, if we haven't done so yet.
3811
+ if (!typealias->hasInterfaceType ())
3812
+ resolver->resolveDeclSignature (typealias);
3813
+
3814
+ return typealias->getUnderlyingTypeLoc ().getType ();
3815
+ }
3816
+
3817
+ return typeDecl->getDeclaredInterfaceType ();
3818
+ }
3819
+
3815
3820
static Type substituteConcreteType (GenericSignatureBuilder &builder,
3816
3821
PotentialArchetype *basePA,
3817
3822
TypeDecl *concreteDecl) {
3818
3823
assert (concreteDecl);
3819
3824
3820
3825
auto *proto = concreteDecl->getDeclContext ()->getSelfProtocolDecl ();
3821
3826
3822
- if (!concreteDecl-> hasInterfaceType ())
3823
- builder. getLazyResolver ()-> resolveDeclSignature (concreteDecl);
3824
-
3825
- if (!concreteDecl-> hasInterfaceType () )
3827
+ // Form an unsubstituted type referring to the given type declaration,
3828
+ // for use in an inferred same-type requirement.
3829
+ auto type = getStructuralType (concreteDecl, builder. getLazyResolver ());
3830
+ if (!type )
3826
3831
return Type ();
3827
3832
3828
- // The protocol concrete type has an underlying type written in terms
3829
- // of the protocol's 'Self' type.
3830
- auto typealias = dyn_cast<TypeAliasDecl>(concreteDecl);
3831
- auto type = typealias ? typealias->getUnderlyingTypeLoc ().getType ()
3832
- : concreteDecl->getDeclaredInterfaceType ();
3833
-
3834
3833
Type parentType;
3835
3834
SubstitutionMap subMap;
3836
3835
if (proto) {
@@ -3855,7 +3854,7 @@ static Type substituteConcreteType(GenericSignatureBuilder &builder,
3855
3854
}
3856
3855
3857
3856
// If we had a typealias, form a sugared type.
3858
- if (typealias) {
3857
+ if (auto * typealias = dyn_cast<TypeAliasDecl>(concreteDecl) ) {
3859
3858
type = TypeAliasType::get (typealias, parentType, subMap, type);
3860
3859
}
3861
3860
@@ -4226,34 +4225,13 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4226
4225
return result;
4227
4226
};
4228
4227
4229
- // Form an unsubstituted type referring to the given type declaration,
4230
- // for use in an inferred same-type requirement.
4231
- auto formUnsubstitutedType = [&](TypeDecl *typeDecl) -> Type {
4232
- if (auto assocType = dyn_cast<AssociatedTypeDecl>(typeDecl)) {
4233
- return DependentMemberType::get (
4234
- assocType->getProtocol ()->getSelfInterfaceType (),
4235
- assocType);
4236
- }
4237
-
4238
- // Resolve the underlying type, if we haven't done so yet.
4239
- if (!typeDecl->hasInterfaceType ()) {
4240
- getLazyResolver ()->resolveDeclSignature (typeDecl);
4241
- }
4242
-
4243
- if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) {
4244
- return typealias->getUnderlyingTypeLoc ().getType ();
4245
- }
4246
-
4247
- return typeDecl->getDeclaredInterfaceType ();
4248
- };
4249
-
4250
4228
// An inferred same-type requirement between the two type declarations
4251
4229
// within this protocol or a protocol it inherits.
4252
4230
auto addInferredSameTypeReq = [&](TypeDecl *first, TypeDecl *second) {
4253
- Type firstType = formUnsubstitutedType (first);
4231
+ Type firstType = getStructuralType (first, getLazyResolver () );
4254
4232
if (!firstType) return ;
4255
4233
4256
- Type secondType = formUnsubstitutedType (second);
4234
+ Type secondType = getStructuralType (second, getLazyResolver () );
4257
4235
if (!secondType) return ;
4258
4236
4259
4237
auto inferredSameTypeSource =
@@ -5170,11 +5148,6 @@ ConstraintResult GenericSignatureBuilder::addInheritedRequirements(
5170
5148
UnresolvedType type,
5171
5149
const RequirementSource *parentSource,
5172
5150
ModuleDecl *inferForModule) {
5173
- if (isa<AssociatedTypeDecl>(decl) &&
5174
- decl->hasInterfaceType () &&
5175
- decl->getInterfaceType ()->is <ErrorType>())
5176
- return ConstraintResult::Resolved;
5177
-
5178
5151
// Local function to get the source.
5179
5152
auto getFloatingSource = [&](const TypeRepr *typeRepr, bool forInferred) {
5180
5153
if (parentSource) {
0 commit comments