@@ -119,11 +119,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
119119
120120 auto requirements = genericSig->getLocalRequirements (depType);
121121
122- // FIXME: With the RequirementMachine, we will always have an anchor.
123- if (requirements.concreteType && !requirements.anchor ) {
124- if (requirements.concreteType ->is <ErrorType>())
125- return requirements.concreteType ;
126-
122+ if (requirements.concreteType ) {
127123 return mapTypeIntoContext (requirements.concreteType ,
128124 conformanceLookupFn);
129125 }
@@ -140,9 +136,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
140136 if (auto depMemTy = requirements.anchor ->getAs <DependentMemberType>()) {
141137 parentArchetype =
142138 getOrCreateArchetypeFromInterfaceType (depMemTy->getBase ())
143- ->getAs <ArchetypeType>();
144- if (!parentArchetype)
145- return ErrorType::get (depMemTy);
139+ ->castTo <ArchetypeType>();
146140
147141 auto name = depMemTy->getName ();
148142 if (auto type = parentArchetype->getNestedTypeIfKnown (name))
@@ -156,39 +150,27 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
156150 addMapping (genericParam, ErrorType::get (ctx));
157151 }
158152
159- Type result;
160-
161- // If this equivalence class is mapped to a concrete type, produce that
162- // type.
163- if (requirements.concreteType ) {
164- result = mapTypeIntoContext (requirements.concreteType ,
165- conformanceLookupFn);
166- } else {
167- // Substitute into the superclass.
168- Type superclass = requirements.superclass ;
169- if (superclass && superclass->hasTypeParameter ()) {
170- superclass = mapTypeIntoContext (superclass,
171- conformanceLookupFn);
172- if (superclass->is <ErrorType>())
173- superclass = Type ();
174- }
175-
176- if (parentArchetype) {
177- auto *depMemTy = requirements.anchor ->castTo <DependentMemberType>();
178- result = NestedArchetypeType::getNew (ctx, parentArchetype, depMemTy,
179- requirements.protos , superclass,
180- requirements.layout );
181- } else {
182- result = PrimaryArchetypeType::getNew (ctx, this , genericParam,
183- requirements.protos , superclass,
184- requirements.layout );
185- }
153+ // Substitute into the superclass.
154+ Type superclass = requirements.superclass ;
155+ if (superclass && superclass->hasTypeParameter ()) {
156+ superclass = mapTypeIntoContext (superclass,
157+ conformanceLookupFn);
158+ if (superclass->is <ErrorType>())
159+ superclass = Type ();
186160 }
187161
188- // Cache the new archetype for future lookups.
189- if (auto depMemTy = requirements.anchor ->getAs <DependentMemberType>()) {
162+ Type result;
163+
164+ if (parentArchetype) {
165+ auto *depMemTy = requirements.anchor ->castTo <DependentMemberType>();
166+ result = NestedArchetypeType::getNew (ctx, parentArchetype, depMemTy,
167+ requirements.protos , superclass,
168+ requirements.layout );
190169 parentArchetype->registerNestedType (depMemTy->getName (), result);
191170 } else {
171+ result = PrimaryArchetypeType::getNew (ctx, this , genericParam,
172+ requirements.protos , superclass,
173+ requirements.layout );
192174 addMapping (genericParam, result);
193175 }
194176
0 commit comments