|
21 | 21 |
|
22 | 22 | #include "swift/AST/ASTDemangler.h"
|
23 | 23 |
|
24 |
| -#include "swift/Subsystems.h" |
25 | 24 | #include "swift/AST/ASTContext.h"
|
26 | 25 | #include "swift/AST/Decl.h"
|
27 | 26 | #include "swift/AST/GenericSignature.h"
|
@@ -155,90 +154,7 @@ Type ASTBuilder::createBoundGenericType(NominalTypeDecl *decl,
|
155 | 154 | if (!validateNominalParent(decl, parent))
|
156 | 155 | return Type();
|
157 | 156 |
|
158 |
| - // Make a generic type repr that's been resolved to this decl. |
159 |
| - TypeReprList genericArgReprs(args); |
160 |
| - auto genericRepr = GenericIdentTypeRepr::create(Ctx, SourceLoc(), |
161 |
| - decl->getName(), |
162 |
| - genericArgReprs.getList(), |
163 |
| - SourceRange()); |
164 |
| - // FIXME |
165 |
| - genericRepr->setValue(decl, nullptr); |
166 |
| - |
167 |
| - Type genericType; |
168 |
| - |
169 |
| - // If we have a parent type, we need to build a compound type repr. |
170 |
| - if (parent) { |
171 |
| - // Life would be much easier if we could just use a FixedTypeRepr for |
172 |
| - // the parent. But we can't! So we have to recursively expand |
173 |
| - // like this; and recursing with a lambda isn't impossible, so it gets |
174 |
| - // even worse. |
175 |
| - SmallVector<Type, 4> ancestry; |
176 |
| - for (auto p = parent; p; p = p->getNominalParent()) { |
177 |
| - ancestry.push_back(p); |
178 |
| - } |
179 |
| - |
180 |
| - struct GenericRepr { |
181 |
| - TypeReprList GenericArgs; |
182 |
| - GenericIdentTypeRepr *Ident; |
183 |
| - |
184 |
| - GenericRepr(const ASTContext &Ctx, BoundGenericType *type) |
185 |
| - : GenericArgs(type->getGenericArgs()), |
186 |
| - Ident(GenericIdentTypeRepr::create(Ctx, SourceLoc(), |
187 |
| - type->getDecl()->getName(), |
188 |
| - GenericArgs.getList(), |
189 |
| - SourceRange())) { |
190 |
| - // FIXME |
191 |
| - Ident->setValue(type->getDecl(), nullptr); |
192 |
| - } |
193 |
| - |
194 |
| - // SmallVector::emplace_back will never need to call this because |
195 |
| - // we reserve the right size, but it does try statically. |
196 |
| - GenericRepr(const GenericRepr &other) : GenericArgs({}), Ident(nullptr) { |
197 |
| - llvm_unreachable("should not be called dynamically"); |
198 |
| - } |
199 |
| - }; |
200 |
| - |
201 |
| - // Pre-allocate the component vectors so that we can form references |
202 |
| - // into them safely. |
203 |
| - SmallVector<SimpleIdentTypeRepr, 4> simpleComponents; |
204 |
| - SmallVector<GenericRepr, 4> genericComponents; |
205 |
| - simpleComponents.reserve(ancestry.size()); |
206 |
| - genericComponents.reserve(ancestry.size()); |
207 |
| - |
208 |
| - // Build the parent hierarchy. |
209 |
| - SmallVector<ComponentIdentTypeRepr*, 4> componentReprs; |
210 |
| - for (size_t i = ancestry.size(); i != 0; --i) { |
211 |
| - Type p = ancestry[i - 1]; |
212 |
| - if (auto boundGeneric = p->getAs<BoundGenericType>()) { |
213 |
| - genericComponents.emplace_back(Ctx, boundGeneric); |
214 |
| - componentReprs.push_back(genericComponents.back().Ident); |
215 |
| - } else { |
216 |
| - auto nominal = p->castTo<NominalType>(); |
217 |
| - simpleComponents.emplace_back(SourceLoc(), |
218 |
| - nominal->getDecl()->getName()); |
219 |
| - // FIXME |
220 |
| - simpleComponents.back().setValue(nominal->getDecl(), nullptr); |
221 |
| - componentReprs.push_back(&simpleComponents.back()); |
222 |
| - } |
223 |
| - } |
224 |
| - componentReprs.push_back(genericRepr); |
225 |
| - |
226 |
| - auto compoundRepr = CompoundIdentTypeRepr::create(Ctx, componentReprs); |
227 |
| - genericType = checkTypeRepr(compoundRepr); |
228 |
| - } else { |
229 |
| - genericType = checkTypeRepr(genericRepr); |
230 |
| - } |
231 |
| - |
232 |
| - // If type-checking failed, we've failed. |
233 |
| - if (!genericType) return Type(); |
234 |
| - |
235 |
| - // Validate that we used the right decl. |
236 |
| - if (auto bgt = genericType->getAs<BoundGenericType>()) { |
237 |
| - if (bgt->getDecl() != decl) |
238 |
| - return Type(); |
239 |
| - } |
240 |
| - |
241 |
| - return genericType; |
| 157 | + return BoundGenericType::get(decl, parent, args); |
242 | 158 | }
|
243 | 159 |
|
244 | 160 | Type ASTBuilder::createTupleType(ArrayRef<Type> eltTypes,
|
@@ -434,16 +350,6 @@ bool ASTBuilder::validateNominalParent(NominalTypeDecl *decl,
|
434 | 350 | return true;
|
435 | 351 | }
|
436 | 352 |
|
437 |
| -Type ASTBuilder::checkTypeRepr(TypeRepr *repr) { |
438 |
| - DeclContext *dc = getNotionalDC(); |
439 |
| - |
440 |
| - TypeLoc loc(repr); |
441 |
| - if (performTypeLocChecking(Ctx, loc, dc, /*diagnose*/ false)) |
442 |
| - return Type(); |
443 |
| - |
444 |
| - return loc.getType(); |
445 |
| -} |
446 |
| - |
447 | 353 | NominalTypeDecl *
|
448 | 354 | ASTBuilder::getAcceptableNominalTypeCandidate(ValueDecl *decl,
|
449 | 355 | Demangle::Node::Kind kind) {
|
|
0 commit comments