@@ -119,11 +119,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
119
119
120
120
auto requirements = genericSig->getLocalRequirements (depType);
121
121
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 ) {
127
123
return mapTypeIntoContext (requirements.concreteType ,
128
124
conformanceLookupFn);
129
125
}
@@ -140,9 +136,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
140
136
if (auto depMemTy = requirements.anchor ->getAs <DependentMemberType>()) {
141
137
parentArchetype =
142
138
getOrCreateArchetypeFromInterfaceType (depMemTy->getBase ())
143
- ->getAs <ArchetypeType>();
144
- if (!parentArchetype)
145
- return ErrorType::get (depMemTy);
139
+ ->castTo <ArchetypeType>();
146
140
147
141
auto name = depMemTy->getName ();
148
142
if (auto type = parentArchetype->getNestedTypeIfKnown (name))
@@ -156,39 +150,27 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
156
150
addMapping (genericParam, ErrorType::get (ctx));
157
151
}
158
152
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 ();
186
160
}
187
161
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 );
190
169
parentArchetype->registerNestedType (depMemTy->getName (), result);
191
170
} else {
171
+ result = PrimaryArchetypeType::getNew (ctx, this , genericParam,
172
+ requirements.protos , superclass,
173
+ requirements.layout );
192
174
addMapping (genericParam, result);
193
175
}
194
176
0 commit comments